I have an error with CCLabelBMFont on Android device.
I create a new hd_font.fnt by myself.
When I use:
pLabel = CCLabelBMFont::labelWithString("hello \n every","hd_font.fnt");
Everything is ok.
But when I use a text file,which have a character ‘’, and read it by CCFileData, then use CCLabelBMFont to show it, it cause error and exit my app.
After some test, I sure this error caused by use text file with character ‘’, like this:
CCFileData data(CCFileUtils::fullPathFromRelativePath("test.txt"), "rt");
std::string pBuffer = (char*)data.getBuffer();
pBuffer[10] = 0;
//I don't know why CCFileData return me data string with some character I don't create
//so I need to end this string by hand
CCLog("text out %s",pBuffer.c_str());
pLabel->setString(pBuffer.c_str());
My text only have text:
hello
every
On win32, it run Ok. On AndroidSDK log, it print true,but my app still crash.
My font is ok. It doesn’t crash if I use { labelWithString(“hello every”,“hd_font.fnt”); }
And if the string in my text file is “hello every”,it doesn’t crash,too. So I think it cause error by character ‘’ on text file.
And more,everything run ok on cocos 0.11, it crash when i change to cocos 0.12
I up the code for test, please check it.
Thanks for help.
code test.rar.zip (39.4 KB)