custom fonts don't load properly

Hi Corona team,

I’m using custom ttf fonts in my game, but they don’t load. I was trying these calls:

local font = "Edson\_Comics\_Bold"; --font file name without extension local font = "Edson\_Comics\_Bold.ttf"; --full font filename local font = "Edson\_Comics Bold"; --the name appearing in windows control panel local font = "Edson\_Comics\_Bold Bold"; --the name appearing in headline after opening the font details i windows control panel

but none of them worked for me. Could write the proper way to define a custom font, plase?

Thanks,

Olaf

Olaf,

We haven’t added custom font support yet.  Right now, the display.newText() function will always use the default system font.  However, all other features of display.newText() such as alignment, bold, point size, multiline support, and choosing a system font by family name is supported.  But that said, I’ll update our CoronaCards documentation to make it clear that we don’t support custom fonts yet.

This shouldn’t be a show-stopper for you, right?

We still have a lot of features to implement on WP8 right now.  So, we’re being very selective about what features to work on next, because everything takes time to implement.

Hi Joshua,

Thanks for your answer. The thing is that the version I should deliver until tomorrow, is the [Release Candidate]. It’s not alpha, it’s not beta, it should to be the exact game version that I was going to submit as the Release Version so that the Q&A Team could give their review.

So answering your question yes - it does hold me from showing it to Microsoft Q&A Team, because with deafult native font it’s horribly cutting out from the game artwork and it’s laggy (updating the text value is causing a very noticeable lag now, even if it’s a system default font).

I’d have to use graphic assets with separated digits instead if it’s not possible to implement custom fonts for now.

Olaf,

I’ve been looking into custom font support.  I can definitely add support for it this week if you don’t mind me requiring you to set the font name a bit differently on this platform (out of interest of speed of course).  Something like the following…

local fontName = "MyFontName.ttf#My Font Family Name"

The #<FontFamilyName> part is a Microsoft XAML convention that I can use to make it faster/easier to implement this on our end.  You can find out the font family name of your *.ttf or *.otf file by double clicking on it in Windows.  (Note: I’d prefer that Corona developers not have to enter the font family name too, but in order for us to do that, we would have to extract it out of *.ttf and *.otf files ourselves, which means more development time on our end.  Microsoft doesn’t provide any APIs to extract this info on WP8 unfortunately.)

So, would you be interested in this?

Or is the display.newText() performance issue make this worthless at the moment?

(The display.newText() function still has its uses.  Just don’t call it on every enterFrame or collision.)

Joshua, I have to update my score text value on every collision so I’ll implement a bitmap font anyway for better performance. I think it’s better if we focus on other missing things now, but I appreciate that you asked.

I noticed that after all you decided to implement the custom fonts. So I decided to use it for my multiline items’ descriptions in a store view - works well. Thanks!

Great!  Happy to help.  Yeah, I was already over halfway finished implementing it when I asked you and thought I might as well finish it.  I’m sure our other closed beta Corona developers would have wanted this feature as well.

One thing to note though.  I’ve discovered that one postscript *.ttf font file that I’ve tested with didn’t load on WP8.  It appears that WP8 might refuse to load some fonts due to licensing issues (this is speculation, but might be true).  A quick search on the Internet showed that font files that used to load in WP7 now refuse to load on WP8 (see the link below).  If you run into this, then your only choice might be to use a different font.  Unfortunately, the OS does not give me any indication if it fails to load the font (at least I haven’t found a means yet) and it just falls back to a default font without telling me.  Just a heads up.

   http://stackoverflow.com/questions/20975351/why-dont-certain-font-files-work-on-windows-phone-8

Also, in case you’re interested, Microsoft document’s the system fonts supported on WP8 here…

   http://msdn.microsoft.com/en-us/library/windowsphone/develop/cc189010%28v=vs.105%29.aspx#silverlight_fonts

Thanks for the info. I’m using 2 custom fonts and I also had a problem to load the second one, but after some experiments with the family name after # sign - it works. I marked which name after # worked for me with each font. Maybe the font that you can’t load would load with the other name? Notice in the upper font name there are differences with spaces and underlines, so it’s not in the same place as the names that worked for the second font.

fvz9xe.jpg

Oh interesting.  I was using the font name displayed under the Print and Install buttons.  I didn’t think of trying the other names.  Just another reason to parse it out of the font file myself.  It’s a future TODO item I’ve written for myself.

Joshua, 

There’s another issue with the new CoronaCards build (2369). I can display custom fonts once but when I update the handler’s text value with a new string - the object disappears and the text is not visible anymore. I checked and downgraded to 2357 - the problem didn’t occur so something happened in the new version.

UPDATE: when I tried to update text with a 10ms timer - I usually get the text value updated, not always though. 

Hmm… I think it’s because Microsoft’s text render is failing to get a hold of the rendering thread because Corona dominates it while in 60 FPS mode.  I bet you it would be 100% reliable at 30 FPS.  *sigh*

I’ll dig into this after we finish the Native/Lua bridge feature.  I have a pretty good idea on how to solve this issue, but unfortunately it would involve increasing the time to create/update text… at least for 60 FPS apps.  It involves aborting our usage of the rendering thread temporarily and relinquishing control of it to Microsoft’s XAML framework to do text rendering, which is GPU bound too.

You’re right! I’ve just made a 30fps build and it worked fine. And yes, let’s keep the bridge as the priority for now. 

Just letting know about this issue for future.

Olaf,

We haven’t added custom font support yet.  Right now, the display.newText() function will always use the default system font.  However, all other features of display.newText() such as alignment, bold, point size, multiline support, and choosing a system font by family name is supported.  But that said, I’ll update our CoronaCards documentation to make it clear that we don’t support custom fonts yet.

This shouldn’t be a show-stopper for you, right?

We still have a lot of features to implement on WP8 right now.  So, we’re being very selective about what features to work on next, because everything takes time to implement.

Hi Joshua,

Thanks for your answer. The thing is that the version I should deliver until tomorrow, is the [Release Candidate]. It’s not alpha, it’s not beta, it should to be the exact game version that I was going to submit as the Release Version so that the Q&A Team could give their review.

So answering your question yes - it does hold me from showing it to Microsoft Q&A Team, because with deafult native font it’s horribly cutting out from the game artwork and it’s laggy (updating the text value is causing a very noticeable lag now, even if it’s a system default font).

I’d have to use graphic assets with separated digits instead if it’s not possible to implement custom fonts for now.

Olaf,

I’ve been looking into custom font support.  I can definitely add support for it this week if you don’t mind me requiring you to set the font name a bit differently on this platform (out of interest of speed of course).  Something like the following…

local fontName = "MyFontName.ttf#My Font Family Name"

The #<FontFamilyName> part is a Microsoft XAML convention that I can use to make it faster/easier to implement this on our end.  You can find out the font family name of your *.ttf or *.otf file by double clicking on it in Windows.  (Note: I’d prefer that Corona developers not have to enter the font family name too, but in order for us to do that, we would have to extract it out of *.ttf and *.otf files ourselves, which means more development time on our end.  Microsoft doesn’t provide any APIs to extract this info on WP8 unfortunately.)

So, would you be interested in this?

Or is the display.newText() performance issue make this worthless at the moment?

(The display.newText() function still has its uses.  Just don’t call it on every enterFrame or collision.)

Joshua, I have to update my score text value on every collision so I’ll implement a bitmap font anyway for better performance. I think it’s better if we focus on other missing things now, but I appreciate that you asked.

The text updating issue for 60 FPS apps has been resolved in build #2398, which should be made available later today.  Probably doesn’t apply to you anymore since you’ve switched to bitmap fonts, but I just wanted to post that it’s solved in case it has affected anyone else.

Nope it doesn’t but thanks for letting me know. I might use custom fonts in my future projects.

BTW: I’m still waiting for the second QA review. This time it takes a little bit longer.

I noticed that after all you decided to implement the custom fonts. So I decided to use it for my multiline items’ descriptions in a store view - works well. Thanks!

Great!  Happy to help.  Yeah, I was already over halfway finished implementing it when I asked you and thought I might as well finish it.  I’m sure our other closed beta Corona developers would have wanted this feature as well.

One thing to note though.  I’ve discovered that one postscript *.ttf font file that I’ve tested with didn’t load on WP8.  It appears that WP8 might refuse to load some fonts due to licensing issues (this is speculation, but might be true).  A quick search on the Internet showed that font files that used to load in WP7 now refuse to load on WP8 (see the link below).  If you run into this, then your only choice might be to use a different font.  Unfortunately, the OS does not give me any indication if it fails to load the font (at least I haven’t found a means yet) and it just falls back to a default font without telling me.  Just a heads up.

   http://stackoverflow.com/questions/20975351/why-dont-certain-font-files-work-on-windows-phone-8

Also, in case you’re interested, Microsoft document’s the system fonts supported on WP8 here…

   http://msdn.microsoft.com/en-us/library/windowsphone/develop/cc189010%28v=vs.105%29.aspx#silverlight_fonts