Libgdx with Cyrillic

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

it works:

System.out.println(""); 

but shows nothing:

 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 would be glad if someone has a solution, many, many will be grateful.

+6
source share
1 answer

I think there may be some additional information that is missing. Aslong libgdx uses bitmap fonts to display all text. (TextField is part of scene2dui, I think) By default, Bitmap-Generation / Default-libgdx-font can contain only ASCII characters and some additional ones, but without Cyrillic.

That is why you will need to provide Cyrillic characters manually in your BitmapFont, and also be able to display them. The relatively new libgdx extension for creating BitmapFonts from .ttf-Asset can also generate Cyrillic characters if you define them: TrueType fonts in libGDX

Then you can also use them in your game / application, since you also define a newly created font for your TextField / scene2dui style: Libgdx Scene2d - adding an add-on to an actor (TextField)?

Here are also some tests in libgdx-repo. Look there if there is a problem with a misunderstanding: https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests/src/com/badlogic/gdx/tests/extensions/InternationalFontsTest.java Hope this helps ! greetings

+6
source

Source: https://habr.com/ru/post/972762/


All Articles