Skip to content

Commit

Permalink
Improved on Skin serializer for BitmapFont (libgdx#7073)
Browse files Browse the repository at this point in the history
* Improved on Skin serializer for BitmapFont

Added "integerPositions" boolean value which sets "useIntegerPositions" for BitmapFont. Also changed scaledSize from int to float as it offers more precision this way.

* Fixed string json for previous commit

Forgot to change string in previous commit, fixed now.

* Another fix for previous commit

Forgot to change json type from int to float. Fixed now.

* Renamed 'integerPositions' to 'useIntegerPositions' as suggested by crykn.
  • Loading branch information
Betalord authored Mar 10, 2023
1 parent 2b92b3f commit 83e2980
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gdx/src/com/badlogic/gdx/scenes/scene2d/ui/Skin.java
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,10 @@ private void readNamedObjects (Json json, Class type, JsonValue valueMap) {
json.setSerializer(BitmapFont.class, new ReadOnlySerializer<BitmapFont>() {
public BitmapFont read (Json json, JsonValue jsonData, Class type) {
String path = json.readValue("file", String.class, jsonData);
int scaledSize = json.readValue("scaledSize", int.class, -1, jsonData);
float scaledSize = json.readValue("scaledSize", float.class, -1f, jsonData);
Boolean flip = json.readValue("flip", Boolean.class, false, jsonData);
Boolean markupEnabled = json.readValue("markupEnabled", Boolean.class, false, jsonData);
Boolean useIntegerPositions = json.readValue("useIntegerPositions", Boolean.class, true, jsonData);

FileHandle fontFile = skinFile.parent().child(path);
if (!fontFile.exists()) fontFile = Gdx.files.internal(path);
Expand All @@ -560,6 +561,7 @@ public BitmapFont read (Json json, JsonValue jsonData, Class type) {
}
}
font.getData().markupEnabled = markupEnabled;
font.setUseIntegerPositions(useIntegerPositions);
// Scaled size is the desired cap height to scale the font to.
if (scaledSize != -1) font.getData().setScale(scaledSize / font.getCapHeight());
return font;
Expand Down

0 comments on commit 83e2980

Please sign in to comment.