I want to use some custom Fonts (.ttf) in my Xamarin.Forms Application.
I added the two Fonts in both Projects(Android/iOS):
Now in the XAML-Page, I added the Fonts to the ResourceDictionary.
It's also possible to use the Fonts, but just in the XAML-File:
<Label Text="Test" FontFamily="{StaticResource FONT}" FontSize="Medium"/>
But how can I use this font in the C# Code?
FontFamily="Roboto-Regular.ttf#Roboto-Regular", as per your fonts.ResourceDictionaryin code behind:Application.Current.Resources["MyResourceName"]. Remember to cast this to the correct type. If you do it this way you won't have to change the font in multiple places if that's ever needed. Also I advise you to define general styles and use those in your controls (that way you can customize a lot more automatically)StyleforLabelin yourResourceDictionarythat sets theFontFamilyyou can just cast and use thatStylein code-behind