Skip to content

Commit

Permalink
Don't update fonts more than once per frame
Browse files Browse the repository at this point in the history
  • Loading branch information
buthed010203 committed Jan 30, 2024
1 parent 7270dc9 commit fed63f3
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions extensions/freetype/src/arc/freetype/FreeTypeFontGenerator.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package arc.freetype;

import arc.*;
import arc.freetype.FreeType.*;
import arc.struct.Seq;
import arc.files.Fi;
Expand Down Expand Up @@ -696,7 +697,7 @@ public static class FreeTypeFontData extends FontData implements Disposable{
Stroker stroker;
PixmapPacker packer;
Seq<Glyph> glyphs;
private boolean dirty;
private boolean dirty, queued;

@Override
public Glyph getGlyph(char ch){
Expand Down Expand Up @@ -734,9 +735,12 @@ public Glyph getGlyph(char ch){
public void getGlyphs(GlyphRun run, CharSequence str, int start, int end, Glyph lastGlyph){
if(packer != null) packer.setPackToTexture(true); // All glyphs added after this are packed directly to the texture.
super.getGlyphs(run, str, start, end, lastGlyph);
if(dirty){
dirty = false;
packer.updateTextureRegions(regions, parameter.minFilter, parameter.magFilter, parameter.genMipMaps);
if(dirty && !queued){
queued = true;
Core.app.post(() -> {
dirty = queued = false;
packer.updateTextureRegions(regions, parameter.minFilter, parameter.magFilter, parameter.genMipMaps);
});
}
}

Expand Down

0 comments on commit fed63f3

Please sign in to comment.