Search code examples
unicodeluacocos2d-xunicode-string

How to display Unicode string in with Lua in Cocos Code Ide


I'm using Cocos Code IDE to create a simple project with Lua. main.lua was saved in UTF-8 Without BOM and contains the following snippet:

local label1 = cc.Label:createWithTTF("長い","fonts/Marker Felt.ttf",32);
local label2 = cc.Label:createWithTTF("LONG","fonts/Marker Felt.ttf",32);
local label3 = cc.Label:createWithTTF("rất dài","fonts/Marker Felt.ttf",32);

label1 was an Japanese string which was rendered correctly, as was label2 which was an ANSI string. however, label3 wasn't rendered correctly. In fact, it was rendered like "rt dài".

I had tried to use other Unicode fonts which clearly has that character. Still, I couldn't get those character rendered correctly. What have I done wrong?


Solution

  • I have the same issue, and i have solved. I figure out that, the font file Marker Felt.tff include in cocos project is not unicode version. So after a while, i have found the unicode version of Marker Felt font in my Mac PC in: System/Library/Fonts/MarkerFelt.ttc

    MarkerFelt Unicode Image