import Texture from "../textures/Texture"; import TextOptions from "./TextOptions"; import TextFormat from "./TextFormat"; import ITextCompositor from "./ITextCompositor"; import BitmapCharLocation from "./BitmapCharLocation"; import BitmapChar from "./BitmapChar"; import MeshStyle from "../styles/MeshStyle"; import Sprite from "../display/Sprite"; import MeshBatch from "../display/MeshBatch"; import Vector from "openfl/Vector"; declare namespace starling.text { /** * The BitmapFont class parses bitmap font files and arranges the glyphs * * in the form of a text. * * * * The class parses the XML format as it is used in the * * AngelCode Bitmap Font Generator or * * the Glyph Designer. * * This is what the file format looks like: * * * *
* * <font> * * <info face="BranchingMouse" size="40" /> * * <common lineHeight="40" /> * * <pages> <!-- currently, only one page is supported --> * * <page id="0" file="texture.png" /> * * </pages> * * <chars> * * <char id="32" x="60" y="29" width="1" height="1" xoffset="0" yoffset="27" xadvance="8" /> * * <char id="33" x="155" y="144" width="9" height="21" xoffset="0" yoffset="6" xadvance="9" /> * * </chars> * * <kernings> <!-- Kerning is optional --> * * <kerning first="83" second="83" amount="-4"/> * * </kernings> * * </font> * ** * * * Pass an instance of this class to the method
registerBitmapFont of the
* * TextField class. Then, set the fontName property of the text field to the
* * name value of the bitmap font. This will make the text field use the bitmap
* * font.
*
*/
export class BitmapFont implements ITextCompositor {
/**
* Creates a bitmap font from the given texture and font data.
* * If you don't pass any data, the "mini" font will be created.
* *
* * @param texture The texture containing all the glyphs.
* * @param fontData Typically an XML file in the standard AngelCode format. Override the
* * the 'parseFontData' method to add support for additional formats.
*
*/
constructor(texture?: Texture, fontData?: any);
/**
* Use this constant for the fontSize property of the TextField class to
* * render the bitmap font in exactly the size it was created.
*/
static readonly NATIVE_SIZE = -1;
/**
* The font name of the embedded minimal bitmap font. Use this e.g. for debug output.
*/
static readonly MINI = "mini";
/**
* Disposes the texture of the bitmap font!
*/
dispose(): void;
/**
* Returns a single bitmap char with a certain character ID.
*/
getChar(charID: number): BitmapChar;
/**
* Adds a bitmap char with a certain character ID.
*/
addChar(charID: number, bitmapChar: BitmapChar): void;
/**
* Returns a vector containing all the character IDs that are contained in this font.
*/
getCharIDs(result?: VectorBEWARE: This method uses an object pool for the returned vector and all
* * (returned and temporary) BitmapCharLocation instances. Do not save any references and
* * always call BitmapCharLocation.rechargePool() when you are done processing.
* *