mirror of
https://github.com/photonstorm/phaser
synced 2025-02-17 14:38:30 +00:00
Pixel accurate character data
This commit is contained in:
parent
eef67b6c11
commit
1579069c50
1 changed files with 26 additions and 4 deletions
|
@ -79,6 +79,8 @@ var GetBitmapTextSize = function (src, round, includeChars, out)
|
|||
|
||||
var glyph = null;
|
||||
|
||||
var align = src._align;
|
||||
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
|
||||
|
@ -381,10 +383,12 @@ var GetBitmapTextSize = function (src, round, includeChars, out)
|
|||
characters.push({
|
||||
char: text[i],
|
||||
code: charCode,
|
||||
x: xAdvance * sx,
|
||||
y: yAdvance * sy,
|
||||
w: charWidth * sx,
|
||||
h: lineHeight * sy
|
||||
x: (glyph.xOffset + xAdvance) * sx,
|
||||
y: (glyph.yOffset + yAdvance) * sy,
|
||||
w: glyph.width * sx,
|
||||
h: glyph.height * sy,
|
||||
line: currentLine,
|
||||
glyph: glyph
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -419,6 +423,24 @@ var GetBitmapTextSize = function (src, round, includeChars, out)
|
|||
shortestLine = currentLineWidth;
|
||||
}
|
||||
|
||||
// Adjust all of the character positions based on alignment
|
||||
if (align > 0)
|
||||
{
|
||||
for (var c = 0; c < characters.length; c++)
|
||||
{
|
||||
var currentChar = characters[c];
|
||||
|
||||
if (align === 1)
|
||||
{
|
||||
currentChar.x += ((longestLine - lineWidths[currentChar.line]) / 2);
|
||||
}
|
||||
else if (align === 2)
|
||||
{
|
||||
currentChar.x += (longestLine - lineWidths[currentChar.line]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var local = out.local;
|
||||
var global = out.global;
|
||||
var lines = out.lines;
|
||||
|
|
Loading…
Add table
Reference in a new issue