UNPKG

babylon-msdf-text

Version:

**babylon-msdf-text** is a library for rendering high-quality, scalable, and anti-aliased text in Babylon.js using the Multi-channel Signed Distance Field (MSDF) technique. It offers an efficient and straightforward solution for superior text rendering in

111 lines (110 loc) 2.61 kB
/** * Font character data */ interface FontChar { id: number; x: number; y: number; width: number; height: number; xoffset: number; yoffset: number; xadvance: number; page?: number; char?: string; } /** * Glyph data with layout information */ export interface Glyph { position: [number, number]; data: FontChar; index: number; linesTotal: number; lineIndex: number; lineLettersTotal: number; lineLetterIndex: number; lineWordsTotal: number; lineWordIndex: number; wordsTotal: number; wordIndex: number; lettersTotal: number; letterIndex: number; } /** * Text layout options */ export interface TextLayoutOptions { text: string; font: any; width?: number; align?: "left" | "center" | "right"; letterSpacing?: number; tabSize?: number; lineHeight?: number; measure?: (text: string, start: number, end: number, width: number) => { start: number; end: number; width: number; }; } /** * Text layout class for arranging glyphs */ export declare class TextLayout { glyphs: Glyph[]; private _width; private _height; private _descender; private _ascender; private _xHeight; private _baseline; private _capHeight; private _lineHeight; private _linesTotal; private _lettersTotal; private _wordsTotal; private _options; private _fallbackSpaceGlyph; private _fallbackTabGlyph; constructor(options: TextLayoutOptions); get width(): number; get height(): number; get descender(): number; get ascender(): number; get xHeight(): number; get baseline(): number; get capHeight(): number; get lineHeight(): number; get linesTotal(): number; get lettersTotal(): number; get wordsTotal(): number; get glyphsArray(): Glyph[]; /** * Updates the text layout with new options * @param options - Text layout configuration */ update(options: TextLayoutOptions): void; /** * Gets a glyph by its character ID * @param font - Font data * @param id - Character ID * @returns Glyph data or null */ private getGlyph; /** * Computes metrics for text layout */ private computeMetrics; /** * Sets up fallback glyphs for space and tab */ private _setupSpaceGlyphs; } /** * Creates a new text layout instance * @param options - Text layout configuration * @returns New TextLayout instance */ export declare function createLayout(options: TextLayoutOptions): TextLayout; export {};