cocos2d / cocos2d-x

Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.
https://www.cocos.com/en/cocos2d-x
18.24k stars 7.06k forks source link

Lable::createWithSystemFont with chinese show as block on windows #17377

Open ychua842655 opened 7 years ago

ychua842655 commented 7 years ago

Lable::createWithSystemFont with chinese show as block on windows , Lable::createWithTTF is work fine; Picture show below is a screenshot of my App run on windows c805c81995f41f63783bae5fb2707281

@minggo The error description is wrong,Label show Chinese only worked with owner .ttf file whatever APi createWithSystemFont or createWithTTF, and i found that word wrap for chinese is not work

minggo commented 7 years ago

did you write the characters in source code?

ychua842655 commented 7 years ago

No, I get it from utf8 file.And it work's fine with api createWithTTF

minggo commented 7 years ago

Any codes to reproduce it? Did you pass system font name, may be your system doesn't have the font you specified.

ychua842655 commented 7 years ago

@minggo I pass the system font name as "Helvetica",just like as ios/android . test code is: std::string str = FileUtils::getInstance()->getStringFromFile("testFile.txt"); auto label = Label::createWithSystemFont(str,"Helvetica",20,Size(getContentSize().width/4,0)); label->setPosition(getContentSize() / 2); this->addChild(label,2); testFile.txt This is my test file with chinese utf8 string

minggo commented 7 years ago

I don't have win10, i will test on win7 to take a look.

ychua842655 commented 7 years ago

Thank you

minggo commented 7 years ago

I tested with latest codes on window7, no problem. I will test on v3.13.1 branch.

ychua842655 commented 7 years ago

Thank you ,Dose results about v3.13.1 branch out now?

minggo commented 7 years ago

windows7 also works on v3.13.1, so the problem may be something related with windows10. Yep, latest version is v3.14.1.

ychua842655 commented 7 years ago

Thank you very much,I will test it on windows phone 10 and give the feedback to you

ychua842655 commented 7 years ago

@minggo If you can, please test it on win10 environment.(will it be a question of access?)

summerinsects commented 7 years ago

Hey here! I reproduced it! The reason why it displayed as square is the ttf your specified does not support Chinese. Maybe you can download Arial Unicode MS (21.8 MB), and put it into the folder Resources/fonts