为什么不使用自定义字体? Xamarin.Forms.iOS [英] Why is the custom font not being used? Xamarin.Forms.iOS

查看:70
本文介绍了为什么不使用自定义字体? Xamarin.Forms.iOS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在正在使用自定义字体,目前正在使用一种名为"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打开.ttfmacOS/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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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