From 10b21c0658be721b540fd0d43207805f8dd1d316 Mon Sep 17 00:00:00 2001 From: raeleus Date: Sat, 20 Apr 2024 05:27:32 -0700 Subject: [PATCH] Fix incorrect glyph page index in FreeTypeFontGenerator (#7357) * Fixed assigning glyphs the wrong page index. * Avoid collisions with glyph hash codes. --- .../gdx/graphics/g2d/freetype/FreeTypeFontGenerator.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/extensions/gdx-freetype/src/com/badlogic/gdx/graphics/g2d/freetype/FreeTypeFontGenerator.java b/extensions/gdx-freetype/src/com/badlogic/gdx/graphics/g2d/freetype/FreeTypeFontGenerator.java index 4472ff7c8f3..dee52891062 100644 --- a/extensions/gdx-freetype/src/com/badlogic/gdx/graphics/g2d/freetype/FreeTypeFontGenerator.java +++ b/extensions/gdx-freetype/src/com/badlogic/gdx/graphics/g2d/freetype/FreeTypeFontGenerator.java @@ -598,8 +598,9 @@ public FreeTypeBitmapFontData generateData (FreeTypeFontParameter parameter, Fre } } - Rectangle rect = packer.pack(mainPixmap); - glyph.page = packer.getPages().size - 1; // Glyph is always packed into the last page for now. + String pixmapName = glyph.hashCode() + "_" + glyph.id; + Rectangle rect = packer.pack(pixmapName, mainPixmap); + glyph.page = packer.getPageIndex(pixmapName); glyph.srcX = (int)rect.x; glyph.srcY = (int)rect.y;