Skip to content

Commit

Permalink
I... wasn't resizing the distance field.
Browse files Browse the repository at this point in the history
This screwed up all the distance field display code... It was an easy fix.
  • Loading branch information
tommyettinger committed May 12, 2024
1 parent 3b5b46f commit c458206
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,23 @@

public class IncongruityFWTest extends ApplicationAdapter {
Stage stage;

Font[] fonts;
@Override
public void create() {
stage = new Stage();
Skin skin = new FreeTypistSkin(Gdx.files.internal("uiskin2.json"));
Table root = new Table(skin);

FileHandle[] jsonFiles = Gdx.files.local("knownFonts/fontwriter").list(".json");
Font[] fonts = new Font[jsonFiles.length];
fonts = new Font[jsonFiles.length];
BitmapFont[] bitmapFonts = new BitmapFont[jsonFiles.length];
for (int i = 0; i < jsonFiles.length; i++) {
fonts[i] = new Font(jsonFiles[i].path(), true);
fonts[i].scaleTo(fonts[i].originalCellWidth * 24f / fonts[i].originalCellHeight, 24f);
bitmapFonts[i] = BitmapFontSupport.loadStructuredJson(jsonFiles[i], jsonFiles[i].nameWithoutExtension() + ".png");
if(fonts[i].distanceField == Font.DistanceFieldType.STANDARD)
bitmapFonts[i] = BitmapFontSupport.loadStructuredJson(jsonFiles[i], jsonFiles[i].nameWithoutExtension() + ".png");
else
bitmapFonts[i] = BitmapFontSupport.loadStructuredJson(jsonFiles[i].sibling(jsonFiles[i].name().replaceAll("-[a-z]+\\.json", "-standard.json")), jsonFiles[i].name().replaceAll("-[a-z]+\\.json", "-standard.png"));
bitmapFonts[i].setUseIntegerPositions(false);
bitmapFonts[i].getData().setScale(24f / bitmapFonts[i].getLineHeight());
}
Expand Down Expand Up @@ -96,6 +99,7 @@ public void render() {

@Override
public void resize(int width, int height) {
for(Font f : fonts) f.resizeDistanceField(width, height);
}

@Override
Expand Down

0 comments on commit c458206

Please sign in to comment.