1
votes

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
but it simply does not work... What is the problem that you are exactly having?SushiHangover
That it won't apply the font i'm trying to use.Mauricio Cárdenas
It was simply added to the Resources folder on iOS project.Mauricio Cárdenas
The only code needed (apparenlty) to be able to use the custom font is the one on info.plist. If you want me to add the code where I actually use it, I will.Mauricio Cárdenas
@SushiHangover already edited to add usage.Mauricio Cárdenas

1 Answers

5
votes

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