UNPKG

modern-text

Version:

Measure and render text in a way that describes the DOM.

62 lines (48 loc) 2.84 kB
import { P as Plugin, O as Options, M as MeasureResult, R as RenderOptions, T as Text } from './shared/modern-text.DRiaDpRv.js'; export { C as Canvas2DRenderer, a as Character, D as DrawShapePathsOptions, F as Fragment, f as MeasureDomResult, e as MeasuredCharacter, d as MeasuredFragment, c as MeasuredParagraph, g as Measurer, b as Paragraph, h as TextEvents, t as textDefaultStyle } from './shared/modern-text.DRiaDpRv.js'; import { NormalizedStyle, NormalizedHighlight } from 'modern-idoc'; import { Matrix3, Path2DSet } from 'modern-path2d'; import 'modern-font'; declare function definePlugin(options: Plugin): Plugin; declare function measureText(options: Options, load: true): Promise<MeasureResult>; declare function measureText(options: Options): MeasureResult; type RenderTextOptions = Options & RenderOptions; declare function renderText(options: RenderTextOptions, load: true): Promise<void>; declare function renderText(options: RenderTextOptions): void; declare function backgroundPlugin(): Plugin; declare function getHighlightStyle(style: NormalizedStyle): NormalizedHighlight; declare function highlightPlugin(): Plugin; declare function listStylePlugin(): Plugin; declare function outlinePlugin(): Plugin; declare function renderPlugin(): Plugin; declare function getTransform2D(text: Text, style: NormalizedStyle): Matrix3; declare function textDecorationPlugin(): Plugin; interface SvgLoader { loaded: Map<string, string>; needsLoad: (source: string) => boolean; load: (svg: string) => Promise<void>; } declare function createSvgLoader(): SvgLoader; interface SvgParser { parsed: Map<string, { dom: SVGElement; pathSet: Path2DSet; }>; parse: (svg: string) => { dom: SVGElement; pathSet: Path2DSet; }; } declare function createSvgParser(loader: SvgLoader): SvgParser; interface ValueContext { total: number; fontSize: number; } declare function parseValueNumber(value: string | number, ctx: ValueContext): number; declare function parseColormap(colormap: 'none' | Record<string, string>): Record<string, string>; declare function isEqualObject(obj1: Record<string, any>, obj2: Record<string, any>): boolean; declare function isEqualValue(val1: any, val2: any): boolean; declare function hexToRgb(hex: string): string | null; declare function filterEmpty(val: Record<string, any> | undefined): Record<string, any> | undefined; export { MeasureResult, Options, Plugin, RenderOptions, Text, backgroundPlugin, createSvgLoader, createSvgParser, definePlugin, filterEmpty, getHighlightStyle, getTransform2D, hexToRgb, highlightPlugin, isEqualObject, isEqualValue, listStylePlugin, measureText, outlinePlugin, parseColormap, parseValueNumber, renderPlugin, renderText, textDecorationPlugin }; export type { RenderTextOptions, SvgLoader, SvgParser };