Skip to content

Commit 25f1ded

Browse files
committed
Started documenting Bitmap Font data structures.
1 parent a90e78d commit 25f1ded

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

src/gameobjects/bitmaptext/ParseRetroFont.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ var GetValue = require('../../utils/object/GetValue');
1515
*
1616
* @param {Phaser.Scene} scene - A reference to the Phaser Scene.
1717
* @param {Phaser.GameObjects.RetroFont.Config} config - The font configuration object.
18+
*
19+
* @return {object} [description]
1820
*/
1921
var ParseRetroFont = function (scene, config)
2022
{

src/gameobjects/bitmaptext/ParseXMLBitmapFont.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,43 @@ function getValue (node, attribute)
1414
return parseInt(node.getAttribute(attribute), 10);
1515
}
1616

17+
// TODO: These typedefs should be kept somewhere else.
18+
// TODO: Elaborate on the kerning property description.
19+
20+
/**
21+
* The font data for an individual character of a Bitmap Font.
22+
*
23+
* Describes the character's position, size, offset and kerning.
24+
*
25+
* @typedef {object} BitmapFontCharacterData
26+
*
27+
* @property {number} x - The x position of the character.
28+
* @property {number} y - The y position of the character.
29+
* @property {number} width - The width of the character.
30+
* @property {number} height - The height of the character.
31+
* @property {number} centerX - The center x position of the character.
32+
* @property {number} centerY - The center y position of the character.
33+
* @property {number} xOffset - The x offset of the character.
34+
* @property {number} yOffset - The y offset of the character.
35+
* @property {object} data - Extra data for the character.
36+
* @property {object} kerning - Kerning values. [description]
37+
*/
38+
1739
/**
40+
* Bitmap Font data that can be used by a BitmapText Game Object.
41+
*
42+
* @typedef {object} BitmapFontData
43+
*
44+
* @property {string} font - The name of the font.
45+
* @property {number} size - The size of the font.
46+
* @property {number} lineHeight - The line height of the font.
47+
* @property {boolean} retroFont - Whether this font is a retro font (monospace).
48+
* @property {Object.<number, BitmapFontCharacterData>} chars - The character data of the font, keyed by character code. Each character datum includes a position, size, offset and more.
49+
*/
50+
51+
/**
52+
* Parse an XML font so you can pass it to the BitmapText constructor and create a BitmapText object.
53+
*
1854
* @function ParseXMLBitmapFont
1955
* @since 3.0.0
2056
* @private
@@ -23,6 +59,8 @@ function getValue (node, attribute)
2359
* @param {integer} [xSpacing=0] - The x-axis spacing to add between each letter.
2460
* @param {integer} [ySpacing=0] - The y-axis spacing to add to the line height.
2561
* @param {Phaser.Textures.Frame} [frame] - The texture frame to take into account while parsing.
62+
*
63+
* @return {BitmapFontData} The parsed Bitmap Font data.
2664
*/
2765
var ParseXMLBitmapFont = function (xml, xSpacing, ySpacing, frame)
2866
{

0 commit comments

Comments
 (0)