import Future from "../utils/Future"; import ByteArray from "../utils/ByteArray"; import FontType from "./FontType"; import FontStyle from "./FontStyle"; declare namespace openfl.text { /** * The Font class is used to manage embedded fonts in SWF files. Embedded * fonts are represented as a subclass of the Font class. The Font class is * currently useful only to find out information about embedded fonts; you * cannot alter a font by using this class. You cannot use the Font class to * load external fonts, or to create an instance of a Font object by itself. * Use the Font class as an abstract base class. * */ export class Font { constructor(name?: string); /** * The ascender value of the font. * */ ascender: number; /** * The descender value of the font. * */ descender: number; /** * The height of the font. * */ height: number; /** * The name of the font. * */ name: string; /** * The number of glyphs in the font. * */ numGlyphs: number; src: any; /** * The underline position of the font. * */ underlinePosition: number; /** * The underline thickness of the font. * */ underlineThickness: number; /** * The underline position of the font. * */ strikethroughPosition: number; /** * The underline thickness of the font. * */ strikethroughThickness: number; /** * The units per EM of the font. * */ unitsPerEM: number; /** * Decomposes the font into outline data. * * @return An instance of `NativeFontData` that contains decomposed font outline information. * */ decompose(): any; /** * Retrieves a glyph from the font by a character. * * @param character The character whose glyph to retrieve. * @return A `Glyph` instance representing the glyph of the character. * */ getGlyph(character: string): number; /** * Retrieves an array of glyphs for a set of characters. * * @param characters The string containing characters to retrieve glyphs for. * @return An array of `Glyph` instances representing the glyphs of the characters. * */ getGlyphs(characters?: string): Array; /** * Retrieves metrics for a given glyph. * * @param glyph The glyph whose metrics to retrieve. * @return A `GlyphMetrics` instance containing the metrics of the glyph. * */ getGlyphMetrics(glyph: number): any; /** * Renders a specific glyph to an image. * * @param glyph The glyph to render. * @param fontSize The size to render the glyph at. * @return An `Image` instance representing the rendered glyph. * */ renderGlyph(glyph: number, fontSize: number): any; /** * Renders a set of glyphs to images. * * @param glyphs The glyphs to render. * @param fontSize The size to render the glyphs at. * @return A `Map` containing glyphs mapped to their corresponding images. * */ renderGlyphs(glyphs: Array, fontSize: number): any; /** * Specifies whether to provide a list of the currently available embedded * fonts. * * @param enumerateDeviceFonts Indicates whether you want to limit the list * to only the currently available embedded * fonts. If this is set to `true` * then a list of all fonts, both device fonts * and embedded fonts, is returned. If this is * set to `false` then only a list of * embedded fonts is returned. * @return A list of available fonts as an array of Font objects. * */ static enumerateFonts(enumerateDeviceFonts?: boolean): Array; /** * Creates a new Font from bytes (a haxe.io.Bytes or openfl.utils.ByteArray) * synchronously. This means that the Font will be returned immediately (if * supported). * * @param bytes A haxe.io.Bytes or openfl.utils.ByteArray instance * @returns A new Font if successful, or `null` if unsuccessful * */ static fromBytes(bytes: ByteArray): Font; /** * Creates a new Font from a file path synchronously. This means that the * Font will be returned immediately (if supported). * * @param path A local file path containing a font * @returns A new Font if successful, or `null` if unsuccessful * */ static fromFile(path: string): Font; /** * Creates a new Font from haxe.io.Bytes or openfl.utils.ByteArray data * asynchronously. The font decoding will occur in the background. * Progress, completion and error callbacks will be dispatched in the current * thread using callbacks attached to a returned Future object. * * @param bytes A haxe.io.Bytes or openfl.utils.ByteArray instance * @returns A Future Font * */ static loadFromBytes(bytes: ByteArray): Future; /** * Creates a new Font from a file path or web address asynchronously. The file * load and font decoding will occur in the background. * Progress, completion and error callbacks will be dispatched in the current * thread using callbacks attached to a returned Future object. * * @param path A local file path or web address containing a font * @returns A Future Font * */ static loadFromFile(path: string): Future; /** * Creates a new Font from a font name asynchronously. This feature should work * for embedded CSS fonts on the HTML5 target, but is not implemented for * registered OS fonts on native targets currently. The file * load and font decoding will occur in the background. * Progress, completion and error callbacks will be dispatched in the current * thread using callbacks attached to a returned Future object. * * @param path A font name * @returns A Future Font * */ static loadFromName(path: string): Future; /** * Registers a font in the global font list. * * */ static registerFont(font: any): void; /** * The name of an embedded font. * */ get fontName(): string; set fontName(value: string) /** * The style of the font. This value can be any of the values defined in the * FontStyle class. * */ fontStyle: FontStyle; /** * The type of the font. This value can be any of the constants defined in * the FontType class. * */ fontType: FontType; } } export default openfl.text.Font;