[Xamarin.Forms] Custom font handling made easy by MS

No more sorrow with custom font defining in Xamarin.Forms. Later we had to define a ResourceDictionary for storing platform specific filenames for our ttf files, import for each platform specific project the ttf file, and set a specific build action for them.

Now we only need to import the TTF file to our Xamarin.Forms project, and set the build action to BundleResource, and add a new line to assembly.cs:

[assembly: ExportFont("Nunito-Light.ttf", Alias = "Nunito")]

See reference at: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/text/fonts

Appreciate it!

This content has 4 years. Some of the information in this post may be out of date or no longer work. Please, read this page keeping its age in your mind.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.