Tutorial: Using Custom Fonts

18 Comments
  • Kevin
    Posted at 00:17h, 17 January

    Thanks for the article…

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

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

  • Andreas
    Posted at 02:12h, 17 January

    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

  • Igor
    Posted at 13:30h, 17 January

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

  • frank
    Posted at 16:56h, 18 January

    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

  • Stiven
    Posted at 20:10h, 19 January

    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
      Posted at 08:44h, 23 January

      I’ve had this same issue

    • Julius Bangert
      Posted at 06:16h, 28 April

      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.

  • Chris Leyton
    Posted at 06:26h, 21 January

    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.

  • Renato - RBG
    Posted at 00:20h, 02 April

    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
      Posted at 05:12h, 20 June

      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

  • Rob
    Posted at 10:32h, 23 August

    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.

  • Rithy
    Posted at 20:42h, 27 August

    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.

  • Sabir Ahmed
    Posted at 03:52h, 26 September

    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,

  • Dewey
    Posted at 14:34h, 13 May

    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

  • Federico Pici
    Posted at 01:58h, 12 June

    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
      Posted at 10:05h, 07 February

      This was super helpful, thanks!

  • Martin
    Posted at 12:36h, 16 July

    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… 🙁

  • Roland
    Posted at 01:10h, 17 October

    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