Custom Fonts not supporting

Hi I wan to implement a custom font “JasmineUPC.otf”, but it is not showing on corona simulator and on device, and also I tried using JasmineUPC.ttf, what to do please help me.

button= widget.newButton{
label=current,
labelColor={ default={ 128, 255, 96, 255 }, over={ 0 } },
id=current,
default = “Images/innerbox.png”,
width=64, height=64,font=“JasmineUPC”,fontSize=20,
onRelease = changeScene – event listener function
} [import]uid: 172535 topic_id: 34836 reply_id: 334836[/import]

hemanth-

This can be different depending upon which platform you are targeting… are you trying to get this to work on iOS or Android?

If on iOS, you need to be sure to put the font file in the same directory as your main.lua file. On an android device, you have to do 3 things: 1) find out the internal reference name of the font. 2) place that font in the same place as your main.lua file, 3) rename the font file to match the internal reference name of the font.

You get the internal reference name by using the native.getFontNames() method.

I hope that helps!

-Duneunit [import]uid: 10818 topic_id: 34836 reply_id: 138504[/import]

First, for the font to be used by the simulator, it has to be installed in the operating system, not just laying in the folder with main.lua. On the Mac use Font Book to install it. I’ve forgotten how to install it on a PC, but probably double clicking on it will work (should work on the Mac too).

I think OTF font support has been recently added to a daily build for Android. I don’t know if OTF fonts are going to work on Windows at all. Since you are a test driver, the last public build doesn’t support OTF on Android. (You didn’t say what you’re building for!)

For iOS, you have to have the font configured properly in your build.settings file. The name you use in Corona must match the internal name of the font both in case, and white space. If the internal name is “Jasmine UPC Regular” and you are using “JasmineUPC” in Corona even though the filename is JasmineUPC.ttf, it won’t match and it won’t load.

For Android it just has to be in the directory with main.lua. Android has the same internal name match requirement as iOS does, but to compound matters, the filename has to match the internal name which has to match the name you use in Corona SDK.
[import]uid: 199310 topic_id: 34836 reply_id: 138535[/import]

Hi Rob,

thankyou for the reply, I am targetting for ios.I want to work it on device, and here is my build.settings
settings = {

orientation =
{
default = “portrait”,
supported =
{
“portrait”, “portraitUpsideDown”
},
},
content =
{
content = “portrait”,
},
plist =
{

UIApplicationExitsOnSuspend = true,
UIStatusBarHidden = true,
UIPrerenderedIcon = true,
UIAppFonts =
{
“JasmineUPC.otf”
}

}

}

Thanks [import]uid: 172535 topic_id: 34836 reply_id: 138556[/import]

Hi,
I am targetting for ios, and do I need to find the internal reference name of the font, If so please tell me how t find its internal name.

Thanks [import]uid: 172535 topic_id: 34836 reply_id: 138560[/import]

On the Mac, CTRL-click the font, choose “Get Info”. The font’s real name should be listed. Font Book should also show you.
[import]uid: 199310 topic_id: 34836 reply_id: 138595[/import]

hemanth-

This can be different depending upon which platform you are targeting… are you trying to get this to work on iOS or Android?

If on iOS, you need to be sure to put the font file in the same directory as your main.lua file. On an android device, you have to do 3 things: 1) find out the internal reference name of the font. 2) place that font in the same place as your main.lua file, 3) rename the font file to match the internal reference name of the font.

You get the internal reference name by using the native.getFontNames() method.

I hope that helps!

-Duneunit [import]uid: 10818 topic_id: 34836 reply_id: 138504[/import]

First, for the font to be used by the simulator, it has to be installed in the operating system, not just laying in the folder with main.lua. On the Mac use Font Book to install it. I’ve forgotten how to install it on a PC, but probably double clicking on it will work (should work on the Mac too).

I think OTF font support has been recently added to a daily build for Android. I don’t know if OTF fonts are going to work on Windows at all. Since you are a test driver, the last public build doesn’t support OTF on Android. (You didn’t say what you’re building for!)

For iOS, you have to have the font configured properly in your build.settings file. The name you use in Corona must match the internal name of the font both in case, and white space. If the internal name is “Jasmine UPC Regular” and you are using “JasmineUPC” in Corona even though the filename is JasmineUPC.ttf, it won’t match and it won’t load.

For Android it just has to be in the directory with main.lua. Android has the same internal name match requirement as iOS does, but to compound matters, the filename has to match the internal name which has to match the name you use in Corona SDK.
[import]uid: 199310 topic_id: 34836 reply_id: 138535[/import]

Hi Rob,

thankyou for the reply, I am targetting for ios.I want to work it on device, and here is my build.settings
settings = {

orientation =
{
default = “portrait”,
supported =
{
“portrait”, “portraitUpsideDown”
},
},
content =
{
content = “portrait”,
},
plist =
{

UIApplicationExitsOnSuspend = true,
UIStatusBarHidden = true,
UIPrerenderedIcon = true,
UIAppFonts =
{
“JasmineUPC.otf”
}

}

}

Thanks [import]uid: 172535 topic_id: 34836 reply_id: 138556[/import]

Hi,
I am targetting for ios, and do I need to find the internal reference name of the font, If so please tell me how t find its internal name.

Thanks [import]uid: 172535 topic_id: 34836 reply_id: 138560[/import]

On the Mac, CTRL-click the font, choose “Get Info”. The font’s real name should be listed. Font Book should also show you.
[import]uid: 199310 topic_id: 34836 reply_id: 138595[/import]

custom font is not working when using storyboard. cause when I dont use it, the custom font is work.

Storyboard should not be interfering with your custom fonts.  Something else has to be the cause.  But you’re going to need to post some code for any of us to have a chance to help you.

Rob

There is something with custom fonts naming that doesn’t goes exacly as it’s written in documentation. Mayby you have alredy everything alright or do not have this problem but for reference:

  1. As said, on simulators you only have fonts you have installed in system (they are not taken from project folder)
  2. Not sure how on Mac but on Windows parametrized fonts are installed as one font, ie. for example you have normal arial font, bold and italic. In text editor you can just select Arial font and pick normal, bold or italic. However some font files are prepared this way that they are inatalled in system as one ‘pack’. If you have such font ‘pack’ then unfortunatelly, you can just use normal in simulator (forget bold or italic).
  3. In Corona docs you have written that you must use font file name or inner name when loading font. I had a problem some time ago because neither was working. The reason was that iOS or Android was seeing this fonts under other (slightly different) name! The perfect solution was to print all fonts names available on device when app was on target device (there is function in Corona to do it - search docs because I cannot recall it now). I found my font name (which was slightly different than that found in file name or inside it). I pasted it in when loading font and it worked like charm.

custom font is not working when using storyboard. cause when I dont use it, the custom font is work.

Storyboard should not be interfering with your custom fonts.  Something else has to be the cause.  But you’re going to need to post some code for any of us to have a chance to help you.

Rob

There is something with custom fonts naming that doesn’t goes exacly as it’s written in documentation. Mayby you have alredy everything alright or do not have this problem but for reference:

  1. As said, on simulators you only have fonts you have installed in system (they are not taken from project folder)
  2. Not sure how on Mac but on Windows parametrized fonts are installed as one font, ie. for example you have normal arial font, bold and italic. In text editor you can just select Arial font and pick normal, bold or italic. However some font files are prepared this way that they are inatalled in system as one ‘pack’. If you have such font ‘pack’ then unfortunatelly, you can just use normal in simulator (forget bold or italic).
  3. In Corona docs you have written that you must use font file name or inner name when loading font. I had a problem some time ago because neither was working. The reason was that iOS or Android was seeing this fonts under other (slightly different) name! The perfect solution was to print all fonts names available on device when app was on target device (there is function in Corona to do it - search docs because I cannot recall it now). I found my font name (which was slightly different than that found in file name or inside it). I pasted it in when loading font and it worked like charm.

Maybe this can be of some help

First be shure to install the font on your mac/PC

When working with custom fonts there are two references you need to deal with.
In this example I refers to the font MarsAttacks truetype font (ttf)


MarsAttacks.ttf                    --<< The actual font file on your computer (used in build.settings file)

MarsAttacks-Regular          --<< The font name you use when you declaring the font handle (i.e. your main file)


your main file:

I usually make a global var of the fonts I use, like this:

_G.messageFont = “MarsAttacks-Regular”

To be shure how to address the font name in the right way I put this for-loop snippet in the main file as well:

local sysFonts = native.getFontNames()
for k,v in pairs(sysFonts) do print(v) end

When you run this code in the simulator with the terminal open you can scroll through the list of fonts and copy the font name and put it in the variable _G.messageFont  (shown over)

 when this is done you can comment out the code again like this:

–[[
local sysFonts = native.getFontNames()
for k,v in pairs(sysFonts) do print(v) end
–]]

Now you go to the build.settings file and make the reference to the actual fontFILE ( Here is my build.settings code as an example ) :

settings = {

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

iphone = {
  plist = {
  UIAppFonts = {
  “MarsAttacks.ttf” 
  },
  CFBundleIconFiles = {
                  ‘Icon.png’,
                  ‘Icon@2x.png’,
                  ‘Icon-Small-40.png’,
                  ‘Icon-Small-40@2x.png’,
                  ‘Icon-60.png’,
                  ‘Icon-60@2x.png’,
                  ‘Icon-72.png’,
                  ‘Icon-72@2x.png’,
                  ‘Icon-76.png’,
                  ‘Icon-76@2x.png’,
                  ‘Icon-Small-50.png’,
                  ‘Icon-Small-50@2x.png’,
                  ‘Icon-Small.png’,
                  ‘Icon-Small@2x.png’
              }
  },
},

}

Hi again :slight_smile:

You could try to convert the off font to truetype  ( otf ==> ttf ) with this free online tool:

http://www.freefontconverter.com/

Keep in mind that I have not tested this myself

Maybe this can be of some help

First be shure to install the font on your mac/PC

When working with custom fonts there are two references you need to deal with.
In this example I refers to the font MarsAttacks truetype font (ttf)


MarsAttacks.ttf                    --<< The actual font file on your computer (used in build.settings file)

MarsAttacks-Regular          --<< The font name you use when you declaring the font handle (i.e. your main file)


your main file:

I usually make a global var of the fonts I use, like this:

_G.messageFont = “MarsAttacks-Regular”

To be shure how to address the font name in the right way I put this for-loop snippet in the main file as well:

local sysFonts = native.getFontNames()
for k,v in pairs(sysFonts) do print(v) end

When you run this code in the simulator with the terminal open you can scroll through the list of fonts and copy the font name and put it in the variable _G.messageFont  (shown over)

 when this is done you can comment out the code again like this:

–[[
local sysFonts = native.getFontNames()
for k,v in pairs(sysFonts) do print(v) end
–]]

Now you go to the build.settings file and make the reference to the actual fontFILE ( Here is my build.settings code as an example ) :

settings = {

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

iphone = {
  plist = {
  UIAppFonts = {
  “MarsAttacks.ttf” 
  },
  CFBundleIconFiles = {
                  ‘Icon.png’,
                  ‘Icon@2x.png’,
                  ‘Icon-Small-40.png’,
                  ‘Icon-Small-40@2x.png’,
                  ‘Icon-60.png’,
                  ‘Icon-60@2x.png’,
                  ‘Icon-72.png’,
                  ‘Icon-72@2x.png’,
                  ‘Icon-76.png’,
                  ‘Icon-76@2x.png’,
                  ‘Icon-Small-50.png’,
                  ‘Icon-Small-50@2x.png’,
                  ‘Icon-Small.png’,
                  ‘Icon-Small@2x.png’
              }
  },
},

}