Merge pull request #2915 from jaredbrookswhite/master

Added Support for HDPI Displays to atlas based BitmapText
This commit is contained in:
Richard Davey 2016-12-12 16:26:33 +00:00 committed by GitHub
commit 48f9c126dc
5 changed files with 33 additions and 33 deletions

View file

@ -7,7 +7,7 @@
*
* Phaser - http://phaser.io
*
* v2.7.2 "2016-12-06" - Built: Tue Dec 06 2016 23:48:14
* v2.7.2 "2016-12-06" - Built: Mon Dec 12 2016 07:00:15
*
* By Richard Davey http://www.photonstorm.com @photonstorm
*
@ -71426,11 +71426,11 @@ Phaser.Cache.prototype = {
if (atlasType === 'json')
{
obj.font = Phaser.LoaderParser.jsonBitmapFont(atlasData, obj.base, xSpacing, ySpacing);
obj.font = Phaser.LoaderParser.jsonBitmapFont(atlasData, obj.base, xSpacing, ySpacing, false, this.game.resolution);
}
else
{
obj.font = Phaser.LoaderParser.xmlBitmapFont(atlasData, obj.base, xSpacing, ySpacing);
obj.font = Phaser.LoaderParser.xmlBitmapFont(atlasData, obj.base, xSpacing, ySpacing, false, this.game.resolution);
}
this._cache.bitmapFont[key] = obj;
@ -71482,12 +71482,12 @@ Phaser.Cache.prototype = {
if (dataType === 'json')
{
fontData = this.getJSON(dataKey);
obj.font = Phaser.LoaderParser.jsonBitmapFont(fontData, obj.base, xSpacing, ySpacing, frame);
obj.font = Phaser.LoaderParser.jsonBitmapFont(fontData, obj.base, xSpacing, ySpacing, frame, this.game.resolution);
}
else
{
fontData = this.getXML(dataKey);
obj.font = Phaser.LoaderParser.xmlBitmapFont(fontData, obj.base, xSpacing, ySpacing, frame);
obj.font = Phaser.LoaderParser.xmlBitmapFont(fontData, obj.base, xSpacing, ySpacing, frame, this.game.resolution);
}
this._cache.bitmapFont[key] = obj;
@ -76217,7 +76217,7 @@ Phaser.LoaderParser = {
* @param {Phaser.Frame} [frame] - Optional Frame, if this font is embedded in a texture atlas.
* @return {object} The parsed Bitmap Font data.
*/
xmlBitmapFont: function (xml, baseTexture, xSpacing, ySpacing, frame) {
xmlBitmapFont: function (xml, baseTexture, xSpacing, ySpacing, frame, resolution) {
var data = {};
var info = xml.getElementsByTagName('info')[0];
@ -76242,9 +76242,9 @@ Phaser.LoaderParser = {
y: y + parseInt(letters[i].getAttribute('y'), 10),
width: parseInt(letters[i].getAttribute('width'), 10),
height: parseInt(letters[i].getAttribute('height'), 10),
xOffset: parseInt(letters[i].getAttribute('xoffset'), 10),
yOffset: parseInt(letters[i].getAttribute('yoffset'), 10),
xAdvance: parseInt(letters[i].getAttribute('xadvance'), 10) + xSpacing,
xOffset: parseInt(letters[i].getAttribute('xoffset'), 10) / resolution,
yOffset: parseInt(letters[i].getAttribute('yoffset'), 10) / resolution,
xAdvance: (parseInt(letters[i].getAttribute('xadvance'), 10) + xSpacing) / resolution,
kerning: {}
};
}
@ -76255,7 +76255,7 @@ Phaser.LoaderParser = {
{
var first = parseInt(kernings[i].getAttribute('first'), 10);
var second = parseInt(kernings[i].getAttribute('second'), 10);
var amount = parseInt(kernings[i].getAttribute('amount'), 10);
var amount = parseInt(kernings[i].getAttribute('amount'), 10) / resolution;
data.chars[second].kerning[first] = amount;
}
@ -76298,9 +76298,9 @@ Phaser.LoaderParser = {
y: 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,
xOffset: parseInt(letter._xoffset, 10) / resolution,
yOffset: parseInt(letter._yoffset, 10) / resolution,
xAdvance: (parseInt(letter._xadvance, 10) + xSpacing) / resolution,
kerning: {}
};
}
@ -76313,7 +76313,7 @@ Phaser.LoaderParser = {
function parseKerning(kerning) {
data.chars[kerning._second].kerning[kerning._first] = parseInt(kerning._amount, 10);
data.chars[kerning._second].kerning[kerning._first] = parseInt(kerning._amount, 10) / resolution;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -526,11 +526,11 @@ Phaser.Cache.prototype = {
if (atlasType === 'json')
{
obj.font = Phaser.LoaderParser.jsonBitmapFont(atlasData, obj.base, xSpacing, ySpacing);
obj.font = Phaser.LoaderParser.jsonBitmapFont(atlasData, obj.base, xSpacing, ySpacing, false, this.game.resolution);
}
else
{
obj.font = Phaser.LoaderParser.xmlBitmapFont(atlasData, obj.base, xSpacing, ySpacing);
obj.font = Phaser.LoaderParser.xmlBitmapFont(atlasData, obj.base, xSpacing, ySpacing, false, this.game.resolution);
}
this._cache.bitmapFont[key] = obj;
@ -582,12 +582,12 @@ Phaser.Cache.prototype = {
if (dataType === 'json')
{
fontData = this.getJSON(dataKey);
obj.font = Phaser.LoaderParser.jsonBitmapFont(fontData, obj.base, xSpacing, ySpacing, frame);
obj.font = Phaser.LoaderParser.jsonBitmapFont(fontData, obj.base, xSpacing, ySpacing, frame, this.game.resolution);
}
else
{
fontData = this.getXML(dataKey);
obj.font = Phaser.LoaderParser.xmlBitmapFont(fontData, obj.base, xSpacing, ySpacing, frame);
obj.font = Phaser.LoaderParser.xmlBitmapFont(fontData, obj.base, xSpacing, ySpacing, frame, this.game.resolution);
}
this._cache.bitmapFont[key] = obj;

View file

@ -38,7 +38,7 @@ Phaser.LoaderParser = {
* @param {Phaser.Frame} [frame] - Optional Frame, if this font is embedded in a texture atlas.
* @return {object} The parsed Bitmap Font data.
*/
xmlBitmapFont: function (xml, baseTexture, xSpacing, ySpacing, frame) {
xmlBitmapFont: function (xml, baseTexture, xSpacing, ySpacing, frame, resolution) {
var data = {};
var info = xml.getElementsByTagName('info')[0];
@ -63,9 +63,9 @@ Phaser.LoaderParser = {
y: y + parseInt(letters[i].getAttribute('y'), 10),
width: parseInt(letters[i].getAttribute('width'), 10),
height: parseInt(letters[i].getAttribute('height'), 10),
xOffset: parseInt(letters[i].getAttribute('xoffset'), 10),
yOffset: parseInt(letters[i].getAttribute('yoffset'), 10),
xAdvance: parseInt(letters[i].getAttribute('xadvance'), 10) + xSpacing,
xOffset: parseInt(letters[i].getAttribute('xoffset'), 10) / resolution,
yOffset: parseInt(letters[i].getAttribute('yoffset'), 10) / resolution,
xAdvance: (parseInt(letters[i].getAttribute('xadvance'), 10) + xSpacing) / resolution,
kerning: {}
};
}
@ -76,7 +76,7 @@ Phaser.LoaderParser = {
{
var first = parseInt(kernings[i].getAttribute('first'), 10);
var second = parseInt(kernings[i].getAttribute('second'), 10);
var amount = parseInt(kernings[i].getAttribute('amount'), 10);
var amount = parseInt(kernings[i].getAttribute('amount'), 10) / resolution;
data.chars[second].kerning[first] = amount;
}
@ -119,9 +119,9 @@ Phaser.LoaderParser = {
y: 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,
xOffset: parseInt(letter._xoffset, 10) / resolution,
yOffset: parseInt(letter._yoffset, 10) / resolution,
xAdvance: (parseInt(letter._xadvance, 10) + xSpacing) / resolution,
kerning: {}
};
}
@ -134,7 +134,7 @@ Phaser.LoaderParser = {
function parseKerning(kerning) {
data.chars[kerning._second].kerning[kerning._first] = parseInt(kerning._amount, 10);
data.chars[kerning._second].kerning[kerning._first] = parseInt(kerning._amount, 10) / resolution;
}