2
\$\begingroup\$

Please, help me with my problem. The character is rendering incorrectly. R symbol looks like N. Also, the symbol ! is not drawn. But this problem was found only on Xiaomi Mi A1. On other devices, such a problem is not detected. enter image description here

Font generates like so:

public enum Font {

    FONT_REGULAR (Res.FONT_REGULAR_PATH),
    FONT_LIGHT (Res.FONT_LIGHT_PATH),
    RUSSO_ONE_REGULAR (Res.RUSSO_ONE_REGULAR),
    ;

    BitmapFont font;
    String path;

    Font (String path) {
        this.path = path;
    }

    public BitmapFont get (float size) {
        final String FONT_CHARACTERS = "абвгдеёжзийклмнопрстуфхцчшщъыьэюяєїіАБВГДЕЁЖЗИЙКЛМ" +
                "НОПРСТУФХЦЧШЩЪЫЬЭЮЯЄЇІáabcdeéfghiíjklmnoópqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123" +
                "456789][_!$%#@|\\/?-+=()*&.:;,{}\"´`'<>°©™";
        FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal(path));
        FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
        parameter.size = (int) size;
        if (size < 1) parameter.size = 1;
        parameter.characters = FONT_CHARACTERS;
        BitmapFont font = generator.generateFont(parameter);
        font.setColor(Color.WHITE);
        generator.dispose();
        return font;
    }

}

I use this font.

How can I fix it?

\$\endgroup\$
3
  • \$\begingroup\$ Some things to try: parameter.flip = true (see if it is still weird upside down); parameter.genMipMaps = true; parameter.minFilter = TextureFilter.MipMapLinearLinear (see if MipMap change anything); parameter.mono = true (disable font smoothing). These will probably not change anything but if they do maybe they can lead you to a solution. \$\endgroup\$
    – Charanor
    Commented Mar 12, 2018 at 11:23
  • \$\begingroup\$ @Charanor, thank you! I'll try your recommendations. \$\endgroup\$ Commented Mar 12, 2018 at 11:57
  • \$\begingroup\$ @Charanor your recommendations don't solve this problem. I guess, this problem relates to Android version (8.0). I tried to launch my game on Nokia 6 (with same android version) and this problem also appears. \$\endgroup\$ Commented Mar 12, 2018 at 13:18

1 Answer 1

2
\$\begingroup\$

I found solution!

I just added this:

FreeTypeFontGenerator.setMaxTextureSize(2048);

So, full code looks like so:

public BitmapFont get (float size) {
    final String FONT_CHARACTERS = "абвгдеёжзийклмнопрстуфхцчшщъыьэюяєїіАБВГДЕЁЖЗИЙКЛМ" +
            "НОПРСТУФХЦЧШЩЪЫЬЭЮЯЄЇІáabcdeéfghiíjklmnoópqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123" +
            "456789][_!$%#@|\\/?-+=()*&.:;,{}\"´`'<>°©™";

    FreeTypeFontGenerator.setMaxTextureSize(2048);

    FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal(path));
    FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();

    parameter.size = (int) size;
    if (size < 1) parameter.size = 1;
    parameter.characters = FONT_CHARACTERS;
    BitmapFont font = generator.generateFont(parameter);
    font.setColor(Color.WHITE);
    generator.dispose();
    return font;
}
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .