cocos2d/cocos2d-x — Issue #763: CCLabelTTF not working as expected in Linux
Author: peoronoob
Created: 2012-03-09 15:50:34+00:00
State: open

Font names like "Arial" are used throughout the project (in tests, in HelloWorld and even in cocosd2x), but CCImage class for Linux (cocos2dx/platform/linux/CCImage_linux.cpp, using FreeType2) cannot handle it.

What happens is that the font cannot be loaded, but the error is not reported by functions like `CCLabelTTF::labelWithString` and thus the labels will not be displayed, without notifying the application in any way.

This shows two problems. One concerns all the platform: if `CCLabelTTF::labelWithString` fails, the application won't be able to handle it, and everything will work normally but the labels won't be shown.

The second issue concerns Linux only: font names like "Arial" won't be loaded by FreeType2 and `CCLabelTTF::labelWithString` will fail.

I'll try to submit a patch for the second issue by using fontconfig to find fonts matching a given pattern (ie: Arial) or falling back on the default font if no matching font can be found.