Search code examples
iosxamarinxamarin.formsxamarin.iostruetype

Cannot use custom font on Xamarin iOS


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>


Solution

  • 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