B4A Library List of Named Icons from Unicode and other Fonts

This is a supporting Class that allows easy (and much more readable) access to Icon characters within the Unicode, FontAwesome and Ligature fonts.

I wrote this for use with my upcoming SmartHost class but it has value as a standalone class.

The three fonts that are mapped are:

Unicode (Symbola): Version 2.300
For a list of Unicode symbols point your browser to http://www.unicode.org/charts/ and select a range in Symbols and Punctuation. Not all ranges extended ranges are represented in this Library. The font file is too large to attach to this thread but you can find it on my Google Drive here.

Font Awesome: Version 4.4
For a list of FontAwesome Symbols and to download the font point your browser to https://fortawesome.github.io/Font-Awesome/icons

Ligature: Version 2.11
For a list of Ligature symbols and to download the font point your browser to http://kudakurage.com/ligature_symbols

All of these fonts are available for free use and distribution but Font Awesome and Ligature request simple attribution of some sort.

How to use it.
B4X:
Dim Icons As Icons_

'Initializes the Icon map in the ranges (FontAwesome, Ligature, UnicodeBasic, UnicodeAll)
Icons.Initialize(True, False, False, True)
btnKey.Text = Icons.FA.Key

btnYes.Text = Icons.Unicode.MiscSymbols.Ballot_Box_With_Check
btnNo.Text = Icons.Unicode.MiscSymbols.Ballot_Box

btnAsterix.Text = MyString & " " & Icons.Unicode.Dingbats.Balloon_Spoked_Asterisk

Icons are broken down by code block for the Unicode range.
Unicode Basic
Arrows *
BoxDrawings *
BlockElements *
GeoShapes *
GeoShapesExt *

Unicode All adds these ranges.
Dingbats
MiscSymbols
PlayingCards
MiscSymbolsExt
Transport

You do not need to use the Unicode.TTF referenced here in order to use these ranges. This library simply provides a pointer to a character within the font table. If your chosen font contains that character it will be displayed. In working with Android I have found their implementation of the Unicode standard to be decent but there are gaps in the character range.

If you request a font to display a given character and that character is not available Android will check other available fonts for a match. If no match is found across all available fonts then a "missing" default character will be used, typically this looks like a rectangle stood on its shortest edge.

Emoji characters are not the same across android devices as there are some vendor specific improvements: http://apps.timwhitlock.info/emoji/tables/unicode

Lastly here is an awesome Emoji set that is much better than the default Android one and as good, if not better, than the IOS Emoji set. Go to www.emojione.com and scroll down. Again it is free to use with attribution. Although this character set is not yet mapped I'm sure I will add it in the future.
 

Attachments

  • Icons_.zip
    123 KB · Views: 298
Last edited:

Rusty

Well-Known Member
Licensed User
Longtime User
Hi Gary,
Are you familiar with character combining (ligature) for some languages such as Gujarati or Korean?
If so, can you advise how this is accomplished in B4a/Android?
Thanks
Rusty
 

Gary Milne

Active Member
Licensed User
Longtime User
I have no experience with that, essentially two characters occupying the same space to create a composite character is what I think you are referring to.

You should have a look at this though, it is an awesome reference. http://unicode.org/charts/

I have only ever dealt with the diacritical marks which have already been combined (n to ñ) but for those I merely reference the Unicode character that represents the combined character. Perhaps the ligature marks operate in the same way, meaning that they have a discrete number of predetermined combinations.

I would strongly recommend that you load your own font file as all the leading phone manufacturers have their own font set and you cannot be guaranteed that everyone will have the same experience if you rely on the built in font.
 

Kwame Twum

Active Member
Licensed User
Longtime User
Hello, I just get series of digits instead of an icons...
• When I used Unicode.Dingbats.Balloon_Spoked_Asterisk, I got 10057 in an Edittext
• And Unicode.Dingbats.Airplane gave 9992

Am I missing something?
 

Gary Milne

Active Member
Licensed User
Longtime User
Hello, I just get series of digits instead of an icons...
• When I used Unicode.Dingbats.Balloon_Spoked_Asterisk, I got 10057 in an Edittext
• And Unicode.Dingbats.Airplane gave 9992

Am I missing something?
Remember that this class exists to make it easier to select these Unicode characters and to make your code a little more readable. But in the end all it does is return the Int value of whatever symbol you choose. I see now that my example did not explain that and I will update it.

All you have to do is convert the returned Int value to a character with chr(MyValue)
B4X:
'This is just an illustration and not a complete project.
Dim BSA as Int
BSA = Unicode.Dingbats.Balloon_Spoked_Asterix
'BSA now equals 10057

'To display it we get the character with chr()
'We can now display it like this.
EditText.Text = chr(BSA) & " This is my text"

Make sense?
 
Top