显示西里尔字母的 libgdx

libgdx with displaying Cyrillic(显示西里尔字母的 libgdx)
本文介绍了显示西里尔字母的 libgdx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

libgdx 显示西里尔字母时出现以下问题.我举个例子:

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

这行得通:

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

但它什么也没显示:

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

然后尝试了,没有成功.

And tried without success.

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.

推荐答案

我认为可能缺少一些额外的信息.只要 libgdx 使用 Bitmap-fonts 来显示所有类型的文本.(我认为TextField是scene2dui的一部分)默认的 Bitmap-Generation/Default-libgdx-font 可能只包含 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 - 设置演员 (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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)