Using FontAwesome in a Corona app

I’m trying to wrap my head around Corona SDK development for an iPad app and I was experimenting with reusing the existing icons from the Bootstrap-based web app. This is the FontAwesome TTF font set. There is a CSS file [1] that has all the unicode character escape sequences in it that I’m referencing.

My question is: how do I convert the escape sequence used in the CSS to a character I use as a button label or just a text block?

I’ve tried guessing at variations on the 0x1c or \01c or other schemes to get the character I want but I can’t get what I’m after. Has anyone used emoticons or other graphics embedded in a font file in a Corona app?

[1] - https://github.com/FortAwesome/Font-Awesome/blob/master/css/font-awesome.css

You would probably need to convert the hex codes to decimal and then use the string.char() function (http://docs.coronalabs.com/api/library/string/char.html) to produce the unicode string for a single glyph. 

Rob

For convenience, I created a Ruby script that translates the Font-Awesome CSS directives into a Lua table that can be used as a module. I found it was easier to convert from the unicode codepoints in the CSS to the decimal versions via Ruby’s string manipulation.

I put the utility up on GitHub with an initial file generated from v4.0.3:

https://github.com/jbrisbin/fontawesome-corona

Note that you’ll still have to download the TTF file and install it onto your machine. But this at least takes care of converting the CSS directives for you so it’s easier to keep it up to date.

Nice!

Rob

Thank you sooOOoo much for this tip :slight_smile:

You would probably need to convert the hex codes to decimal and then use the string.char() function (http://docs.coronalabs.com/api/library/string/char.html) to produce the unicode string for a single glyph. 

Rob

For convenience, I created a Ruby script that translates the Font-Awesome CSS directives into a Lua table that can be used as a module. I found it was easier to convert from the unicode codepoints in the CSS to the decimal versions via Ruby’s string manipulation.

I put the utility up on GitHub with an initial file generated from v4.0.3:

https://github.com/jbrisbin/fontawesome-corona

Note that you’ll still have to download the TTF file and install it onto your machine. But this at least takes care of converting the CSS directives for you so it’s easier to keep it up to date.

Nice!

Rob

Thank you sooOOoo much for this tip :slight_smile: