Can't load the font

Hello guys

I m trying to load a font I coded the Build.setting file in this way

settings = { orientation = { default = "landscapeRight", supported = { "landscapeRight", } }, iphone = { plist = { UIStatusBarHidden = false, UIPrerenderedIcon = true, -- set to false for "shine" overlay --UIApplicationExitsOnSuspend = true, -- uncomment to quit app on suspend --[[-- iOS app URL schemes: CFBundleURLTypes = { { CFBundleURLSchemes = { "fbXXXXXXXXXXXXXX", -- example scheme for facebook "coronasdkapp", -- example second scheme } } } --]] } }, --[[-- Android permissions androidPermissions = { "android.permission.INTERNET", },]]-- iphone = { plist = { UIAppFonts = { "CooperBlackStd-Italic.otf" }, }, } }

Then I Coded the main.lua in this way

local sfondo = display.newImage("sfondo.png") sfondo:setReferencePoint(display.BottomLeftReferencePoint) sfondo.x =-4 sfondo.y =273 local hai =display.newText("HAI" , 0 , 0 , "CooperBlackStd-Italic", 24) hai.x = 100 hai.y = 100

With the task to write "hai " using the font loaded; but whent i run it the simulator show me this message:

WARNING: THE FONT CooperBlackStd-Italic CAN’T BE LOADED USING DEFAULT FONT

Can someone suggest me how to solve it…

PS The name of the font is right for sure.

Thanks

I’ve had trouble in the past with otf fonts - use only ttf now.   

Did you try to install the font on your system?   e.g., on a Mac, double-clicking on the font will load it in Font Book - click on Install Font and see if you get errors.

If you do, probably have to find another font.

Also, some fonts worked in the Simulator, but not iOS and/or Android.   Test all platforms before releasing.

Hi @BETLAB11,

This tutorial should help clear up the font issue you’re having:

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

Best regards,

Brent

This not helped me due the fact that i used this tutorial to code .

You have two iPhone->plist tables in there.  You should only have one.

But you said it’s not working in the simulator.  This tells me that you do not have the font installed so your Mac can see it?  The plist entry only affects iOS devices.

Rob

Oooo I get… In fact I have windows XD… And how should I do to implement the font and use it on android??

On Windows you still have to have the font installed.  You probably should also use a True Type font instead of an Open Type Font.  I’m not sure how wide supported .otf fonts are on those platforms, but .ttf files work like a charm.

For Android you just need the file in the same folder as your main.lua.   This is all covered in the Font guide Brent posted above.

Rob

I’ve had trouble in the past with otf fonts - use only ttf now.   

Did you try to install the font on your system?   e.g., on a Mac, double-clicking on the font will load it in Font Book - click on Install Font and see if you get errors.

If you do, probably have to find another font.

Also, some fonts worked in the Simulator, but not iOS and/or Android.   Test all platforms before releasing.

Hi @BETLAB11,

This tutorial should help clear up the font issue you’re having:

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

Best regards,

Brent

This not helped me due the fact that i used this tutorial to code .

You have two iPhone->plist tables in there.  You should only have one.

But you said it’s not working in the simulator.  This tells me that you do not have the font installed so your Mac can see it?  The plist entry only affects iOS devices.

Rob

Oooo I get… In fact I have windows XD… And how should I do to implement the font and use it on android??

On Windows you still have to have the font installed.  You probably should also use a True Type font instead of an Open Type Font.  I’m not sure how wide supported .otf fonts are on those platforms, but .ttf files work like a charm.

For Android you just need the file in the same folder as your main.lua.   This is all covered in the Font guide Brent posted above.

Rob

I ve installed the font and I ve put it on my project folder… but It doesn’t load (it is a .ttf file… )

I really don’t know how to do…

I’m having a similar problem on iOS. The fonts show up in the Simulator but not on a real device. I’ve followed the article mentioned above to no avail.

The font files are present in the .app package, so the build.settings is obviously correct. If I list the fonts on the device using native.getFontNames() i see the fonts on the Simulator but NOT on a real device.

  • build.settings:

    iphone = { plist = { UIAppFonts = { “StelaUT.otf”, “CasperItalic.ttf”, “Merit.ttf”, } } }

  • Output from native.getFontNames…  (other fonts not included)

CasperItalic

Merit
StelaUT

  • File names in the .app package:

 

CasperItalic.ttf

Merit.ttf

StelaUT.otf

  • SDK Build: 2014.2189
     
  • iOS version 7.1

Hi @donfuego,

I assume you’ve contained all of the code you pasted inside the “settings” table? And your font files are not contained in a subfolder?

Brent

I ve installed the font and I ve put it on my project folder… but It doesn’t load (it is a .ttf file… )

I really don’t know how to do…

I’m having a similar problem on iOS. The fonts show up in the Simulator but not on a real device. I’ve followed the article mentioned above to no avail.

The font files are present in the .app package, so the build.settings is obviously correct. If I list the fonts on the device using native.getFontNames() i see the fonts on the Simulator but NOT on a real device.

  • build.settings:

    iphone = { plist = { UIAppFonts = { “StelaUT.otf”, “CasperItalic.ttf”, “Merit.ttf”, } } }

  • Output from native.getFontNames…  (other fonts not included)

CasperItalic

Merit
StelaUT

  • File names in the .app package:

 

CasperItalic.ttf

Merit.ttf

StelaUT.otf

  • SDK Build: 2014.2189
     
  • iOS version 7.1

Hi @donfuego,

I assume you’ve contained all of the code you pasted inside the “settings” table? And your font files are not contained in a subfolder?

Brent