iOS Tutorial Custom Fonts

In order to add custom font files to your application you need to follow these instructions:
1. Add the font file to the "special" folder: <project>\Files\Special
2. Add the #AppFont attribute for each font file (including the extension):
B4X:
#AppFont: papercuts-2.ttf
#AppFont: vermidirouge 1.0.ttf
3. Find the font name. You can double click on the font file:

SS-2014-11-04_15.13.26.png


4. Create a new font with this font name. The name should not include spaces:
B4X:
Label1.Font = Font.CreateNew2("VermidiRouge", 30)
Label2.Font = Font.CreateNew2("PaperCuts2", 20)

SS-2014-11-04_15.18.22.png



Note that #AppFont and the special folder features are not available in the current beta.
 

Attachments

  • CustomFonts.zip
    54.9 KB · Views: 948

JanPRO

Well-Known Member
Licensed User
I tried to use apple's san francisco font, but I got the following error:
Object was not initialized (UIFont)

My code:
B4X:
#AppFont: SF-UI-Display-Thin.otf
label1.Font = Font.CreateNew2("SFUIDisplayThin",20)

Edit: I just checked Font.AvailableNames and saw that the correct name is "SFUIDisplay-Thin". Solved :)
 
Last edited:
Top