Lea*_*tto 3 css fonts android nativescript
我导入了一组 Galano Grotesque xxx.otf 字体文件(xxx=Alt Black、Alt Black Bold 等),它在 iOS 上就像一个魅力,但在 Android 上却不然。当我在 Android 上运行该应用程序时,字体未加载。
我正在使用这个:
Label {
font-family: "Galano Grotesque";
color: #5b5b5f;
}
Run Code Online (Sandbox Code Playgroud)
我发现这篇文章 - Android Not Showing Font Icon In NativeScript - 我尝试了这个
Label {
font-family: "Galano Grotesque", galano grotesque;
color: #5b5b5f;
}
Run Code Online (Sandbox Code Playgroud)
但没有成功:(
有人知道我能做什么来解决它吗?
谢谢
在 iOS 和 Android 中使用字体时有一个主要考虑因素。为了让字体在 iOS 上工作,它应该使用确切的字体名称(请注意,这不是文件名!),而在 Android 中,字体应该使用其特定的文件名来引用。
示例:假设您使用的是此处的 Galano Grotesque DEMO Bold 字体(该字体免费用于演示目的)下载后,您将看到文件名如下
Rene Bieder - Galano Grotesque DEMO Bold.otf
Run Code Online (Sandbox Code Playgroud)
但字体名称是(在 Mac 中使用 FontBook 应用程序打开,在弹出窗口顶部查看字体名称。对于 Windows,使用 Windows 字体查看器打开字体并查找字体名称)
Galano Grotesque DEMO
Run Code Online (Sandbox Code Playgroud)
所以要在 iOS 中使用它,你应该使用
font-family: "Galano Grotesque DEMO";
Run Code Online (Sandbox Code Playgroud)
对于 Android,你应该使用
font-family: "Rene Bieder - Galano Grotesque DEMO Bold";
Run Code Online (Sandbox Code Playgroud)
当然,最好的做法是查看实际的字体名称是什么,并使用确切的名称重命名该文件,这样您就可以在 iOS 和 Android 中重复使用它,而无需使用不同的 CSS 文件。
综上所述,请检查 Android 下的文件名并确保 CSS 文件中的引用相同