BitmapFontData
Complete data structure containing all information about a bitmap font.
BitmapFontData stores everything needed to render text with a bitmap font: character definitions, texture page references, kerning pairs, and metrics. This data is typically loaded from font definition files (like BMFont format) and used to construct a BitmapFont instance.
The data includes:
- Font metadata (face name, sizes)
- Character definitions with texture coordinates and metrics
- Texture page information for multi-page fonts
- Kerning data for improved character spacing
- Optional distance field data for high-quality scaling
var fontData:BitmapFontData = {
face: "Arial",
pointSize: 32,
baseSize: 32,
lineHeight: 40,
chars: new IntMap(),
pages: [{id: 0, file: "arial_0.png"}],
kernings: new IntMap()
};
Instance Members
face: StringThe name of the font face (e.g., "Arial", "Helvetica"). This identifies the typeface family.
path: StringPath to the directory containing the font files. Used to resolve relative paths for texture pages. Can be null or empty for fonts in the root directory.
pointSize: FloatFont size in points at which the glyphs were rendered. This is the reference size for all metrics. When rendering at different sizes, metrics are scaled proportionally.
baseSize: FloatBase size of the font in pixels. Usually matches pointSize but may differ depending on the tool used to generate the bitmap font.
chars: IntMap<BitmapFontCharacter>Map of all characters in the font, indexed by Unicode code point. Each character contains texture coordinates, size, and positioning data. Missing characters will not be present in the map.
charCount: IntTotal number of characters defined in this font. This count includes all glyphs across all texture pages. Useful for validation and statistics.
distanceField: Null<BitmapFontDistanceFieldData>Optional distance field data for SDF (Signed Distance Field) fonts. When present, indicates this is an MSDF font that can be scaled without quality loss. Null for regular bitmap fonts.
pages: Array<BitmapFontDataPage>Array of texture pages containing the font glyphs. Large fonts may span multiple textures to fit all characters. Pages are referenced by index in BitmapFontCharacter.page.
lineHeight: FloatRecommended line height in pixels. This is the vertical distance between baselines of consecutive lines of text. Includes ascent, descent, and line gap.
kernings: IntMap<IntFloatMap>Kerning information for character pairs.
Kerning adjusts the spacing between specific character pairs for better visual appearance (e.g., "AV" vs "AA").
Structure: kernings[firstChar][secondChar] = adjustment
- First key: Unicode code point of the first character
- Second key: Unicode code point of the second character
- Value: Horizontal adjustment in pixels (usually negative)
var kernValue = kernings.get(65)?.get(86); // Kerning for "AV"
if (kernValue != null) cursorX += kernValue;
smooth: BoolWhether the font uses smoothing (bilinear filtering). When true, the font texture uses smooth interpolation for scaling. When false, uses nearest neighbor filtering for pixel-perfect rendering. Defaults to true for XML/BMFont formats, false for Construct 3 format.
aa: BoolWhether the font uses anti-aliasing. When true, the font glyphs were rendered with anti-aliasing. When false, the font has hard pixel edges. Defaults to true for XML/BMFont formats, false for Construct 3 format.
needsReparsing: BoolInternal flag for Construct 3 fonts that need re-parsing after image loading. When true, the font data needs to be re-parsed with actual image dimensions. This is used for two-stage parsing of Construct 3 fonts.
rawFontData: StringStores the raw font data text for re-parsing. Only populated for fonts that need re-parsing (e.g., Construct 3 fonts).
new(face: String, path: String, pointSize: Float, baseSize: Float, chars: IntMap<BitmapFontCharacter>, charCount: Int, distanceField: Null<BitmapFontDistanceFieldData>, pages: Array<BitmapFontDataPage>, lineHeight: Float, kernings: IntMap<IntFloatMap>, ?smooth: Null<Bool>, ?aa: Null<Bool>, ?needsReparsing: Null<Bool>, ?rawFontData: Null<String>): Void| Name | Type | Default | Description |
|---|---|---|---|
face |
String | * The name of the font face (e.g., "Arial", "Helvetica"). This identifies the typeface family. | |
path |
String | * Path to the directory containing the font files. Used to resolve relative paths for texture pages. Can be null or empty for fonts in the root directory. | |
pointSize |
Float | * Font size in points at which the glyphs were rendered. This is the reference size for all metrics. When rendering at different sizes, metrics are scaled proportionally. | |
baseSize |
Float | * Base size of the font in pixels. Usually matches pointSize but may differ depending on the tool used to generate the bitmap font. | |
chars |
IntMap<BitmapFontCharacter> | * Map of all characters in the font, indexed by Unicode code point. Each character contains texture coordinates, size, and positioning data. Missing characters will not be present in the map. | |
charCount |
Int | * Total number of characters defined in this font. This count includes all glyphs across all texture pages. Useful for validation and statistics. | |
distanceField |
Null<BitmapFontDistanceFieldData> | * Optional distance field data for SDF (Signed Distance Field) fonts. When present, indicates this is an MSDF font that can be scaled without quality loss. Null for regular bitmap fonts. | |
pages |
Array<BitmapFontDataPage> | * Array of texture pages containing the font glyphs. Large fonts may span multiple textures to fit all characters. Pages are referenced by index in BitmapFontCharacter.page. | |
lineHeight |
Float | * Recommended line height in pixels. This is the vertical distance between baselines of consecutive lines of text. Includes ascent, descent, and line gap. | |
kernings |
IntMap<IntFloatMap> | * Kerning information for character pairs. * Kerning adjusts the spacing between specific character pairs for better visual appearance (e.g., "AV" vs "AA"). * Structure: kernings[firstChar][secondChar] = adjustment - First key: Unicode code point of the first character - Second key: Unicode code point of the second character - Value: Horizontal adjustment in pixels (usually negative) * haxe var kernValue = kernings.get(65)?.get(86); // Kerning for "AV" if (kernValue != null) cursorX += kernValue; |
|
smooth |
Null<Bool> | (optional) | * Whether the font uses smoothing (bilinear filtering). When true, the font texture uses smooth interpolation for scaling. When false, uses nearest neighbor filtering for pixel-perfect rendering. Defaults to true for XML/BMFont formats, false for Construct 3 format. |
aa |
Null<Bool> | (optional) | * Whether the font uses anti-aliasing. When true, the font glyphs were rendered with anti-aliasing. When false, the font has hard pixel edges. Defaults to true for XML/BMFont formats, false for Construct 3 format. |
needsReparsing |
Null<Bool> | (optional) | * Internal flag for Construct 3 fonts that need re-parsing after image loading. When true, the font data needs to be re-parsed with actual image dimensions. This is used for two-stage parsing of Construct 3 fonts. |
rawFontData |
Null<String> | (optional) | * Stores the raw font data text for re-parsing. Only populated for fonts that need re-parsing (e.g., Construct 3 fonts). |
Metadata
| Name | Parameters |
|---|---|
:structInit |
- |