无法在Xamarin iOS上使用自定义字体 [英] Cannot use custom font on Xamarin iOS

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

问题描述

我一直在尝试在Xamarin iOS上使用自定义字体,但它根本不起作用.这是我的info.plist:

I've been trying to use a custom font on Xamarin iOS but it simply does not work. This is my info.plist:

    <key>UIAppFonts</key>
<array>
    <string>BebasNeue-Regular.ttf</string>
</array>

我还将.ttf文件的构建操作设置为BundleResource并始终复制",如我已经阅读的一些教程中所示.如果我将生成操作更改为编译"(正如我在其他教程中所发现的那样),它将根本无法生成.

I also set the build action of the .ttf file to BundleResource and "always copy" as shown on several tutorials I already read. If I change the build action to Compile (as I found on other tutorials), it will simply not build.

这就是它的使用方式

     <Label Text="Hello Forms with XAML">
<Label.FontFamily>
    <OnPlatform x:TypeArguments="x:String">
            <On Platform="iOS" Value="BebasNeue-Regular" />
            <On Platform="Android" Value="BebasNeue-Regular.ttf#BebasNeue-Regular" />
    </OnPlatform>
</Label.FontFamily>

推荐答案

在macOS Font Book应用中打开字体并查看实际名称:

Open the font in the macOS Font Book app and review the actual name:

PostScript name BebasNeueRegular
      Full name Bebas Neue Regular

因此,在您的代码中:

<On Platform="iOS" Value="Bebas Neue Regular" />

回复: https://stackoverflow.com/a/41567423/4984832

回复: https://stackoverflow.com/a/48191854/4984832

回复: https://stackoverflow.com/a/36942128/4984832

这篇关于无法在Xamarin iOS上使用自定义字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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