How To Use Google Fonts In Xamarin Forms
Goodbye images hello fonts.
How to use google fonts in xamarin forms. I appreciate your help in this. Custom fonts are one of the back bones of modern app development. I can use these fonts without any problem in my app with labels or buttons on ios and android. Add font to xamarin forms app. My entire mobile development career i have gone all in on using device specific images and icons.
Stacklayout label text welcome to xamarin forms. Opensans bold fontfamily staticresource boldfont label text welcome to 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. This article demonstrate each and every steps required for adding font style in your app. I downloaded a greek true type font from google i placed it in the assets folder under a folder i named fonts.
Use font alias label text hello xamarin forms fontfamily lobster. 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. 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. The result is the word displays in english and not greek. I ve first only added the main font montserrat regular and robotocondensed regular.
Then to use the font you just need to reference the key. Then i try to use it in the page where i want to display the greek words using xamarin label command with font family and text parameters. Using font icons in xamarin forms. In xamarin forms we include the font asset into each platform project and use the fontfamily property to apply the fonts in xaml. 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.
Opensans regular fontfamily staticresource normalfont label text welcome to xamarin forms. They are critical to a business s branding and icon fonts like fontawesome or ionicons are increasingly used as a replacement for image icons. But when i try to apply a fontattributes like italic or bold this doesn t work. First of all we need to get a font. You are ready to use a custom font.