Phaser.LoaderParser = { bitmapFont: function (xml, baseTexture, xSpacing, ySpacing){ return this.xmlBitmapFont(xml, baseTexture, xSpacing, ySpacing); } , xmlBitmapFont: function (xml, baseTexture, xSpacing, ySpacing){ var data = { } ; var info = _AN_Call_getelementsbytagname('getElementsByTagName', xml, 'info')[0]; var common = _AN_Call_getelementsbytagname('getElementsByTagName', xml, 'common')[0]; data.font = _AN_Call_getattribute('getAttribute', info, 'face'); data.size = parseInt(_AN_Call_getattribute('getAttribute', info, 'size'), 10); data.lineHeight = parseInt(_AN_Call_getattribute('getAttribute', common, 'lineHeight'), 10) + ySpacing; data.chars = { } ; var letters = _AN_Call_getelementsbytagname('getElementsByTagName', xml, 'char'); for (var i = 0; i < _AN_Read_length('length', letters); i++ ){ var charCode = parseInt(_AN_Call_getattribute('getAttribute', letters[i], 'id'), 10); data.chars[charCode] = { x: parseInt(_AN_Call_getattribute('getAttribute', letters[i], 'x'), 10), y: parseInt(_AN_Call_getattribute('getAttribute', letters[i], 'y'), 10), width: parseInt(_AN_Call_getattribute('getAttribute', letters[i], 'width'), 10), height: parseInt(_AN_Call_getattribute('getAttribute', letters[i], 'height'), 10), xOffset: parseInt(_AN_Call_getattribute('getAttribute', letters[i], 'xoffset'), 10), yOffset: parseInt(_AN_Call_getattribute('getAttribute', letters[i], 'yoffset'), 10), xAdvance: parseInt(_AN_Call_getattribute('getAttribute', letters[i], 'xadvance'), 10) + xSpacing, kerning: { } } ; } var kernings = _AN_Call_getelementsbytagname('getElementsByTagName', xml, 'kerning'); for (i = 0; i < _AN_Read_length('length', kernings); i++ ){ var first = parseInt(_AN_Call_getattribute('getAttribute', kernings[i], 'first'), 10); var second = parseInt(_AN_Call_getattribute('getAttribute', kernings[i], 'second'), 10); var amount = parseInt(_AN_Call_getattribute('getAttribute', kernings[i], 'amount'), 10); data.chars[second].kerning[first] = amount; } return this.finalizeBitmapFont(baseTexture, data); } , jsonBitmapFont: function (json, baseTexture, xSpacing, ySpacing){ var data = { font: json.font.info._face, size: parseInt(json.font.info._size, 10), lineHeight: parseInt(json.font.common._lineHeight, 10) + ySpacing, chars: { } } ; json.font.chars["char"] .forEach(function parseChar(letter){ var charCode = parseInt(letter._id, 10); data.chars[charCode] = { x: parseInt(letter._x, 10), y: parseInt(letter._y, 10), width: parseInt(letter._width, 10), height: parseInt(letter._height, 10), xOffset: parseInt(letter._xoffset, 10), yOffset: parseInt(letter._yoffset, 10), xAdvance: parseInt(letter._xadvance, 10) + xSpacing, kerning: { } } ; } ); if (json.font.kernings && json.font.kernings.kerning) { json.font.kernings.kerning.forEach(function parseKerning(kerning){ data.chars[kerning._second].kerning[kerning._first] = parseInt(kerning._amount, 10); } ); } return this.finalizeBitmapFont(baseTexture, data); } , finalizeBitmapFont: function (baseTexture, bitmapFontData){ Object.keys(bitmapFontData.chars).forEach(function addTexture(charCode){ var letter = bitmapFontData.chars[charCode]; letter.texture = new PIXI.Texture(baseTexture, new Phaser.Rectangle(letter.x, letter.y, letter.width, letter.height)); } ); return bitmapFontData; } } ;