Font Usage Problem

Dear Corona Community,

I have a severe font problem. I have been trying to get a specific bold type font working and I just cannot get it working. I altered the Font Name properly and call it in the proper code but it simply does not display at all. It does not say that the font does not exist but rather it simply does not display on the screen. The text appears fine with other custom installed fonts. I have installed many custom fonts before but never a bold weight font. If someone here is a font expert I will gladly email them to font to look at for expert consultation.

Best Regards,
Zeke [import]uid: 58749 topic_id: 31748 reply_id: 331748[/import]

Hello All,

The issue has gotten far greater, now that we have tested it on a device, non of the fonts are displaying. We call the correct font names but the font files in the build.settings file are not the same. Frankly, this should probably not matter too much but it might. I can really use some guidance on custom fonts, we have to use 7 of them… [import]uid: 58749 topic_id: 31748 reply_id: 126947[/import]

In the build.settings file, it should be the filename that you reference, like Verdana-Bold.ttf.

In the app itself, you have to use the font name, not the filename, See this for information on getting the correct font names:
http://developer.coronalabs.com/reference/index/nativegetfontnames

And finally, make sure you include your font files in the root folder of the application project so that they load correctly.

Hope that helps. [import]uid: 17827 topic_id: 31748 reply_id: 126971[/import]

Hello All,

The issue has gotten far greater, now that we have tested it on a device, non of the fonts are displaying. We call the correct font names but the font files in the build.settings file are not the same. Frankly, this should probably not matter too much but it might. I can really use some guidance on custom fonts, we have to use 7 of them… [import]uid: 58749 topic_id: 31748 reply_id: 126947[/import]

In the build.settings file, it should be the filename that you reference, like Verdana-Bold.ttf.

In the app itself, you have to use the font name, not the filename, See this for information on getting the correct font names:
http://developer.coronalabs.com/reference/index/nativegetfontnames

And finally, make sure you include your font files in the root folder of the application project so that they load correctly.

Hope that helps. [import]uid: 17827 topic_id: 31748 reply_id: 126971[/import]

I hate to re-hash a topic that has been done to death, but nothing I do gets my custom font working. The font file is in the same directory as the main.lua, my build.settings reads like this:

settings = {  
  
 orientation = {  
 default = "landscapeRight",  
 supported = { "landscapeRight", "landscapeLeft", }  
 },  
  
 iphone = {  
 plist = {  
 UIPrerenderedIcon = true, -- set to false for "shine" overlay  
 UIApplicationExitsOnSuspend = false,  
 UIStatusBarHidden = true,  
 UIAppfonts =   
 {  
 "SFSlapstickComic.ttf",  
 },  
 }  
 },  
  
-- For Android:  
 android = {  
 versionCode = "1.3.1",  
 versionName = "1.3.1",  
 },  
  
 androidPermissions = {  
 "android.permission.INTERNET",  
 "android.permission.READ\_EXTERNAL\_STORAGE",  
 "android.permission.WRITE\_EXTERNAL\_STORAGE",  
 "android.permission.READ\_PHONE\_STATE",  
 },  
}  

and i call the font with:

 local fontName = "SFSlapstickComic" -- matches terminal output when I print native.getFontNames()  
 local fontSize = 32  
  
 -- if on Android or non-iOS device  
 if (platformName == "Android" and not onSimulator) or (platformName ~= "iPhone OS" and not onSimulator) then  
 fontName = "SFSlapstickComic.ttf"  
 fontSize = 32  
 end  
  
 -- if on older device (and not on simulator) ...  
 if not onSimulator and olderVersion then  
 if string.sub( platformVersion, 1, 3 ) ~= "3.2" then  
 fontName = "Helvetica"  
 fontSize = 30  
 end  
 end  

and text items:

 local lifeString = (moduleVariables.gameLives - init) .. " x"  
  
 lifeText = display.newText( lifeString, 0, 0, fontName, (fontSize \* 0.9375 ))  
 lifeText:setTextColor( textColor, textColor, textColor, 255 )  
 lifeText.xScale = 0.5; lifeText.yScale = 0.5 --\> for clear retina display text  
 lifeText.x = 25  
 lifeText.y = 17  
  
 hudGroup:insert( lifeText )  

But still only system fonts will display when specified. The thing is though, I don’t get an error or a fall back to a system font, I just get blank spaces where the text should display.

The font is also installed in Font Book and I’ve tried multiple custom fonts, including ‘Harrowprint’ in the Corona custom font example, but all to no avail.

Aside from giving up and using something as visually stimulating as Helvetica, can anybody point me in any new directions? Just FYI, I’m using build 2012.935 and at this point I’m just focusing on iOS, I haven’t done any testing in the Android environment.

I should mention that fonts work no problems in Coronas simulator. But xCode simulator and iOS devices don’t. [import]uid: 157954 topic_id: 31748 reply_id: 128723[/import]

I hate to re-hash a topic that has been done to death, but nothing I do gets my custom font working. The font file is in the same directory as the main.lua, my build.settings reads like this:

settings = {  
  
 orientation = {  
 default = "landscapeRight",  
 supported = { "landscapeRight", "landscapeLeft", }  
 },  
  
 iphone = {  
 plist = {  
 UIPrerenderedIcon = true, -- set to false for "shine" overlay  
 UIApplicationExitsOnSuspend = false,  
 UIStatusBarHidden = true,  
 UIAppfonts =   
 {  
 "SFSlapstickComic.ttf",  
 },  
 }  
 },  
  
-- For Android:  
 android = {  
 versionCode = "1.3.1",  
 versionName = "1.3.1",  
 },  
  
 androidPermissions = {  
 "android.permission.INTERNET",  
 "android.permission.READ\_EXTERNAL\_STORAGE",  
 "android.permission.WRITE\_EXTERNAL\_STORAGE",  
 "android.permission.READ\_PHONE\_STATE",  
 },  
}  

and i call the font with:

 local fontName = "SFSlapstickComic" -- matches terminal output when I print native.getFontNames()  
 local fontSize = 32  
  
 -- if on Android or non-iOS device  
 if (platformName == "Android" and not onSimulator) or (platformName ~= "iPhone OS" and not onSimulator) then  
 fontName = "SFSlapstickComic.ttf"  
 fontSize = 32  
 end  
  
 -- if on older device (and not on simulator) ...  
 if not onSimulator and olderVersion then  
 if string.sub( platformVersion, 1, 3 ) ~= "3.2" then  
 fontName = "Helvetica"  
 fontSize = 30  
 end  
 end  

and text items:

 local lifeString = (moduleVariables.gameLives - init) .. " x"  
  
 lifeText = display.newText( lifeString, 0, 0, fontName, (fontSize \* 0.9375 ))  
 lifeText:setTextColor( textColor, textColor, textColor, 255 )  
 lifeText.xScale = 0.5; lifeText.yScale = 0.5 --\> for clear retina display text  
 lifeText.x = 25  
 lifeText.y = 17  
  
 hudGroup:insert( lifeText )  

But still only system fonts will display when specified. The thing is though, I don’t get an error or a fall back to a system font, I just get blank spaces where the text should display.

The font is also installed in Font Book and I’ve tried multiple custom fonts, including ‘Harrowprint’ in the Corona custom font example, but all to no avail.

Aside from giving up and using something as visually stimulating as Helvetica, can anybody point me in any new directions? Just FYI, I’m using build 2012.935 and at this point I’m just focusing on iOS, I haven’t done any testing in the Android environment.

I should mention that fonts work no problems in Coronas simulator. But xCode simulator and iOS devices don’t. [import]uid: 157954 topic_id: 31748 reply_id: 128723[/import]