iOS Question FontAwesome library crashing (UIFont not initialized)

andyr00d

Member
Licensed User
Longtime User
Hello,

I'm getting this error when trying to create my own FontAwesome typeface to use as a font for a list of labels I'm creating programmatically. Each label when created has a hex value which is converted to decimal to then display the relevant icon. I think the issue is either that the icons don't exist in the internal library or it's something to do with the sizing.

B4X:
lblWPIcon.Font = Font.CreateNew2("Font Awesome 5 Free Solid",17)

B4X:
Error occurred on line: 913 (Main)
Object was not initialized (UIFont)
)

I would like to say I am aware that there is already an internal B4X_FontAwesome.otf font which so far I've used and it's been great. The problem I have now is that in B4i there are some icons which are not showing with the default FA library - showing a question mark instead (screenshot below is an example). I had the same issue in B4A and solved it by downloading the official free file from the FontAwesome website and loading it in like this:

B4X:
    Dim FontAwesome As Typeface
    FontAwesome = Typeface.LoadFromAssets("FontAwesome5Free_Solid_900.otf")
    lblWPAIcon.Typeface = FontAwesome
    lblWPAIcon.Text = Chr(hexa2Decimal("f5a2"))

1.png


For reference the icon which is displaying correctly above is https://fontawesome.com/icons/users, the one which is not displaying correctly is: https://fontawesome.com/icons/store

I saw this thread but it is more related to the designer: https://www.b4x.com/android/forum/threads/solved-fontawesome-not-working-as-button-icons.105581/

Anyone know what else I can try?

Thanks!
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

andyr00d

Member
Licensed User
Longtime User
Example B4i project attached. This is only using the default FA library demonstrating some icons not showing from the FA collection (links inside code). Let me know if you want to include the full downloaded font inclusion, which will cause the crash.

screenshot.png
 

Attachments

  • FAdemo.zip
    110.6 KB · Views: 167
Upvote 0

andyr00d

Member
Licensed User
Longtime User
Just write 0xf5a2
Do you mean Label1.Text = Chr("0xf5a2")? That results in: java.lang.NumberFormatException: For input string: "0xf5a2"

2. Have you used the built-in icon picker to find these codes?

Yes and they don't all exist in there, which is why I was trying to reference the downloaded FA font and use that instead, but that results in the "not initialized" error as per my top post. I did reference the Fonts guide, and in fact I am already using another custom font in my B4i app with no issues.
 
Upvote 0

Semen Matusovskiy

Well-Known Member
Licensed User
FontAwesome download includes 3 otf files.
It's possible to expect the equal glyphs in all files, but this is not so.

I found interesting for you glyphs in Free Solid only. You can use FontForge to look a font internals.
 

Attachments

  • FADemo.zip
    483 KB · Views: 187
Upvote 0
Top