Custom font doesn't display

I’ve loaded a custom font by installing it on my Windows, pointing to it in the app build settings (“BIOST.TTF”), putting it in the app directory too, checking what the font name is by iterating through the available list (it’s “Bio-disc Thin”), and assigning it as font during display.newText.

Yet, no text or font at all shows in the Windows simulator (only when I go back to the system default font will it appear again). Typically when I run on the device it works again.

Help? Thanks!

Can you post your build.settings file?

Regardless on Android (and in theory Windows) you don’t need to list the font in build.settings.  The .ttf file has to be in the same directory as your main.lua.   The file name is case sensitive on device, but not in the simulator.   Typically the font internal name needs to match the file name too.  

Try renaming the font to:   Bio-disc Thin.ttf

and in your display.newText:   display.newText(“Hello World”, 0, 0, “Bio-disc Thin”, 32)

and see if that does any thing for you.

My build.settings are somewhat like this:

settings =  {     iphone = {         plist = {             UIAppFonts = {                 "Bio-disc Thin.ttf" (one of many names I tried)             },         },     }, }  

I’ve tried renaming the ttf file to your suggested version. I’ve tried various file name. I’ve tried installing the font on Windows, uninstalling it again etc. To no avail so far. The best that happens is that it may show on the device, but not the simulator. Even though the font is found on the simulator – as shown by the font list – I cannot get it to display on the simulator screen…

Hi @Philipp,

Did you read over this FAQ thoroughly? Especially the notes about Windows:

http://www.coronalabs.com/blog/2013/01/16/faq-wednesday-custom-fonts/

There might just be one tiny little issue with the naming of it. At least, let’s hope that’s the solution. :slight_smile:

Brent

Brent, thanks, the problem is that I *do* check the font via native.getFontNames() – in fact, specifying the “correct” font name causes the text to not be displayed at all if it is installed on the machine. If the font is not installed on the machine, or if I’m specifying a false font name (i.e. something not in native.getFontNames), then Corona displays its default font (Arial, I presume).

So: If I do everything wrong, I get Arial.

If I do it right by checking the exact font name, I get nothing at all on the Simulator.

(The device acts differently, but it’s burdensome to test…)

Hi @Philipp,

Does the same thing happen with another font? Sometimes there are just weird quirks with a particular font. But, if the same thing happens with other fonts, then it’s perplexing.

Brent

On your computer (Mac or Windows), the font has to be installed like any other font.  The location of the .ttf in the folder I think doesn’t matter.  For Android, you do not need to put anything in build.settings (and I’m assuming you’re testing on Android since you are on Windows), the font just has to be in the folder.

Put this code into a generic screen and run the debugger and then execute this code on a page

local sysFonts = native.getFontNames()

for k,v in pairs(sysFonts) do print(v) end

When you run the debugger, you should get something like this in the print window

2013-04-24 21:03:50.363 Corona Simulator[4365:707] ACaslonPro-Bold

2013-04-24 21:03:50.363 Corona Simulator[4365:707] ACaslonPro-BoldItalic

2013-04-24 21:03:50.364 Corona Simulator[4365:707] ACaslonPro-Italic

2013-04-24 21:03:50.364 Corona Simulator[4365:707] ACaslonPro-Regular

2013-04-24 21:03:50.364 Corona Simulator[4365:707] ACaslonPro-Semibold

2013-04-24 21:03:50.364 Corona Simulator[4365:707] ACaslonPro-SemiboldItalic

2013-04-24 21:03:50.365 Corona Simulator[4365:707] AGaramondPro-Bold

2013-04-24 21:03:50.365 Corona Simulator[4365:707] AGaramondPro-BoldItalic

2013-04-24 21:03:50.365 Corona Simulator[4365:707] AGaramondPro-Italic

2013-04-24 21:03:50.366 Corona Simulator[4365:707] AGaramondPro-Regular

This would then be the name that should work for you.    

Sample code would be this

 local highScoringText1 = display.newText(“David”, 80,100, “ACaslonPro-Bold”, 32)

highScoringText1:setReferencePoint(display.leftReferencePoint)

highScoringText1:setTextColor(0,0,0)

Try this and see if it works for you.    

If this doesn’t work, does native.systemFontBold work to display text?

Post your code and happy to see if it works for me.

(I am on a Mac, so I believe this should work on Windows)

Can you post your build.settings file?

Regardless on Android (and in theory Windows) you don’t need to list the font in build.settings.  The .ttf file has to be in the same directory as your main.lua.   The file name is case sensitive on device, but not in the simulator.   Typically the font internal name needs to match the file name too.  

Try renaming the font to:   Bio-disc Thin.ttf

and in your display.newText:   display.newText(“Hello World”, 0, 0, “Bio-disc Thin”, 32)

and see if that does any thing for you.

My build.settings are somewhat like this:

settings =  {     iphone = {         plist = {             UIAppFonts = {                 "Bio-disc Thin.ttf" (one of many names I tried)             },         },     }, }  

I’ve tried renaming the ttf file to your suggested version. I’ve tried various file name. I’ve tried installing the font on Windows, uninstalling it again etc. To no avail so far. The best that happens is that it may show on the device, but not the simulator. Even though the font is found on the simulator – as shown by the font list – I cannot get it to display on the simulator screen…

Hi @Philipp,

Did you read over this FAQ thoroughly? Especially the notes about Windows:

http://www.coronalabs.com/blog/2013/01/16/faq-wednesday-custom-fonts/

There might just be one tiny little issue with the naming of it. At least, let’s hope that’s the solution. :slight_smile:

Brent

Brent, thanks, the problem is that I *do* check the font via native.getFontNames() – in fact, specifying the “correct” font name causes the text to not be displayed at all if it is installed on the machine. If the font is not installed on the machine, or if I’m specifying a false font name (i.e. something not in native.getFontNames), then Corona displays its default font (Arial, I presume).

So: If I do everything wrong, I get Arial.

If I do it right by checking the exact font name, I get nothing at all on the Simulator.

(The device acts differently, but it’s burdensome to test…)

Hi @Philipp,

Does the same thing happen with another font? Sometimes there are just weird quirks with a particular font. But, if the same thing happens with other fonts, then it’s perplexing.

Brent

On your computer (Mac or Windows), the font has to be installed like any other font.  The location of the .ttf in the folder I think doesn’t matter.  For Android, you do not need to put anything in build.settings (and I’m assuming you’re testing on Android since you are on Windows), the font just has to be in the folder.

Put this code into a generic screen and run the debugger and then execute this code on a page

local sysFonts = native.getFontNames()

for k,v in pairs(sysFonts) do print(v) end

When you run the debugger, you should get something like this in the print window

2013-04-24 21:03:50.363 Corona Simulator[4365:707] ACaslonPro-Bold

2013-04-24 21:03:50.363 Corona Simulator[4365:707] ACaslonPro-BoldItalic

2013-04-24 21:03:50.364 Corona Simulator[4365:707] ACaslonPro-Italic

2013-04-24 21:03:50.364 Corona Simulator[4365:707] ACaslonPro-Regular

2013-04-24 21:03:50.364 Corona Simulator[4365:707] ACaslonPro-Semibold

2013-04-24 21:03:50.364 Corona Simulator[4365:707] ACaslonPro-SemiboldItalic

2013-04-24 21:03:50.365 Corona Simulator[4365:707] AGaramondPro-Bold

2013-04-24 21:03:50.365 Corona Simulator[4365:707] AGaramondPro-BoldItalic

2013-04-24 21:03:50.365 Corona Simulator[4365:707] AGaramondPro-Italic

2013-04-24 21:03:50.366 Corona Simulator[4365:707] AGaramondPro-Regular

This would then be the name that should work for you.    

Sample code would be this

 local highScoringText1 = display.newText(“David”, 80,100, “ACaslonPro-Bold”, 32)

highScoringText1:setReferencePoint(display.leftReferencePoint)

highScoringText1:setTextColor(0,0,0)

Try this and see if it works for you.    

If this doesn’t work, does native.systemFontBold work to display text?

Post your code and happy to see if it works for me.

(I am on a Mac, so I believe this should work on Windows)

The font you installed is a variation of the regular font Bio Disc.
In windows, it likely to be installed inside a folder named Bio Disc.
Coronasdk won’t detect it as error, because there is a bio disc font, but it shows nothing/blank because you are missing the regular font, you only have the thin version.

There is no way to show the thin font correctly in windows simulator. The only solution is to change th font name inside the ttf(not the file name) with an ttf editor.

The font you installed is a variation of the regular font Bio Disc.
In windows, it likely to be installed inside a folder named Bio Disc.
Coronasdk won’t detect it as error, because there is a bio disc font, but it shows nothing/blank because you are missing the regular font, you only have the thin version.

There is no way to show the thin font correctly in windows simulator. The only solution is to change th font name inside the ttf(not the file name) with an ttf editor.