mirror of
https://github.com/photonstorm/phaser
synced 2024-11-10 23:24:41 +00:00
Added a letterSpacing property to BitmapText
This commit is contained in:
parent
43ea5f239c
commit
2ec70cac48
5 changed files with 14 additions and 13 deletions
|
@ -19,7 +19,7 @@ being passed to the simulation. The default value is 1 to remain consistent with
|
|||
* HTML5AudioSound.setVolume is a chainable way to set the volume of a single Sound instance.
|
||||
* HTML5AudioSound.setSeek is a chainable way to set seek to a point of a single Sound instance.
|
||||
* HTML5AudioSound.setLoop is a chainable way to set the loop state of a single Sound instance.
|
||||
* A new property was added to BitmapText, 'kerning' which accepts a positive or negative number to add/reduce spacing in between characters.
|
||||
* A new property was added to BitmapText, 'letterSpacing' which accepts a positive or negative number to add/reduce spacing in between characters.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ var GetBitmapTextSize = function (src, round)
|
|||
|
||||
var chars = src.fontData.chars;
|
||||
var lineHeight = src.fontData.lineHeight;
|
||||
var kerning = src.kerning;
|
||||
var letterSpacing = src.letterSpacing;
|
||||
|
||||
var xAdvance = 0;
|
||||
var yAdvance = 0;
|
||||
|
@ -99,7 +99,7 @@ var GetBitmapTextSize = function (src, round)
|
|||
bh = gh;
|
||||
}
|
||||
|
||||
xAdvance += glyph.xAdvance + kerning;
|
||||
xAdvance += glyph.xAdvance + letterSpacing;
|
||||
indexCount += 1;
|
||||
lastGlyph = glyph;
|
||||
lastCharCode = charCode;
|
||||
|
|
|
@ -33,7 +33,7 @@ var Render = require('./BitmapTextRender');
|
|||
* @property {string} font - [description]
|
||||
* @property {string} text - [description]
|
||||
* @property {number} fontSize - [description]
|
||||
* @property {number} kerning - [description]
|
||||
* @property {number} letterSpacing - Adds/Removes spacing between characters
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -131,13 +131,14 @@ var BitmapText = new Class({
|
|||
this.fontSize = size || this.fontData.size;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
* Adds/Removes spacing between characters
|
||||
* Can be a negative or positive number
|
||||
*
|
||||
* @name Phaser.GameObjects.BitmapText#kerning
|
||||
* @name Phaser.GameObjects.BitmapText#letterSpacing
|
||||
* @type {number}
|
||||
* @since 3.4.0
|
||||
*/
|
||||
this.kerning = 0;
|
||||
this.letterSpacing = 0;
|
||||
|
||||
this.setTexture(entry.texture, entry.frame);
|
||||
this.setPosition(x, y);
|
||||
|
|
|
@ -34,7 +34,7 @@ var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage,
|
|||
|
||||
var chars = src.fontData.chars;
|
||||
var lineHeight = src.fontData.lineHeight;
|
||||
var kerning = src.kerning;
|
||||
var letterSpacing = src.letterSpacing;
|
||||
|
||||
var xAdvance = 0;
|
||||
var yAdvance = 0;
|
||||
|
@ -141,7 +141,7 @@ var BitmapTextCanvasRenderer = function (renderer, src, interpolationPercentage,
|
|||
x *= scale;
|
||||
y *= scale;
|
||||
|
||||
xAdvance += glyph.xAdvance + kerning;
|
||||
xAdvance += glyph.xAdvance + letterSpacing;
|
||||
indexCount += 1;
|
||||
lastGlyph = glyph;
|
||||
lastCharCode = charCode;
|
||||
|
|
|
@ -946,7 +946,7 @@ var TextureTintPipeline = new Class({
|
|||
var rotation = -bitmapText.rotation;
|
||||
var scaleX = bitmapText.scaleX;
|
||||
var scaleY = bitmapText.scaleY;
|
||||
var kerning = bitmapText.kerning;
|
||||
var letterSpacing = bitmapText.letterSpacing;
|
||||
var sr = Math.sin(rotation);
|
||||
var cr = Math.cos(rotation);
|
||||
var sra = cr * scaleX;
|
||||
|
@ -1006,7 +1006,7 @@ var TextureTintPipeline = new Class({
|
|||
x += (kerningOffset !== undefined) ? kerningOffset : 0;
|
||||
}
|
||||
|
||||
xAdvance += glyph.xAdvance + kerning;
|
||||
xAdvance += glyph.xAdvance + letterSpacing;
|
||||
indexCount += 1;
|
||||
lastGlyph = glyph;
|
||||
lastCharCode = charCode;
|
||||
|
@ -1179,7 +1179,7 @@ var TextureTintPipeline = new Class({
|
|||
var rotation = -bitmapText.rotation;
|
||||
var scaleX = bitmapText.scaleX;
|
||||
var scaleY = bitmapText.scaleY;
|
||||
var kerning = bitmapText.kerning;
|
||||
var letterSpacing = bitmapText.letterSpacing;
|
||||
var sr = Math.sin(rotation);
|
||||
var cr = Math.cos(rotation);
|
||||
var sra = cr * scaleX;
|
||||
|
@ -1254,7 +1254,7 @@ var TextureTintPipeline = new Class({
|
|||
x += (kerningOffset !== undefined) ? kerningOffset : 0;
|
||||
}
|
||||
|
||||
xAdvance += glyph.xAdvance + kerning;
|
||||
xAdvance += glyph.xAdvance + letterSpacing;
|
||||
indexCount += 1;
|
||||
lastGlyph = glyph;
|
||||
lastCharCode = charCode;
|
||||
|
|
Loading…
Reference in a new issue