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.

Static methods

@:value({ enumerateDeviceFonts : false })staticenumerateFonts(enumerateDeviceFonts:Bool = false):Array<Font>

Specifies whether to provide a list of the currently available embedded fonts.

Parameters:

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.

Returns:

A list of available fonts as an array of Font objects.

staticfromBytes(bytes:ByteArray):Font

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).

Parameters:

bytes

A haxe.io.Bytes or openfl.utils.ByteArray instance

Returns:

A new Font if successful, or null if unsuccessful

staticfromFile(path:String):Font

Creates a new Font from a file path synchronously. This means that the Font will be returned immediately (if supported).

Parameters:

path

A local file path containing a font

Returns:

A new Font if successful, or null if unsuccessful

staticloadFromBytes(bytes:ByteArray):Future<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.

Parameters:

bytes

A haxe.io.Bytes or openfl.utils.ByteArray instance

Returns:

A Future Font

staticloadFromFile(path:String):Future<Font>

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.

Parameters:

path

A local file path or web address containing a font

Returns:

A Future Font

staticloadFromName(path:String):Future<Font>

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.

Parameters:

path

A font name

Returns:

A Future Font

staticregisterFont(font:Dynamic):Void

Registers a font in the global font list.

Constructor

@:value({ name : null })new(?name:String)

Variables

fontName:String

The name of an embedded font.

fontStyle:FontStyle

The style of the font. This value can be any of the values defined in the FontStyle class.

fontType:FontType

The type of the font. This value can be any of the constants defined in the FontType class.

Inherited Variables

Defined by Font

ascender:Int

The ascender value of the font.

descender:Int

The descender value of the font.

height:Int

The height of the font.

read onlyname:String

The name of the font.

numGlyphs:Int

The number of glyphs in the font.

src:Dynamic

underlinePosition:Int

The underline position of the font.

underlineThickness:Int

The underline thickness of the font.

unitsPerEM:Int

The units per EM of the font.

Inherited Methods

Defined by Font

decompose():NativeFontData

Decomposes the font into outline data.

Returns:

An instance of NativeFontData that contains decomposed font outline information.

getGlyph(character:String):Glyph

Retrieves a glyph from the font by a character.

Parameters:

character

The character whose glyph to retrieve.

Returns:

A Glyph instance representing the glyph of the character.

getGlyphMetrics(glyph:Glyph):GlyphMetrics

Retrieves metrics for a given glyph.

Parameters:

glyph

The glyph whose metrics to retrieve.

Returns:

A GlyphMetrics instance containing the metrics of the glyph.

@:value({ characters : "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^`'\"/\\&*()[]{}<>|:;_-+=?,. " })getGlyphs(characters:String = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^`'\"/\\&*()[]{}<>|):Array<Glyph>

Retrieves an array of glyphs for a set of characters.

Parameters:

characters

The string containing characters to retrieve glyphs for.

Returns:

An array of Glyph instances representing the glyphs of the characters.

renderGlyph(glyph:Glyph, fontSize:Int):Image

Renders a specific glyph to an image.

Parameters:

glyph

The glyph to render.

fontSize

The size to render the glyph at.

Returns:

An Image instance representing the rendered glyph.

renderGlyphs(glyphs:Array<Glyph>, fontSize:Int):Map<Glyph, Image>

Renders a set of glyphs to images.

Parameters:

glyphs

The glyphs to render.

fontSize

The size to render the glyphs at.

Returns:

A Map containing glyphs mapped to their corresponding images.