Android Custom Fonts

I have read through a few topics on the API and forums about custom fonts and android.

I have the following which works fine on Apple devices:

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

iphone =
{
plist =
{
UIAppFonts =
{
“MyFont.ttf”
},

UIStatusBarHidden=true,
UIPrerenderedIcon = true

},
}

}[/lua]

It states that you don’t need to specify for Android and I have check that the fontname (not the file) name is the same as it is in FontBook on my PC using [lua]native.getFontNames()[/lua] and indeed the name is the same.

However, when using my font I get Warning: could not load font MYFONTNAME. Using default font.

Is in fact the documentation misleading and there is something else I need to be doing? [import]uid: 103970 topic_id: 21570 reply_id: 321570[/import]

Ignore me. Font wasnt installed on PC :slight_smile: [import]uid: 103970 topic_id: 21570 reply_id: 85514[/import]

I was wrestling with this last night. I have discovered that on Android, you specify the filename, MINUS the file extension.

i.e. “amienne.ttf” becomes “amienne” for Android, while on iOS it would be “Amienne”.

Also make sure the actual font file is in the root folder of your project.
[import]uid: 93133 topic_id: 21570 reply_id: 85515[/import]

Thanks for the response

How does your build.settings file look if you dont mind sharing [import]uid: 103970 topic_id: 21570 reply_id: 85520[/import]

Sure…

[lua]settings =
{

androidPermissions =
{
“android.permission.VIBRATE”
},

orientation =
{
default = “landscapeRight”,
content = “landscapeRight”,
supported =
{
“landscapeRight”
},
},

iphone =
{
plist =
{

MinimumOSVersion=“4.3”,
UIApplicationExitsOnSuspend = false,
UIAppFonts =
{
“amienne.ttf”,
“teen.ttf”
},

CFBundleURLTypes =
{
{
CFBundleURLSchemes =
{
“fb363179733694583”,
}
}
},
CFBundleIconFile = “Icon.png”,
CFBundleIconFiles = {
“Icon.png” ,
“Icon@2x.png” ,
“Icon-72.png” ,
“Icon-Small-50.png” ,
“Icon-Small.png” ,
“Icon-Small@2x.png”
},
},
}
}[/lua] [import]uid: 93133 topic_id: 21570 reply_id: 85521[/import]

thanks for that

So when you say you are missing the TTF off you mean in code when specifying a newText object? [import]uid: 103970 topic_id: 21570 reply_id: 85527[/import]

Yes, I just set up a table called fontName and set the values depending on system.getInfo(“platformName”).

[import]uid: 93133 topic_id: 21570 reply_id: 85534[/import]

Thanks again for your help thats clear [import]uid: 103970 topic_id: 21570 reply_id: 85545[/import]