'Afternoon, hi.
Rather than dig up Label v3.0 unicode characters? I’ve started here instead.
I use BMFont
to generate some nice fast fonts but then when I go to output anything above 127, eg Latin + Latin supplement the Label
doesn’t get drawn to screen anymore.
08-18 17:03:36.287: D/cocos2d-x debug info(615): Logging word “nat�o”
08-18 17:03:36.287: D/cocos2d-x debug info(615): Logging word “nat�o” 0x2aebeb88
when the string is natío (nat &237; o)
the source is
CCLOG("Logging word \"%s\"", preWord);
Label *pLabel = Label::createWithBMFont(fntNm, preWord);
CCLOG("Logging word \"%s\" %p", preWord, pLabel);
and works great until I step into Latin + supplement territory.
Does anyone have a quick fix for this? I can’t get tests to build anymore. Thank yous.
EDIT
It seems the problem is more like the previous issue than anticipated. pLabel->getContentSize().height
is reporting zero.
I think http://www.lingua-systems.com/unicode-converter/unicode-mappings/encode-iso-8859-1-to-utf-8-unicode.html
should help, if not I’ll bang on here.
Do me a favour and save me opening another topic, how can I get from a zipped char *
to a wide string? I’ve save my text as UTF-8 and I reckon on those >127 char’s taking 2 bytes now, but I can’t just pipe every byte one-by-one. Is there an easy fix to get from in memory char* where the text is variable width UTF-8 to wchar, UNICODE or even a Label
? Spent ages getting my unzip routine fast and smooth, never reckoned with zlib succesfully before though.
Sorry, I know this is a big ask. You make everything too easy already with these fab libs.
can’t believe this has had so few views, don’t think anyone will mind if I post again, some sample code:
/////////////////////////////
// 3. add your codes below...
for (int i = 0; i < 130; ++i) {
char labBuf[64] = {0};
labBuf[0] = i + 126;
// wsprintf(labBuf, "%c", i);
//std::string mystr
Label *pLabel = Label::createWithBMFont("fonts/libsans48.fnt", labBuf);
Label *pLabel2 = Label::createWithTTF(labBuf, "fonts/Marker Felt.ttf", 32);
CCLOG("Logging word \"%s\"", labBuf);
pLabel->setPosition(Vec2(25.0 + visibleSize.width * (i / 14) / 10.0, 35.0 + visibleSize.height * (i % 14) / 14.0));
pLabel2->setPosition(Vec2(42.0 + visibleSize.width * (i / 14) / 10.0, 42.0 + visibleSize.height * (i % 14) / 14.0));
addChild(pLabel, 1, i);
addChild(pLabel2, 1, i);
}
return true;```
Hopefully we all know where that is from in HelloWorld::init(). I can't meddle in my files if I can't figure out how to get Unicode into the `Labels`. All the methods take strings which only hold chars up to 127. http://stackoverflow.com/questions/3011082/c-stdstring-and-utf-8.
I think I'll have to redefine some BMFonts and dump some symbols for proper accented versions. At least this explains why my £ key wasn't appearing.
// 3. add your codes below...
int byte2 = 0xC2A0;
for (int i = 0; i < 96; ++i) {
char labBuf[64] = {0};
labBuf[0] = (byte2 >> 8) & 0x00ff;
labBuf[1] = byte2 & 0x00ff;
if (++byte2 == 0xC2C0) byte2 = 0xC380; //A discontinuity
Label *pLabel = Label::createWithBMFont("fonts-enuk/libsans48.fnt", labBuf);
CCLOG("Logging word \"%s\"", labBuf);
pLabel->setPosition(Vec2(25.0 + visibleSize.width * (i / 14) / 10.0, 35.0 + visibleSize.height * (i % 14) / 14.0));
addChild(pLabel, 1, i);
}
return true;
Even CCLOG is now displaying UTF-8. Thanks to file:///C:/Users/LB/Desktop/New%20folder/c++%20specific/Encode%20ISO-8859-1%20to%20UTF-8_Unicode%20Code%20Points.htm for supplying the mapping.
The big black gap is my fault, I removed unused big capital glyphs.