libgdx显示西里尔文 [英] libgdx with displaying Cyrillic

查看:151
本文介绍了libgdx显示西里尔文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的libgdx显示了西里尔文件有以下问题。
我举一个例子:

I have the following problem with libgdx displaying Cyrillic. I give an example:

这样做:

System.out.println("абцдеф");

但没有显示任何内容:

field = new TextField("абцдеф", style);

尝试没有成功。

try {
    mmm = new String(t.getBytes(), "UTF-8");
} catch (UnsupportedEncodingException e) {
    // Will it ever be thrown?
}
field = new TextField(mmm, style);

如果有人有解决方案,我会很高兴,很多人会很感激。 >

I'll be glad if someone has a solution, many, many will be grateful.

推荐答案

我认为可能还有一些其他信息丢失。 Aslong libgdx正在使用Bitmap-fonts显示所有类型的文本。 (TextField是我认为的scene2dui的一部分)
默认的Bitmap-Generation / Default-libgdx字体可能只包含ASCII代码字符和一些额外的但不是西里尔字母。

I think there might be some additional information that is missing. Aslong libgdx is using Bitmap-fonts for displaying all kind of text. (TextField is a part of scene2dui I think) The default Bitmap-Generation / Default-libgdx-font might only contain ASCII-code characters and some additional, but no cyrillic.

这就是为什么你必须在BitmapFont手动提供西里尔字符,以便能够显示它们。
如果定义它们,用于生成.ttf-Asset中的BitmapFonts的相对较新的libgdx扩展也可以生成西里尔字符:
libGDX中的TrueType字体

That's why you would have to provide cyrillic chars manually in your BitmapFont aswell to be able to display them. The relatively new libgdx-extension for generating BitmapFonts out of an .ttf-Asset can also generate the cyrillic characters if you define them: TrueType Fonts in libGDX

然后,您还可以在游戏/应用程序中使用它们您还可以为TextField / scene2dui样式定义新生成的字体:
Libgdx Scene2d - 设置actor(TextField)填充?

Then you'll be also able to use them in your game/app aslong you also define the newly generated font for your TextField / scene2dui style: Libgdx Scene2d - Set actor ( TextField ) padding?

这里也是libgdx-repo中的一些测试。看看那里是否有一个错误的想法: https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests/src/com/badlogic/gdx/tests/extensions/InternationalFontsTest.java
我希望这有帮助!
欢呼

Here are also some tests in the libgdx-repo. Have a look there if there's a matter of missunderstanding: https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests/src/com/badlogic/gdx/tests/extensions/InternationalFontsTest.java I hope this helps! cheers

这篇关于libgdx显示西里尔文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆