B4A Library FontAwesome

This library will allow you to use FontAwesome on any view that supports Typeface (except Spinner).

Requirements:

1- B4A 4.x.

2- Copy the FontAwesome.xml and FontAwesome.jar to your additional libraries directory.

Usage:
B4X:
'Initialize the library.
Private FA As FontAwesome

FA.Initialize

'Add the FontAwesome typeface to your view.
Label1.Typeface = FA.FontAwesomeTypeface

'Select the icon you want to display.
Label1.Text = FA.GetFontAwesomeIconByName("fa-android") & "  Some title label  " & FA.GetFontAwesomeIconByNumber(0xf15d)
That's it!!

Notes:

* If an icon isn't defined the library will show a "?" or a blank-square (get all the defined icons by name and their numbers from the Cheat Sheet)

Screenshot:

vt5GWftl.png
 

Attachments

  • FontAwesome_Sample.zip
    38.4 KB · Views: 904
  • FontAwesome_Lib_1.5.zip
    97.8 KB · Views: 1,116
Last edited:

adastra

Member
Licensed User
Longtime User
when run showing error

B4A version: 5.50 BETA #1
Parsing code. (0.00s)
Compiling code. (0.02s)
Compiling layouts code. (0.00s)
Generating R file. Error
res\values-v14\theme.xml:7: error: Error: No resource found that matches the given name: attr 'android:windowTranslucentNavigation'.
res\values-v14\theme.xml:6: error: Error: No resource found that matches the given name: attr 'android:windowTranslucentStatus'.
res\values-v14\theme.xml:11: error: Error retrieving parent for item: No resource found that matches the given name '@android:style/Widget.Holo.Light.ActionBar.Solid'.
res\values-v14\theme.xml:17: error: Error retrieving parent for item: No resource found that matches the given name '@android:style/TextAppearance.Holo.Widget.ActionBar.Title'.
 

valentino s

Active Member
Licensed User
Longtime User
Thank you adastra, but I'm not looking for the version of b4a.
The FontAwesome.jar library has inside a version of awesome font. I'm looking for the version of the font included in the library.
Thank you,
v.
 

Anser

Well-Known Member
Licensed User
Longtime User
The FontAwesome.jar library has inside a version of awesome font. I'm looking for the version of the font included in the library.

So the Library developer (NJDude) has to include the new FontAwsome ver 4.4.0 in his library and then create the updated lib right ?

From where can I download the latest version of FontAwsome ver 4.4.0 that is compatible with Android phone (fontawesome-webfont-4.4.0.ttf) ?

Can I use any .ttf font, by just simply copying into the Fonts folder inside Files folder os our project ie \Project\Files\Fonts

Or are there fonts (.ttf files) specifically for Android ?
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
So the Library developer (NJDude) has to include the new FontAwsome ver 4.4.0 in his library and then create the updated lib right ?
Yes. The lib contains the font. The lib contains a map file too (i found this using reverse engeneering)
B4X:
#Sat May 16 21:39:00 EDT 2015
fa-eye-slash=61552
fa-dropbox=61803
fa-mars=61986
fa-file-word-o=61890
fa-close=61453
[...]

Both files need to be updated.
 

DonManfred

Expert
Licensed User
Longtime User
Then: font included is version 4.x ?
Compare icons in lib with the CheatSheet and you´ll know that - for example - fa-bed - is included (which is introduced in v4.3

So i guess it´s 4.3
The FontAwesome.jar library has inside a version of awesome font. I'm looking for the version of the font included in the library

Have you searched for it on the fontAwesome site?

https://github.com/FortAwesome/Font-Awesome/tree/master/fonts

Edit:
Google
google founding
 
Last edited:

Anser

Well-Known Member
Licensed User
Longtime User
Is it possible to use Bold Text in FontAwsome ?.

Am I doing something wrong in the way that I code ? OR am I expecting something impossible ?

I am getting the following results

BOLD
Image is not displayed
With_Bold.png



Without BOLD
Please note the height difference between the picture and the text "Save"
Without_Bold.png


I use the following Code
B4X:
FA.Initialize  
BtnSave.Typeface = FA.FontAwesomeTypeface  
BtnSave.Typeface = Typeface.DEFAULT_BOLD
BtnSave.Text = FA.GetFontAwesomeIconByName("fa-save") & "  Save"



Regards
Anser
 
Last edited:

Gary Milne

Active Member
Licensed User
Longtime User
Change the TextColor property of the FontAwesome's host control:

B4X:
Private FA As FontAwesome
FA.Initialize
Label1.Typeface = FA.FontAwesomeTypeface
Label1.Text = FA.GetFontAwesomeIconByNumber(61481)
Label1.TextColor = colors.red

Don't know if you are still looking for an answer to this. I used a combo of FontAwesome and text on labels for a while but had alignment issues and the monochromatic look was always a bit lacking so I created something called SmartHost that gives me much more control and flexibility. Here is a button similar to yours that uses the built in Floppy Icon but you could use the one from FontAwesome instead if you wished.
SaveButton.jpg


I attached the code if you want to try it out but you will have to get the Library.
 

Attachments

  • Test.zip
    82.4 KB · Views: 291

Mashiane

Expert
Licensed User
Longtime User
This library will allow you to use FontAwesome on any view that supports Typeface (except Spinner).

Requirements:

1- B4A 4.x.

2- Copy the FontAwesome.xml and FontAwesome.jar to your additional libraries directory.

Usage:
B4X:
'Initialize the library.
Private FA As FontAwesome

FA.Initialize

'Add the FontAwesome typeface to your view.
Label1.Typeface = FA.FontAwesomeTypeface

'Select the icon you want to display.
Label1.Text = FA.GetFontAwesomeIconByName("fa-android") & "  Some title label  " & FA.GetFontAwesomeIconByNumber(0xf15d)
That's it!!

Notes:

* If an icon isn't defined the library will show a "?" or a blank-square (get all the defined icons by name and their numbers from the Cheat Sheet)

Screenshot:

vt5GWftl.png
Do you happen to have an alternative for b4i please?
 
Top