FreeType generated font misses some characters with certain parameters
See original GitHub issueIssue details
When using the font provided below and one of the affected sizes some characters are not rendered.
Reproduction steps/code
- Generate new project with FreeType feature enabled
- Replace the body of your generated ApplicationAdapter class (MyGdxGame by default) with this:
private SpriteBatch batch;
private BitmapFont font;
@Override
public void create() {
batch = new SpriteBatch();
FreeTypeFontGenerator fontGenerator =
new FreeTypeFontGenerator(Gdx.files.internal("Carlito-Regular.ttf"));
FreeTypeFontGenerator.FreeTypeFontParameter parameter =
new FreeTypeFontGenerator.FreeTypeFontParameter();
// Rendered text depending on font size:
// 211: "abcde" as expected
// 212: "something strange bcde"
// 214 - 215: " b de"
// 216 - 262: " b d "
// 263: " bcde"
// 264 - 266: " b de"
// 267 - 268: " b d "
// 269: "abcde" as expected
parameter.size = 216;
font = fontGenerator.generateFont(parameter);
}
@Override
public void render() {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
font.draw(batch, "abcde", 5, 300);
batch.end();
}
@Override
public void dispose() {
batch.dispose();
font.dispose();
}
- Download Carlito font from https://fontlibrary.org/en/font/carlito and copy Carlito-Regular.ttf to your assets folder
- Set parameter.size to one of the values from the comments above
- Run and see a certain kind of unexpected render
Version of LibGDX and/or relevant dependencies
• LibGdx 1.9.8 • Windows and Android, other platforms not tested • Carlito-Regular.ttf font, other fonts not tested.
Please select the affected platforms
- [+] Android
- [?] iOS (robovm)
- [?] iOS (MOE)
- [?] HTML/GWT
- [+] Windows
- [?] Linux
- [?] MacOS
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
libGDX FressType font misses accented characters (french)
I'm stupid !!! the problem came from the file in which I read the texts: it was coded in ANSI, not in UTF-8...
Read more >Error Code Values - FreeType-2.12.1 API Reference
See the 'Error Enumerations' subsection how to automatically generate a list of ... 0x0C, "missing property" ) /* glyph/character errors */ FT_ERRORDEF_( ...
Read more >Base Interface - FreeType-2.12.1 API Reference
A handle to a FreeType library instance. Each 'library' is completely independent from the others; it is the 'root' of a set of...
Read more >Driver properties - FreeType-2.12.1 API Reference
A list of constants used for the hinting-engine property to select the hinting engine for CFF, Type 1, and CID fonts. values. FT_HINTING_FREETYPE....
Read more >TrueType Tables - FreeType-2.12.1 API Reference
This section contains definitions of some basic tables specific to ... For an OpenType variation font, the values of the following fields can...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Cool, glad you got it sorted. Sorry it took so long to reply. I’ve updated the wiki. Feel free to make wiki contributions! I believe anyone can edit the wiki, that is what it is there for.
BTW, you might look at DistanceFieldFont: https://github.com/libgdx/libgdx/wiki/Distance-field-fonts That wiki page looks outdated though, since it doesn’t even mention that you should use the shader created by DistanceFieldFont.createDistanceFieldShader.
Found a much more simple solution:
Then I guess it’s even better to mention this method on https://github.com/libgdx/libgdx/wiki/Gdx-freetype