How To Use Google Fonts In Xamarin Forms
Label text welcome to xamarin forms fontfamily myawesomecustomfont fontsize 50 horizontaloptions center verticaloptions centerandexpand under the hood the font is loaded and cached whenever you start the app.
How to use google fonts in xamarin forms. My entire mobile development career i have gone all in on using device specific images and icons. Because of that be mindful of how many custom fonts you are adding. Opensans regular fontfamily staticresource normalfont label text welcome to xamarin forms. These are properly scaled and sized images that fit 1x 2x 3x hdpi xhdpi xxhdi and so on which are great because they are super optimized for each platform. Xamarin already contains some popular font styles but if you want to add a new font style then this article completely belongs to you.
I ve first only added the main font montserrat regular and robotocondensed regular. Use font name label text hello xamarin forms fontfamily lobster regular alternatively it can be consumed on each platform by referencing its alias. They are critical to a business s branding and icon fonts like fontawesome or ionicons are increasingly used as a replacement for image icons. Now rebuild your solution and use your custom font in the xaml or c as you would normally use. I work on a xamarin forms project where i added 2 google fonts.
Using font icons in xamarin forms. The font can then be consumed on each platform by referencing its name without the file extension. I appreciate your help in this. In my mainpage i have one label with the standard hello world message from xamarin forms project and i am using my libre baskerville in the fontfamily property of the label control. You are ready to use a custom font.
I can use these fonts without any problem in my app with labels or buttons on ios and android. For my example i will use a google font like indie flower just visit the page and download the file by using the download family. First of all we need to get a font. In xamarin forms we include the font asset into each platform project and use the fontfamily property to apply the fonts in xaml. Custom fonts are one of the back bones of modern app development.
Then to use the font you just need to reference the key. Opensans bold fontfamily staticresource boldfont label text welcome to xamarin forms. Add font to xamarin forms app. This article demonstrate each and every steps required for adding font style in your app. Goodbye images hello fonts.