@@ -46,12 +46,12 @@ public static BitmapFont loadStructuredJson(FileHandle jsonFont, TextureRegion r
46
46
* a TextureRegion for the image the JSON needs; this region is often part of an atlas.
47
47
* @param jsonFont a FileHandle with the path to a Structured JSON Font (typically a .json file)
48
48
* @param region a TextureRegion, often part of a shared atlas, holding the image the JSON needs
49
- * @param integerPositions if true, positions will be rounded to integer positions; default to false
49
+ * @param flip true if this BitmapFont has been flipped for use with a y-down coordinate system
50
50
* @return a new BitmapFont loaded from {@code jsonFont}
51
51
*/
52
- public static BitmapFont loadStructuredJson (FileHandle jsonFont , TextureRegion region , boolean integerPositions ) {
53
- JsonFontData data = new JsonFontData (jsonFont );
54
- return new BitmapFont (data , region , integerPositions );
52
+ public static BitmapFont loadStructuredJson (FileHandle jsonFont , TextureRegion region , boolean flip ) {
53
+ JsonFontData data = new JsonFontData (jsonFont , null , flip );
54
+ return new BitmapFont (data , region , false );
55
55
}
56
56
57
57
/**
@@ -73,12 +73,12 @@ public static BitmapFont loadStructuredJson(FileHandle jsonFont, String imagePat
73
73
* a relative path (from {@code jsonFont}) to the necessary image file, with the path as a String.
74
74
* @param jsonFont a FileHandle with the path to a Structured JSON Font (typically a .json file)
75
75
* @param imagePath a String holding the relative path from {@code jsonFont} to the image file the JSON needs
76
- * @param integerPositions if true, positions will be rounded to integer positions; default to false
76
+ * @param flip true if this BitmapFont has been flipped for use with a y-down coordinate system
77
77
* @return a new BitmapFont loaded from {@code jsonFont}
78
78
*/
79
- public static BitmapFont loadStructuredJson (FileHandle jsonFont , String imagePath , boolean integerPositions ) {
80
- JsonFontData data = new JsonFontData (jsonFont , imagePath );
81
- return new BitmapFont (data , (TextureRegion ) null , integerPositions );
79
+ public static BitmapFont loadStructuredJson (FileHandle jsonFont , String imagePath , boolean flip ) {
80
+ JsonFontData data = new JsonFontData (jsonFont , imagePath , flip );
81
+ return new BitmapFont (data , (TextureRegion ) null , false );
82
82
}
83
83
84
84
/**
@@ -92,14 +92,18 @@ public JsonFontData() {
92
92
}
93
93
94
94
public JsonFontData (FileHandle jsonFont ) {
95
- super ();
96
- load (jsonFont , false );
95
+ this (jsonFont , null );
97
96
}
98
97
99
98
public JsonFontData (FileHandle jsonFont , String imagePath ) {
99
+ this (jsonFont , imagePath , false );
100
+ }
101
+
102
+ public JsonFontData (FileHandle jsonFont , String imagePath , boolean flip ) {
100
103
super ();
101
104
path = imagePath ;
102
- load (jsonFont , false );
105
+ this .flipped = flip ;
106
+ load (jsonFont , flip );
103
107
}
104
108
105
109
@ Override
@@ -174,12 +178,12 @@ else if (ch <= Character.MAX_VALUE)
174
178
}
175
179
if (planeBounds != null ) {
176
180
glyph .xoffset = round (planeBounds .getFloat ("left" , 0f ) * size );
177
- glyph .yoffset = round (size + planeBounds .getFloat ("bottom" , 0f ) * size );
181
+ glyph .yoffset = flip
182
+ ? round (-size - planeBounds .getFloat ("top" , 0f ) * size )
183
+ : round (size + planeBounds .getFloat ("bottom" , 0f ) * size );
178
184
} else {
179
185
glyph .xoffset = glyph .yoffset = 0 ;
180
186
}
181
-
182
- // if (glyph.width > 0 && glyph.height > 0) descent = Math.min(baseLine + glyph.yoffset, descent);
183
187
}
184
188
185
189
JsonValue kern = fnt .get ("kerning" );
0 commit comments