0
\$\begingroup\$

I use libgdx and I draw some text with BitmapFont, it works, but on some devices with Android 5.1 game draw only numbers and punctuation symbols, without any text.

I tried two ways:

1) Font Generator:

    mFontGenerator = new FreeTypeFontGenerator(Gdx.files.internal(fontName));
    mFontParameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
    mFontParameter.characters = Font.FONT_CHARS;
    mFontParameter.size = mSizePixels;
    mFontParameter.color = mTextColor;
    mFontParameter.borderWidth = mBorderWidth;
    mFontParameter.borderColor = mBorderColor;
    mBitmapFont = mFontGenerator.generateFont(mFontParameter);
    mBitmapFont.setUseIntegerPositions(false);
    mBitmapFont.getData().setScale(mTextScale);
    mFontGenerator.dispose();

2) Font, created in Hiero:

    mBitmapFont = new BitmapFont(Gdx.files.internal(fontName));
    mBitmapFont.setUseIntegerPositions(false);
    mBitmapFont.getData().setScale(mTextScale);
    mBitmapFont.setColor(mTextColor);

Draw code is the same for both ways:

@Override
public void draw(SpriteBatch spriteBatch) {
    mBitmapFont.draw(spriteBatch, mText, mPositionX, mPositionY);
}

Both ways works on tablet with Android 7.1.1 and even on phone with Android 2.3.5, but on two devices with Android 5.1 I can see just numbers, no letters.

Thanks for any help!

\$\endgroup\$
2
  • \$\begingroup\$ If you remove all settings (so no useInteger, setScale, setColor) is it still the same? Also, what characters do FONT_CHARS contain? \$\endgroup\$
    – Charanor
    Jan 29, 2018 at 10:34
  • \$\begingroup\$ @Charanor, yes, result is the same. FONT_CHARS - all symbols that I need to draw (alphabet, numbers), but it need only for FontGenerator and like I said both ways work on Android 7.1 and both ways don`t work for Android 5.1 \$\endgroup\$
    – SlowAR
    Jan 29, 2018 at 11:48

1 Answer 1

0
\$\begingroup\$

The problem was with localization bundle files charset: files need have UTF-8, but by default in Android Studio it was windows-1251. To change it go to File -> Settings -> Editor -> File Encodings, press plus and choose localization bundle files, after choose UTF-8 at bottom, press OK

\$\endgroup\$

You must log in to answer this question.

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