且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

libgdx 绘制汉字

更新时间:2023-01-30 22:19:09

转到 http://www.angelcode.com/products/bmfont/ 并获取 BMFont 并使用它来查看您的字体.您还可以使用它预生成 libgdx 位图字体文件.问题是您的字体不是 unicode 字体.

Go to http://www.angelcode.com/products/bmfont/ and get BMFont and use it to look at your font. You can also pregenerate libgdx bitmap font files with it. The problem is that your font is not a unicode font.

当您输入 Java 代码时,好"符号被转换为值 U+597D.您使用的字体 ttf 文件是老式的非 unicode 字体.这些旧字体文件的工作方式是用不同的图片替换像a"这样的字母.a"是 U+61.所以在你的程序中,字母a"被转换为 U+61,它映射到一个汉字符号,但值为 U+597D 的好"没有.

When you are typing Java code the "好" symbol is translated to the value U+597D. The font ttf file you are using is an old-school non-unicode font. The way these older font files work is that they replace a letter like "a" with a different picture. "a" is U+61. So in your program the letter "a" is converted to U+61 which maps to a chinese character symbol but "好" with a value of U+597D does not.

您可以继续使用您的字体并查找每个字符的位置,以便使用正确的数字.不要使用a",而是使用 (char)0x61 之类的东西,这样它就不会那么混乱了.或者……

You can either continue to use your font and look up the position of every character so that you can use the correct number. Don't use "a" instead use something like (char)0x61 so it is a little less confusing. Or...

只需在 U+597D 处获取包含好"符号的有效 unicode 字体即可.

Just get a valid unicode font that contains the "好" symbol at U+597D.