Tutorial: Using Custom Fonts

FAQ Icon
Share on Facebook0Share on Google+2Tweet about this on TwitterShare on LinkedIn0

NOTE: This tutorial is outdated and has been replaced by the Using Custom Fonts guide.


Share on Facebook0Share on Google+2Tweet about this on TwitterShare on LinkedIn0
tom

This entry has 18 replies

  1. Kevin says:

    Thanks for the article…

    I think this is a good article on custom fonts as well. Published last year by Mr. Beebe:

    http://www.coronalabs.com/blog/2011/07/13/custom-fonts-corona/

  2. Andreas says:

    Hi Tom,

    thanks again for a straight & helpful tutorial.

    We use custom fonts a lot, so I want to share two small tips:

    1. License

    Normally you have to buy an extra license to use a font in your apps, it’s not enough to have bought the license for web publishing or print (if you’re e.g. working on converting kids books into interactive storybooks). It’s not steep, we in average pay about $20-40 for the license per font.

    2. OTF -> TTF

    We use only TTF because we publish for iOS / Android / Kindle / NOOK – hey, that’s what the Coronalabs SDK was made for. ๐Ÿ™‚
    So we sometimes need to convert OTF -> TTF. A very fast, free (and hassle-free) online converter doing the task nicely is:
    http://www.freefontconverter.com

    Best,
    Andreas

  3. Igor says:

    I’ve discovered that its impossible to include more than ~100 fonts in single build. The app crashes (probably due to memory issues)

  4. frank says:

    Hi Andreas,

    re 1., once we bought the fonts, can we publish the TTF with our application free of charge to unlimited number of users ?

    Thanks
    Frank

  5. Stiven says:

    Hi!

    I Have a question.

    With custom font, on the device font is sometimes misplaced, and appears a couple of pixels higher or lower. Do you know what is the problem or how to fix that?

    the difference also appears to be different on different devices.

    • Greg says:

      I’ve had this same issue

    • Julius Bangert says:

      Stiven, did you ever figure this out? I’ve noticed this problem with the text being slightly higher on the device compared to the simulator. I’ve been aware of this the whole time I’ve been developing my game but kind of ignored it as something I could fix at the end. Really need to fix it now though.

  6. Chris Leyton says:

    How about an article on bitmap fonts – if you want to make your game look that little more polished this is really the only route to go. So far as I can teel the only way is to use a pretty outdated community module (bmf.lua) or the third-party Text Candy option. Some advice on this would be pretty helpful.

  7. Renato - RBG says:

    I was trying to use custom font in my Android device (Galaxy S-I) but even following the instructions above the custom font was not working.

    After several tentatives and tests, I found that the problem was that my font file was with its extension in capital letters (.TTF). I changed the font file extension to .ttf and it worked perfectly.

    • Ahmad says:

      i do every thing in my Android app and it’s works on simulator but in my device LG G2 not working why ? help me please

  8. Rob says:

    I was fighting an with a Font on my Droid Razr. Read Renato’s comment above and found that the same issue fixed my problem too.

    The font file extension ( TTF ) must be lower case; ttf

    As soon as I changed that, my font display perfectly on Device.

  9. Rithy says:

    Hi,

    I found this tutorial very useful; however, i’m facing a problem with font family to work in Win. I have 2 fonts, helveticaneue.ttf and HelveticaNeue-Bold.ttf, and i installed them in My Win 7, but i can get only Helvetica Neue font name to work.
    How can i get the Bold one to work? i used the above method to get font name from system font, but there’s no HelveticaNeue-Bold printed. Anyone has solved this?

    By the way, it seems to work fine on Mac and IOS.

    Thanks.

  10. Sabir Ahmed says:

    Hello all,
    I have question.
    Can I display some sentence or word in different format in single string? (like: italic , bold or change the word color)

    Thanks,

  11. Dewey says:

    Can the fonts be in a folder or do they need to be at the project root?
    If in a folder, what needs to change to the syntax of build_settings??

    Thx
    D

  12. Hi,
    after some test i was able to understand how to use correctly custom fonts under android.
    1) choose a .ttf font file and put it in the root folder (where main.lua is) of your app. File name extension (.ttf) MUST be lowercase
    2) No need to write something in build.setting (for android)
    3) Under emulator font file must be referenced by Font Name but under android font file must be referenced by file name. So in my case i put LUNAKRONIKLIGHT.ttf under root folder of my app, i installed it in my OS and referenced it (in emulator) with “Luna Kronik Light”. Under android device i referenced it with LUNAKRONIKLIGHT. It took me some time to understand. If you change the name of the file and set it equal to font name you won’t need to detect if you are under emulator or under real device. In my case i renamed “LUNAKRONIKLIGHT.ttf” in “Luna Kronik Light.ttf” and have it work under emulator AND under android device with same name convention.
    Hope it helps
    Federico Pici

    • Crossman says:

      This was super helpful, thanks!

  13. Martin says:

    Not working. The font is listed via native.getFontNames() but newText does not display.

    swap font to “Arial” (or any of the other preloaded fonts) and everything works… ๐Ÿ™

  14. Roland says:

    I can confirm, fonts not working on my Android devices.
    – Fonts are .tff (lowercase) in main.lua directory
    – added to UIAppFonts in build.settings

    I don’t even see the custom font names in native.getFontNames(). I’m using corona ver 2014.2456

Leave a reply

You may use these HTML tags and attributes: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">