Custom Font not loading on build

Hey Guys.

Just wanted to ask a question to see if you know what is going on. I am using a custom font to keep the score in my game, when I test the code it the simulator it works well but when I build and test in the device the numbers disappear. Any idea of what is going on ?

Here is my code:

I placed this on the config .lua

settings =
{
iphone =
{
plist =
{
UIAppFonts =
{
“specialfont.otf”
}
},
},
}

And I placed this on the main.lua

score = 0
scoreText = display.newText( " " … score,470, 15, “specialfont”, 60)

local function countUp()
score = score + 1
scoreText.text = " " … score

end

tmrscore = timer.performWithDelay(70, countUp, -1)

Thank you for your suggestions.

[import]uid: 111657 topic_id: 19520 reply_id: 319520[/import]

Have you including the font file in the project folder?

If so ensure you are using the correct font name. (Double clicking it to install it on a Mac will show you the exact name, which should match what you are requiring. If you changed the file name they may not match.)

If this is correct and you are still experiencing issues try with a different font (I always use TTF fonts) to see if it is just an incompatible font or the like.

Lastly - what device are you testing on?

Peach :slight_smile: [import]uid: 52491 topic_id: 19520 reply_id: 75424[/import]

Hi all,

same problem here. working fine on simulator but not working on xcode and device.

Harrowprint.ttf is in the project root.
Here the build.settings:

settings = {  
 iphone = {  
 plist = {  
 UiAppFonts = {  
 "Harrowprint.ttf"  
 },  
 },  
 },  
}  

And here the main.lua:

local myText = display.newText("Hi!", 0, 0, "Harrowprint", 120)  
myText.x = display.contentWidth/2  
myText.y = display.contentHeight/2  
  
--[[  
local sysFonts = native.getFontNames()  
for k,v in pairs(sysFonts) do print(v) end  
--]]  
  

Let me point out a couple of consideration:

  1. On the simulator it works correctly even if the font is removed from “Font book”
  2. the name of the font is from the for cicle
  3. If used a “common font” everything works fine on the xcode sim and on the device

Thanks for the attention [import]uid: 107375 topic_id: 19520 reply_id: 77534[/import]

Hello!

I have the same exact problem ( ok in simulator but no go on iPhone/iPad) I was a different font but to make sure I tried Harrowprint like above (same build settings and usage) Still no go. I even made sure by using the code that get the name of the font (get.names() function). The Harrowprint font is present on my project (using CPM) and the name seems to be correct (by looking at the book font…name above the window).

Using Helvitca font works both on simulator and device. Both Harrowprint and another font do not show on Device? I am going to try another font but it seems curious that bunch of people (like me) have problem witbph this. By he way I am using the latest trial Corona (very, very, very close to to getting the indie version so I can release my app).

Thank you for any suggestions or help.

Mo. [import]uid: 49236 topic_id: 19520 reply_id: 78863[/import]

Hey Mo,

You have required the font and placed it in your project folder, not in a subfolder?

If you’d care to post a link to a download for the font (the one you are using) I can try and test it myself later tonight.

Peach :slight_smile: [import]uid: 52491 topic_id: 19520 reply_id: 78873[/import]

Hello Peach.

Happy new year!

Yes I think the file is the root folder (using CPM , the file with my main.lua and other lua)

I got the file from the Ansca site talking about font and text:

http://www.dafont.com/font-comment.php?file=harrowprint

I was trying for another font but I need to make sure this font that many use works.

Here my build.settings file

[lua]-- cpmgen build.settings
settings =
{
orientation =
{
default =“landscapeRight”,
content = “landscapeRight”,

supported =
{
“landscapeRight”, “landscapeLeft”
}
},

iphone =
{
plist =
{
UIStatusBarHidden=true,

MinimumOSVersion=“4.2.1”,

UIAppFonts = {“Harrowprint.ttf”}

},
},

}

orientation =
{
default = “portrait”,
supported =
{
“landscapeRight”, “landscapeLeft”
}
}[/lua]

And here how I use it:

local timerText = display.newText(“00:00:00”,190,42, “Harrowprint”,24);

Again it works great on the simulator (mac) but not on the device (iPhone 4…4+ and iPad2…os5)

Thank you so much for looking into this. i am sure it is something I am doing…

Mo [import]uid: 49236 topic_id: 19520 reply_id: 78890[/import]

Hello Peach.

I can see that my buid.settings above seems strange so I decided to use CPM system to build that file like this:

[lua]settings =
{
orientation =
{
default =“landscapeRight”,
content = “landscapeRight”,
supported =
{
“landscapeLeft”,“landscapeRight”
},
},

iphone =
{
plist =
{
UIAppFonts = “Harrowprint.ttf”,

},
},

}[/lua]

Still no luck :slight_smile:

Thank you.

Mo [import]uid: 49236 topic_id: 19520 reply_id: 78892[/import]

Hey Mo, try these EXACT build.settings (copy and paste);

[lua]settings = {
orientation =
{
default = “landscapeRight”,
},
iphone =
{
plist=
{
UIAppFonts =
{
“Harrowprint.ttf”
},

},
},
}[/lua]

I just used these with Harrowprint.ttf in my root folder (the same folder main.lua is in) and tested on an iPhone 4 running iOS5 and it worked perfectly on device.

Can you test that and let me know, please?

Peach :slight_smile: [import]uid: 52491 topic_id: 19520 reply_id: 78898[/import]

Hi Peach,

thanks for the reply.
Actually with your build.settings and with corona build 704 it did worked correctly.
Even with another font than harrowprint.

Last time i used a 715 build of the corona sdk, that my be the cause?
Seems as you can see on my previous post, there is not much difference between your and my build settings.

As soon as i have some time i’ll try with a latest build of corona to verify same condition as i tryed last time.
[import]uid: 107375 topic_id: 19520 reply_id: 78908[/import]

WORKS LIKE A CHARM!!!

Thank you so MUCH Peach. You again save the day!

I will look at the difference between your build settings file and mine but I am sure i made a stupid mistake somewhere. i will try different fonts but i am sure that did it.

THANK YOU Peach :slight_smile:

Mo

ps: Oh, and I am using the latest trial version (…not for long :slight_smile: [import]uid: 49236 topic_id: 19520 reply_id: 78945[/import]

@grandezot - interesting. Yes, please do that, if there is a problem in newer builds it would be very important we hear about that.

@Mo - I’m very happy it sorted it, thank you :slight_smile: Any time I can save the day for a Corona developer is a great one!

Peach :slight_smile: [import]uid: 52491 topic_id: 19520 reply_id: 79082[/import]

No thank you Peach. Just a quick note that I tried another font and it works great too both on device and simulator. My build settings was really messed up!

Mo [import]uid: 49236 topic_id: 19520 reply_id: 79086[/import]

The build.settings that you last posted the issue was that you had;

[lua]UIAppFonts = “Harrowprint.ttf”[/lua]

Rather than;

[lua] UIAppFonts =
{
“Harrowprint.ttf”
}[/lua]

And easy mistake to make, so it wasn’t too messed up :wink:

Peach :slight_smile: [import]uid: 52491 topic_id: 19520 reply_id: 79128[/import]

Hello,

hate to say it, but I have the same problem - no custom fonts on iOS or Android.
On the simulator it works fine, but it’s a no show on iPad2, Galaxy Tab and Kindle Fire.

Normally I get all the stuff to work on all these devices, with LevelHelper & ParticleCandy etc. - but this custom font problem just kills me:

I followed the instructions to the letter, copied your code (Peach) and it still doesn’t work.
I tried with Corona build 725 and even got back to 704 - no success.

Here’s the link to download the most basic of tests:
http://apps.oetingerverlag.de/CustomFontTest.zip

build.settings:

settings = {  
 orientation =  
 {  
 default = "landscapeRight",  
 },  
  
 iphone =  
 {  
 plist=  
 {  
 UIAppFonts =  
 {  
 "Harrowprint.ttf"  
 },  
 },  
 },  
}  

main.lua:

-------------------------------------  
-- main.lua  
-------------------------------------  
  
local myText1 = display.newText( "This is Harrowprint", 200, 200, "Harrowprint", 42 )  
myText1:setTextColor(255, 255, 255)  

I used the “Harrowprint.ttf” font linked on your example page and put it into the main folder (have a look at the project zip and just compile).
Works fine on simulator, but not on the devices.

I’m running out of ideas.

Best,
Andreas

[import]uid: 107675 topic_id: 19520 reply_id: 80837[/import]

Hey Andreas,

OOI, what version of iOS is on your test device?

Peach [import]uid: 52491 topic_id: 19520 reply_id: 80983[/import]

I tested it on iPhone 4 and iPad 2, both with iOS 5.0.1.

When I take a look into the package the font is listed in the CustomFontTest.app/Info.plist:

<?xml version="1.0" encoding="UTF-8"?>  
  
<plist version="1.0"><br><dict><br>...<br>	<key>UIAppFonts</key><br>	<array><br> <string>Harrowprint.ttf</string><br>	</array><br>...<br></dict><br></plist>  
  

Does the test project work on your device?

Thanks for looking into it!

Andreas
[import]uid: 107675 topic_id: 19520 reply_id: 81008[/import]

Your test project actually works just fine on my device.

I’m going to ask around and see if another team member has any ideas about this.

Peach :slight_smile: [import]uid: 52491 topic_id: 19520 reply_id: 81019[/import]

Hey Andreas,

That is incredibly interesting. Would you be able to file a bug report with all of this info, please? (You can copy and paste most of your post if that makes it easier.)

It would be a huge help in figuring this out.

One other question as I wasn’t sure about the above - is your computer running Xcode 4.1 or 4.2? (The last paragraph confused me and I like to make sure.)

Peach :slight_smile: [import]uid: 52491 topic_id: 19520 reply_id: 81069[/import]

Hi Peach,

yes, my computer WAS running Xcode 4.2.
I deinstalled it and installed Xcode 4.1.

But - oh no - this didn’t solve the problem:
Still the “Harrowprint.ttf” is not placed into the IPA package.

Now I’m starting to upgrade to OSX Lion.
Do you run Lion?

I will put this into the bug database after my result of the Lion test.

Best,
Andreas [import]uid: 107675 topic_id: 19520 reply_id: 81238[/import]

Arggh! This is really weird…

Here some additional information:

My Mac runs OSX 10.6.8
Xcode 4.2

I get these warnings compiling the test project (because I don’t have icons etc.):

Copyright (C) 2009-2012 A n s c a , I n c .  
 Version: 2.0.0  
 Build: 2012.726  
The file sandbox for this project is located at the following folder:  
 (/Users/anl982/Library/Application Support/Corona Simulator/159-C393496EBD4FBD6CCCEA9158A1168F48)  
  
2012-01-19 12:08:47.857 Corona Simulator[77848:60f] WARNING: Could not find certificate for identity (iPhone Distribution: Loud Crow Interactive Inc.) whose user id is: xxxxxxxx  
2012-01-19 12:08:47.858 Corona Simulator[77848:60f] WARNING: Could not find certificate for identity (iPhone Developer: Horst Hoesel (xxxxxxx)) whose user id is: xxxxxxxx  
  
Using Custom Build Id 4a9b448a437943329989b8ca4181ecda  
  
Using additional build settings from: /var/folders/FE/FE4UmB+0F-SwwJTKyOzZL++++TM/-Tmp-/TemporaryItems/159/build.settings  
Created XCENT: /var/folders/FE/FE4UmB+0F-SwwJTKyOzZL++++TM/-Tmp-/1326971348/entitlements.xcent  
2012-01-19 12:09:15.930 defaults[77867:60b]   
There is no (ContentOrientation) default for the (/Users/anl982/Desktop/Corona/Build/CustomFontTest.app/Info) domain.  
Defaults have not been changed.  
2012-01-19 12:09:15.939 defaults[77868:60b]   
There is no (UISupportedInterfaceOrientations) default for the (/Users/anl982/Desktop/Corona/Build/CustomFontTest.app/Info) domain.  
Defaults have not been changed.  
mv: rename /Users/anl982/Desktop/Corona/Build/CustomFontTest.app/icon.png to /Users/anl982/Desktop/Corona/Build/CustomFontTest.app/Icon.png: No such file or directory  
/Users/anl982/Desktop/Corona/Build/CustomFontTest.app: replacing invalid existing signature  
/Users/anl982/Desktop/Corona/Build/CustomFontTest.app: signed bundle with Mach-O thin (armv7) [CustomFontTest]  

When I open the CustomFontTest.app package I find these files:


http://apps.oetingerverlag.de/CustomFontTest.app.png

Shouldn’t the “Harrowprint.ttf” file be in there somewhere?

EDIT:

I compiled the project on a friends Mac (OSX Lion, Corona 726, Xcode 4.1).
The IPA showed the custom font on his iPad…

And: The “Harrowprint.ttf” was packaged in the IPA!

The problem seems to be that when I compile the project the font file is NOT placed into the IPA.

The differences of our development systems is Snow Leopard w Xcode 4.2 vs. Lion w Xcode 4.1.
I don’t think that it’s the OS, so maybe it’s the Xcode version?

Hope this helps you to help me. :slight_smile:

Andreas
[import]uid: 107675 topic_id: 19520 reply_id: 81030[/import]