Cannot use custom font on Xamarin iOS

和自甴很熟 提交于 2019-12-13 00:06:16

问题


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>

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.

EDIT: This is how it's being used

     <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>


回答1:


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

PostScript name BebasNeueRegular
      Full name Bebas Neue Regular

So, in your code:

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

Re: https://stackoverflow.com/a/41567423/4984832

Re: https://stackoverflow.com/a/48191854/4984832

Re: https://stackoverflow.com/a/36942128/4984832



来源:https://stackoverflow.com/questions/50011220/cannot-use-custom-font-on-xamarin-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!