Skip to content

Commit fcaa6ce

Browse files
committed
Merge pull request phaserjs#1912 from Feenposhleen/feature/fixing-json-fonts
Improving JSON BitmapText implementation
2 parents 7271eb5 + 795a7c8 commit fcaa6ce

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

src/gameobjects/BitmapText.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
* Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner
2525
* Littera (Web-based, free): http://kvazars.com/littera/
2626
*
27-
* For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of running a valid XML file through the popular X2JS library.
27+
* For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of
28+
* converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson
2829
*
2930
* @class Phaser.BitmapText
3031
* @constructor

src/loader/LoaderParser.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Phaser.LoaderParser = {
9494
jsonBitmapFont: function (json, baseTexture, xSpacing, ySpacing) {
9595

9696
var data = {
97-
font: json.font.info._font,
97+
font: json.font.info._face,
9898
size: parseInt(json.font.info._size, 10),
9999
lineHeight: parseInt(json.font.common._lineHeight, 10) + ySpacing,
100100
chars: {}
@@ -120,15 +120,19 @@ Phaser.LoaderParser = {
120120

121121
);
122122

123-
json.font.kernings.kerning.forEach(
123+
if (json.font.kernings && json.font.kernings.kerning) {
124124

125-
function parseKerning(kerning) {
125+
json.font.kernings.kerning.forEach(
126126

127-
data.chars[kerning._second].kerning[kerning._first] = parseInt(kerning._amount, 10);
127+
function parseKerning(kerning) {
128128

129-
}
129+
data.chars[kerning._second].kerning[kerning._first] = parseInt(kerning._amount, 10);
130130

131-
);
131+
}
132+
133+
);
134+
135+
}
132136

133137
return this.finalizeBitmapFont(baseTexture, data);
134138

0 commit comments

Comments
 (0)