Custom fonts on Windows

Not having much luck with custom fonts on Windows and I’m hoping someone can help me out. This is a bit of a new foray for me. I have read the Font tutorial and Blog FAQ:

I got my custom fonts from the Basic section of dafonts.com:

The fonts I’m attempting to use are all free TTF (TrueType) fonts:

Let’s take these three as a good sample:

Now, I’m using Windows 7 so I have installed the fonts and confirmed their installation by accessing them in Microsoft Word, so I know they are available for use. I have tried them in the Windows font viewer and they all seem to be fine and uncorrupted.

The code I’m using to render them is:

display.newText( "Dolphin Sans", 100, 100, "Dolphin Sans", 50 ) display.newText( "Origin Light", 100, 200, "Origin Light", 50 ) display.newText( "Roboto Th", 100, 300, "Roboto Th", 50 ) 

Though I know it’s not necessary on Windows/Android, I have setup my build.settings file like so:

settings =  {     iphone =     {         components={},         plist =         {             UIApplicationExitsOnSuspend = true,             UIAppFonts = {                 "Dolphin-Sans.ttf",                 "Origin-Light.ttf",                 "Roboto-Thin.ttf",             },         }     }, }

The output I get in the Windows simulator console is:

Warning: could not load font Dolphin Sans. Using default font. Warning: could not load font Origin Light. Using default font. Warning: could not load font Roboto Th. Using default font.

Would anyone be able to tell me why this is happening and how to fix it, please?

I have attached my zipped working directory with the code and font files included.

I think the biggest challenge with custom fonts is knowing the exact font name.  Sometimes it’s different than what you expect.

I’d recommend a freeware font editor called Type Light.  I’ve used it for all of the custom fonts in my apps in order to edit the font name.  I edit the font name so that it’s one word, all lowercase, and exactly matches the filename.

Separate question: I assume that, in addition to installing the fonts on your machine, you always have the font file in your project’s folder, right?

  • Andrew

Thanks for that advice. I’ll give it a try now.

Yes, I have the files exactly as you can see in the zip file. I never use directories in my apps, as it happens, and I’m as clear and explicit as I can be with filenames (as a habit.)

Cool, I’ll be interested to see what you find.  (Sorry, didn’t look at the attachment to see that you had included the files!)

For what it’s worth, Type Light says the full name of Dolphin Sans is “Dolphin Sans Regular”, so that may be the problem.  (You can find and edit this in Type Light under Font | Names).

  • Andrew

I took a look at the full name and edited it to “DolphinSansRegular” - does not seem to have made a difference.

Could I ask you to run it locally and let me know what you see in the WinSim, please?

Interesting.  I downloaded your project, installed the fonts, and ran it as is without any changes, and it worked in the Windows Simulator.  I’m running Windows Vista.  (Yes, my computer is a bit old…)

  • Andrew

Right, ok, erm, a few questions as I try to nail this down…

Are you on the latest daily (1192)?

Did you install the fonts before running my code for the first time?

What method did you use to install them (I just right click and select “Install”)?

Cheers,

Matt.

I’m using Daily Build 1190.  Yes, I installed the fonts before running the code for the first time, and yes, I installed just by right-clicking and selecting Install.

  • Andrew

Dang.

Reinstalled the latest build and it worked.

Thanks for your help.

Matt

Cool, no problem, glad you got it working.

  • Andrew

Turns out that the sim needs to be restarted when new fonts get installed.

Ah yes, that’s true!  I remember running into that a long time ago and completely forgot about it.

  • Andrew

I think the biggest challenge with custom fonts is knowing the exact font name.  Sometimes it’s different than what you expect.

I’d recommend a freeware font editor called Type Light.  I’ve used it for all of the custom fonts in my apps in order to edit the font name.  I edit the font name so that it’s one word, all lowercase, and exactly matches the filename.

Separate question: I assume that, in addition to installing the fonts on your machine, you always have the font file in your project’s folder, right?

  • Andrew

Thanks for that advice. I’ll give it a try now.

Yes, I have the files exactly as you can see in the zip file. I never use directories in my apps, as it happens, and I’m as clear and explicit as I can be with filenames (as a habit.)

Cool, I’ll be interested to see what you find.  (Sorry, didn’t look at the attachment to see that you had included the files!)

For what it’s worth, Type Light says the full name of Dolphin Sans is “Dolphin Sans Regular”, so that may be the problem.  (You can find and edit this in Type Light under Font | Names).

  • Andrew

I took a look at the full name and edited it to “DolphinSansRegular” - does not seem to have made a difference.

Could I ask you to run it locally and let me know what you see in the WinSim, please?

Interesting.  I downloaded your project, installed the fonts, and ran it as is without any changes, and it worked in the Windows Simulator.  I’m running Windows Vista.  (Yes, my computer is a bit old…)

  • Andrew

Right, ok, erm, a few questions as I try to nail this down…

Are you on the latest daily (1192)?

Did you install the fonts before running my code for the first time?

What method did you use to install them (I just right click and select “Install”)?

Cheers,

Matt.

I’m using Daily Build 1190.  Yes, I installed the fonts before running the code for the first time, and yes, I installed just by right-clicking and selecting Install.

  • Andrew

Dang.

Reinstalled the latest build and it worked.

Thanks for your help.

Matt