How to use custom font(ttf)?

How to use custom font(ttf)?
0.0 0


I was try use different font call “NanumMyeongjo.ttf” and it didn’t work.

I put “NanumMyeongjo.ttf” file into Resource and here are code…
CCLabelTTF* pLabel = CCLabelTTF::labelWithString(“Font Test”, “NanumMyeongjo.ttf”, 30);

It work fine at cocos2d-iPhone.

Is there anything I missed?
thankq. (1353.3 KB)


cocos2d-iphone uses FontLabel as third-party library to parse the custom ttf file.
But we haven’t implement this feature on cocos2d-x yet.
Issue #347 is created 1 month ago, but we still have no time to do it.


FYI, I would also like to request this feature - especially as skia seems to be crashing on my archos 101…


@Isaac Ashdown
It hears so bad. skia crashes. AFAIK, both GUI system & webkit on android use either skia or opengles for rendering.
I saw your post in another thread, so odd.


Sorry to be so vague - I was referring to the discussion we’ve been having in this thread:


So, is there any chance of getting a schedule on this? Would like to start localisation but its pretty difficult with bitmap fonts…


@Isaac Ashdown
After evaluating freetype library, we are clear that it cannot replace FontLabel directly. FreeType is too low-level for our usage.
We had to find new ways to render custom fonts. Do you have any suggestions?


Walzer, I am having a translation done to chinese for Mashemup, i would like to keep the current look of the game, so i guess i need to get the bitmap from the ttf.

Did freetype give you too much trouble to compile? :smiley:


It is not compiling trouble, the freetype is too low level to use, such as the layout, alignment and so on.


Ic… well, i think i will use, i need to create the look of my custom fonts so i already integrated cximage to use some of the features and to be able to access the bitmaps directly and modify them and add some stroke and effects to them.


After playing with the freetype library, i understand now what you mean by too low level.

It works and i get the bits done since i only need to extract a few characters although it is really a lot of work to have it generic.
At least on my case i dont need much of it so i guess i will use it.

There are not many other options to this one, right?


What about using the platform SDK? It seems it would be worth it, no? To be honest, without custom fonts the CCLabelTTF is fairly useless, because its pretty ugly :frowning:

Seems at least on android it’s easy enough to do, and then sending the data as just a raw bitmap to the NDK layer shouldn’t be a problem. Guess it might be slow…but then if you want speed, you should use bitmap fonts anyway…


I agree with you, Isaac. Since we switch from skia to sdk to draw texts at 0.8.5, using sdk to support custom ttf seems feasible now.
Ming, what’s your opinion?


I will have a test.


Update feature #347.


So! I noticed this feature was closed today, so i thought I’d grab the git edge version and take a peek.

It’s working very nicely on Android, which is fantastic! Thank you so much for implementing this!

However, it doesn’t appear to have made any changes on the win32 version. I notice that CCImage_win32 has seen some changes, and I’ve stepped through the code there and taken a look. It appears to be loading the font OK, as far as I can tell, but the rendered text is the same as before. It’s not a huge deal, as android is my target platform and all, I just do most of the development on win32…

Also, I was wondering - is it best practice to include the ‘.ttf’ extension in the font name, or to leave it out?



OK, I reopen issue #347 for win32 port.
Maybe you should leave .ttf extension as it is.


If remove ‘.ttf’ extension, it will be used as “xxx/yyy”. I think it is not so good. You may said that, in iOS, we just use “yyy” as the font name. But as you see, the ttf files are copied into the root directory of the app. If the android use like it, the ttf files should put into a directory with specified name, fonts as example. I think it is not a good idea.


to Isaac Ashdown:

sorry! because fonttest’s font has been installed in my computer,so i can renderer fine.

I has found the reason! I will fix it.

Thank you for your reminds!


to Isaac Ashdown:

I downloaded today (12.08.2011) edge version (

Win version works great with your font, but Android version still has default font.

Can you please test today version, if works? Its really odd that version 7days older works and newest not.