问题描述
我现在正在使用自定义字体,目前正在使用一种名为"Yellowtail-Regular.tff"的字体.我在iOS文件夹中创建了一个名为Fonts
的地图,并在其中添加了tff文件.之后,我进入Info.plist并创建了Fonts provided by application
,在其中创建了一个名为Fonts/Yellowtail-Regular.ttf
的新字符串.
I am working with custom fonts right now and currently a font named: "Yellowtail-Regular.tff". I created a map called Fonts
in my iOS folder and I added the tff file in there. After that I went to my Info.plist and created a Fonts provided by application
and in there I created a new string called Fonts/Yellowtail-Regular.ttf
.
当我现在尝试像这样使用它时:
When I now try to use it like this:
<Label FontFamily = "Yellowtail" Text = "Testing my label" />
标准字体(Helvetica Neue)仍然保留.我也尝试过:
The standard font (Helvetica Neue) still remains. I also tried with:
<Label FontFamily = "Yellowtail-Regular" Text = "Testing my label" />
但结果相同.
我错过了一步还是做错了什么?
Am I missing a step or am I doing something wrong?
推荐答案
如果您使用的是Yellowtail-Regular.ttf > http://www.1001freefonts.com/yellowtail.font ,则iOS
下的字体名称将仅为Yellowtail
.
If you are using Yellowtail-Regular.ttf
from http://www.1001freefonts.com/yellowtail.font, then that font name under iOS
would be just Yellowtail
.
每个平台都有不同的命名约定,因此使用Device.OnPlatform
可能类似于:
Each platform has different naming conventions, so using Device.OnPlatform
might look something like:
public Label()
{
FontFamily = Device.OnPlatform("Yellowtail", "Yellowtail-Regular", "/Assets/Yellowtail-Regular.ttf#Yellowtail-Regular");
}
要确认您的iOS字体系列名称,请在macOS
上使用Font Book
打开.ttf
,macOS
/iOS
将使用的名称是应用程序标题栏中的名称.
To confirm your iOS font family name, on macOS
open your .ttf
using Font Book
and the name that macOS
/iOS
will use is the one in the title bar of the app.
这篇关于为什么不使用自定义字体? Xamarin.Forms.iOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!