Reputation: 9251
I am using Corona SDK for game development. I need to use "comic sans font" for my App. I am using font like this.
GAME_FONT = "ComicSansMS"
local txtTitle = display.newText("My Text", 0, 0, GAME_FONT, 30)
This is working perfectly in simulator, but not on real iPhone device. I have also tried to download this font and added in project, then updated build.settings
file.
settings = {
orientation = {
default = "landscapeRight",
supported = { "landscapeRight", }
},
iphone = {
plist = {
UIAppFonts = { "comic.ttf"},
UIStatusBarHidden = true,
UIPrerenderedIcon = true, -- set to false for "shine" overlay
UIApplicationExitsOnSuspend = true, -- uncomment to quit app on suspend
}
},
}
But it is still not working in real iPhone device.
I also made sure if "ComicSansMS" is available built-in by following code.
local fonts = native.getFontNames()
for i,fontname in ipairs(fonts) do
print(fontname)
end
And i can see "ComicSansMS" in list. Any suggestion would be appreciated.
Upvotes: 0
Views: 1819
Reputation: 1006
One small trick: Rename your font file to the same 'logic' name that the font has (ComicSansMS) in your case, without the ttf extension and make sure it's still in the main ressource directory so that you will have natural-born compatibility with Android :)
Android checks by default for font using the internal name so if you rename all your added fonts to the logic name it will work everywhere, less headaches later :)
Also make sure to test on a real iphone device and at least in the google android simulator if you don't have a simulator because some fonts will work perfectly well on the corona simulator but not work at all on iphone / android :)
Upvotes: 0
Reputation: 7390
I'm not sure that Comic Sans is a built-in font for iOS devices. You can refer this link to know more about the available device fonts.
And change the font name to Comic Sans MS
, instead of ComicSansMS
(The space matters).
Also copy and paste the comic.ttf
file to the application folder where your main.lua
resides.
For more information about integrating custom-fonts in your corona app, you can refer my answer on the post: How do you integrate custom fonts in an app?
Keep coding .................. 😃
Upvotes: 1
Reputation: 129
Testing a font with the Windows simulator or with an iOs device is different.
Your code about how to be sure that "ComicSansMs" is in your iOs device looks like you checked the console of the Windows simulator (with print) ...
You should really test on your iOs device and see the results :
local fonts = native.getFontNames()
local fontsNames = ''
for i,fontname in ipairs(fonts) do
fontsNames = fontname .. ',' .. fontsNames
end
local textFontsNames = display.newText(fontsNames, 0, 0, native.systemFont, 30)
Upvotes: 1