/** @ignore */ /** */ import type { IBounds } from "../../util/IBounds"; import type { ITextStyle } from "../backend/Renderer"; import type { Color } from "../../util/Color"; /** * What text layout measures with. A canvas 2D context in the chart's DOM is * one: it resolves relative font sizes (`em`) against the page like the layer * canvases do. * * @ignore */ export interface ITextMeasureContext { font: string; save(): void; restore(): void; measureText(text: string): TextMetrics; } /** * Style fields text layout reads beyond `ITextStyle`. * * @ignore */ export interface ILayoutTextStyle extends ITextStyle { fillOpacity?: number; ignoreFormatting?: boolean; } /** * @ignore */ export interface ILineChunk { style: string | undefined; fill: Color | undefined; text: string; width: number; height: number; left: number; right: number; ascent: number; offsetX: number; offsetY: number; textDecoration: string | undefined; verticalAlign?: "baseline" | "sub" | "super"; } /** * @ignore */ export interface ILine { offsetY: number; ascent: number; width: number; height: number; left: number; right: number; textChunks: Array; } /** * Layout results that belong to the text's display object. Layout reads the * current values and updates them in place. * * @ignore */ export interface ITextLayoutState { lines: Array; textVisible: boolean; truncated?: boolean; scale: number; originalScale?: number; } /** * CSS font string for `style`, overridden by `style2` (a rich-text format). * * @ignore */ export declare function getFontStyle(style: ITextStyle, style2: ITextStyle | undefined, ignoreFontWeight: boolean, inheritedFontFamily: () => string): string; /** * A font size as CSS: a plain number, also one in a string (`"8"`), is in * pixels. * * @ignore */ export declare function fontSizeToCSS(fontSize: string | number): string; /** * Safari measures without the font weight. * * @ignore */ export declare function ignoreFontWeight(): boolean; /** * Measures `text` in the context's current font. Horizontal extents follow * `style.textAlign`. * * @ignore */ export declare function measureText(text: string, context: ITextMeasureContext, style: ITextStyle): TextMetrics; /** * @ignore */ export declare function fitRatio(style: ITextStyle, bounds: IBounds, horizontalOnly?: boolean): number; /** * @ignore */ export declare function truncateText(context: ITextMeasureContext, style: ITextStyle, text: string, maxWidth: number, breakWords?: boolean, fallbackBreakWords?: boolean): string; /** * Lays out regular text: rich-text chunks, wrapping, truncation, line * metrics and the oversized behavior. The context must already carry the * base font and alignment. * * @ignore */ export declare function layoutText(context: ITextMeasureContext, text: string, style: ILayoutTextStyle, fontOf: (format: ITextStyle) => string, state: ITextLayoutState): IBounds; /** * Lays out circular text one glyph at a time. The context must already carry * the base font. * * @ignore */ export declare function layoutCircularText(context: ITextMeasureContext, text: string, style: ILayoutTextStyle, fontOf: (format: ITextStyle) => string, state: ITextLayoutState): IBounds; //# sourceMappingURL=TextLayout.d.ts.map