6

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

this works:

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

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

Bigfoot
  • 65
  • 5

1 Answers1

6

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.

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

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?

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

Community
  • 1
  • 1
TheWhiteLlama
  • 1,276
  • 1
  • 18
  • 31
  • Thanks for the reply @TheWhiteLlama was helpful. Do not give me the right solution, but gave me good ideas. The problem was in the font. For the moment at least Failed to generate a fountain. Here's an example: `FreeTypeFontGenerator generator = new FreeTypeFontGenerator (Gdx.files.internal ("font/ciril1.ttf")); BitmapFont font15 = generator.generateFont (11);` It gives me the error: Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: java.lang.NoSuchMethodError: com.badlogic.gdx.graphics.g2d.TextureAtlas.getRegions () Ljava / util / List; – Bigfoot Jul 26 '14 at 06:59
  • I had success with: `BitmapFont font = new BitmapFont (Gdx.files.internal ("font / font.fnt"), Gdx.files.internal ("font / font.png"), false); font.scale (-0.5f);` – Bigfoot Jul 26 '14 at 07:01