NativeScript:字体家族未在Android上加载 [英] NativeScript: font-family not loading on Android

查看:66
本文介绍了NativeScript:字体家族未在Android上加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为Galano Grotesque xxx.otf字体(xxx = Alt Black,Alt Black Bold等)导入了一组文件,它在iOS上像超级按钮一样工作,但在Android上却不起作用.当我在Android上运行该应用程序时,该字体未加载.

I imported a set of files for Galano Grotesque xxx.otf font (xxx=Alt Black, Alt Black Bold, etc), and it works like a charm on iOS but not on Android. When I run the app on Android the font is not loaded.

我正在使用它:

Label {
    font-family: "Galano Grotesque";
    color: #5b5b5f;
}

我发现了此帖子- Android在NativeScript中未显示字体图标-我尝试过

I found this post - Android Not Showing Font Icon In NativeScript - and I tried this

Label {
    font-family: "Galano Grotesque", galano grotesque;
    color: #5b5b5f;
}

但没有成功:(

有人知道我该怎么做吗?

Does anybody knows what I can do to solve it?

谢谢

推荐答案

在iOS和Android中使用字体时,有一个主要注意事项. 为了使字体在iOS上正常工作,应使用确切的字体名称(请注意,这不是文件名!),在Android中,应使用特定的文件名引用字体. strong>.

There is one primary consideration when working with fonts in iOS and Android. For the font to work on iOS it should use the exact font name (notice that this is not the file name!) where in Android the font should be referenced with its particular file name.

示例: 假设您正在使用这里(此是免费的,用于演示) 下载后,您会看到文件名如下

Example: Let's assume you are using the Galano Grotesque DEMO Bold font from here (this one is free for demonstration purposes) When downloaded you will see that the file name is as follows

Rene Bieder - Galano Grotesque DEMO Bold.otf

但是字体名称是(在Mac中使用FontBook应用程序打开,以在弹出窗口顶部看到字体名称.对于Windows,请使用Windows Font Viewer打开字体,然后查找字体名称)

But the font name is (in Mac open with FontBook app to see the font-name at the top of the pop-up.. for Windows open the font with Windows Font Viewer and look for font name)

Galano Grotesque DEMO

因此要在iOS中使用它,您应该使用

So to use it in iOS, you should use

font-family: "Galano Grotesque DEMO";

对于Android,您应该使用

And for Android, you should use

font-family: "Rene Bieder - Galano Grotesque DEMO Bold";

当然,最佳做法是查看实际的字体名称,然后使用确切的名称重命名该文件,以便您可以在iOS和Android中重复使用它而无需使用其他CSS文件.

Of course, the best practice is to see what is the actual font name and rename the file with the exact name so you can reuse it in both iOS and Android with no different CSS files.

上述所有内容都请检查您在Android下的文件名,并确保CSS文件中的引用相同

All that said check your file name under Android and make sure that reference in the CSS file is the same

这篇关于NativeScript:字体家族未在Android上加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆