Forked from andrewsheley/gist:8077a245027e4b06f5b7bb89efc6aa1e
Created
January 17, 2020 17:51
-
-
Save graco911/7256a7365a3e3863aa2aed807c0f48c1 to your computer and use it in GitHub Desktop.
Xamarin FontAwesome as Icons FAQ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To Use FontAwesome | |
1. Download Free FontAwesome fonts from website, grab the "Web" fonts. URL:https://fontawesome.com/download | |
2. Unzip and copy the font file into both Android and IOS projects. Verify build action. | |
a. For IOS add entry to info.plist at bottom before </dict> element. | |
<key>UIAppFonts</key> | |
<array> | |
<string>fa-solid-900.ttf</string> | |
</array> | |
3. Add fontfamily text to App resources. Use appropriate Font Famil name from font and filename. | |
<OnPlatform x:Key="MaterialFontFamily" x:TypeArguments="x:String"> | |
<On Platform="iOS" Value="Font Awesome 5 Free" /> | |
<On Platform="Android" Value="fa-solid-900.ttf#Font Awesome 5 Free" /> | |
</OnPlatform> | |
4. Create static class with Icon names for string values. URL: https://andreinitescu.github.io/IconFont2Code/ | |
5. Examples of using font as image: | |
<Label FontFamily="{StaticResource MaterialFontFamily}" Text="{x:Static local:IconFont.Map}"></Label> | |
<Image> | |
<Image.Source> | |
<FontImageSource | |
FontFamily="{StaticResource MaterialFontFamily}" | |
Glyph="{x:Static local:IconFont.Cog}" | |
Size="44" | |
Color="Black" /> | |
</Image.Source> | |
</Image> | |
************ IMPORTANT ****************************** | |
For IOS if you have issues delete application from emulator, clean the IOS project then debug/build F5. It seems to cache the font??? | |
Import URLs | |
Font awesome fonts: https://fontawesome.com/download | |
Icon Fonts to Code: https://andreinitescu.github.io/IconFont2Code/ | |
James Montamagno page on it: https://montemagno.com/using-font-icons-in-xamarin-forms-goodbye-images-hello-fonts/ | |
Xappy App that is good example of fonts being used: https://github.com/davidortinau/Xappy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment