Custom font: select font type "thin"

hey guys,

I’m using “Roboto” as a font in my app. Everything works fine with the custom font, but I can’t use any other font style than “regular”.

But I want to use Bold, Black or Thin too at some points. There are different files for the different font types. I also found the font names (for windows simulator)

But it doesnt change, not on my android device and not in the simulator.

Here is my code for the font:

[lua]-- load roboto font
if “Win” == system.getInfo( “platformName” ) then
robotoFont = native.newFont( “Roboto”)
robotoFontBlack = native.newFont( “Roboto Bk”)
robotoFontThin = native.newFont( “Roboto Th”)
elseif “Android” == system.getInfo( “platformName” ) then
robotoFont = native.newFont( “RobotoRegular”)
robotoFontBlack = native.newFont( “RobotoBlack”)
robotoFontThin = native.newFont( “RobotoThin”)
end[/lua]

I placed  the font files in the project folder (and as I said, the regular font works)

Any ideas? 

Hi @lornz87,

Did you follow the tips inside the FAQ on custom fonts? There are some important details that you need to follow to ensure that custom fonts work:

http://www.coronalabs.com/blog/2013/01/16/faq-wednesday-custom-fonts/

Best regards,

Brent

Yes I read that. I have no trouble loading a custom font.

I have trouble getting a special font-style to work. I can load “Roboto” just fine. But I can’t find a way to load “Roboto Black” or “Roboto Thin” - everytime I try I just get “Roboto regular”

Are you using this with display.newText or with native.newTextField. native.newTextBox?

display.newText

Same here, never been able to get variations of a font to work.

Even if I replace the “regular” font file with the “thin” font file - no difference. I guess the different font styles are not really connected to the respective font files.

Hi lornz87,

Would you be willing to send these font files to me for testing? I would certainly not distribute them or use them for any reasons other than testing, assuming these are fonts you purchased or licensed. If you’re willing to, please send to brent (at) coronalabs (dot) com.

Thanks!

You got mail!

Hi @lornz87,

Did you follow the tips inside the FAQ on custom fonts? There are some important details that you need to follow to ensure that custom fonts work:

http://www.coronalabs.com/blog/2013/01/16/faq-wednesday-custom-fonts/

Best regards,

Brent

Yes I read that. I have no trouble loading a custom font.

I have trouble getting a special font-style to work. I can load “Roboto” just fine. But I can’t find a way to load “Roboto Black” or “Roboto Thin” - everytime I try I just get “Roboto regular”

Are you using this with display.newText or with native.newTextField. native.newTextBox?

display.newText

Same here, never been able to get variations of a font to work.

Even if I replace the “regular” font file with the “thin” font file - no difference. I guess the different font styles are not really connected to the respective font files.

Hi lornz87,

Sorry for the delay on this. Can you please run the following code and tell me the exact names you’re getting back in Windows? I want to confirm it against the names that I’m seeing before proceeding.

[lua]

local fonts = native.getFontNames()

local name = “roboto”

name = string.lower( name )

– Display each font in the terminal console

for i, fontname in ipairs(fonts) do

    j, k = string.find( string.lower( fontname ), name )

    if( j ~= nil ) then

        print( "fontname = " … tostring( fontname ) )

    end

end

[/lua]

Thanks,

Brent

Hi lornz87,

Would you be willing to send these font files to me for testing? I would certainly not distribute them or use them for any reasons other than testing, assuming these are fonts you purchased or licensed. If you’re willing to, please send to brent (at) coronalabs (dot) com.

Thanks!

You got mail!

Hi lornz87,

Sorry for the delay on this. Can you please run the following code and tell me the exact names you’re getting back in Windows? I want to confirm it against the names that I’m seeing before proceeding.

[lua]

local fonts = native.getFontNames()

local name = “roboto”

name = string.lower( name )

– Display each font in the terminal console

for i, fontname in ipairs(fonts) do

    j, k = string.find( string.lower( fontname ), name )

    if( j ~= nil ) then

        print( "fontname = " … tostring( fontname ) )

    end

end

[/lua]

Thanks,

Brent

Hi, I’m wondering if there was a conclusion, closure to this case. Thanks for sharing.