Can't create CCLabelTTF with system font!

I create a CCLabelTTF simply with “Arial”, which is also the default font name implementing in CCFreeTypeFont. But in CCFreeTypeFont::loadSystemFont() is simply return nullptr for WP8!

How to use system font instead of carry many .ttf files in the packages, especially for the huge chinese fonts?

Finally, I find a way to use system font. Modify method loadSystemFont() in CCFreeTypeFont.cpp.

Using the following code to replace “return nullptr”.

unsigned char* CCFreeTypeFont::loadSystemFont(const char *pFontName, unsigned long *size) 
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8)
    std::string fontName(pFontName);
    if (fontName.find(".ttf") == -1)
        fontName += ".ttf";
    std::string fontPath = "C:\\Windows\\Fonts\\" + fontName;
    return CCFileUtils::sharedFileUtils()->getFileData(fontPath.c_str(), "rb", size);
#else
    ......
1 Like

Thank you for sharing this information. It works great and allowed me to use the Yu Gothic-systemfont for showing Japanese text. I am working with version 2.2.3 by the way and as far as I could see, this code is not in the official release, but should be imho.