problem with CCLabelBMFont and kCCBMFontMaxChars

problem with CCLabelBMFont and kCCBMFontMaxChars
0.0 0


Hi forum.

I’m trying to make my own CCLabelBMFont from a keyboard string, if I try to input a ñ (spanish keyboard) I get this error : Assertion failed: (c < kCCBMFontMaxChars) . As I read from other developers, this is because only english letters are allowed, because of this, I tried to replace the ñ letter using the string.replace(), but even when i make a cout<< Mystring ; Im getting the string correctly replaced, the assertion is still there :S.

Any one can help me out with this??

Thanks to everyone.


I managed this problem is a “not so good” way but it worked for me:
I cast the m_sString[i] value in a unsigned char. Therefore, I can now use all characters from 0 to 255 instead of just 0 to 127. I don’t know about the ñ but it allowed me to use french characters such as éàè so hopefully the ñ will work too.


Thank you very much


Hi again, I’m still trying to make the ñ, or éàè to appear, but getting nothing :S. Did you made any other change apart from casting the m_sString[i] value?? when I log the index value of ñ, it should be 241, but I’m getting two values instead 195 and 177 .


Well, if you have two values, it’s because your data is encoded in utf-8 and BMFont does not handle it. When reading my source file with the texts, I convert the utf-8 to 8859-1, In your case, it would convert the 195 and 177 in 241. Check out on google to find how to do the conversion.


Although this post is quite old, just for if it helps anyone in the future:

I had similar problems with “Ñ”, which I solved by just encoding the cpp file (or loaded text file) in UTF-8 without signature (or without BOM).