/** * Letters as rows of dots, for a child to trace (#1017): the dots a text * is painted with when its style sets `dotted` (a design text element, a * chip style). * * The browser shapes and draws the text, so a joined script keeps its * joins and an Arabic word its forms, and the dots are read off what it * drew. The run is painted alone on a small canvas, `RASTER_PITCH` pixels * to a dot spacing; the edge of its ink is traced (marching squares, at * the half-coverage level); each point of the edge is moved half the * stroke's width inward, onto the middle of the stroke; and the dots are * laid along each edge at the spacing, the longest edge first, a dot kept * only where no dot stands closer than `REJECT` spacings. The two edges of * a stroke meet on its middle, so the second one adds nothing: one row of * dots per stroke, whatever the weight (the thinnest weight of a face * gives the most even rows). An edge too short to carry two dots is a * mark of its own (the dot of an i, an accent): one dot at its middle, if * that is ink (the eye of a small loop is not). * * The dots are a function of the run, its font, its tracking, direction * and language, and of the spacing: cached under all of them. They are * paint, not layout: the run keeps the width it was measured at. */ import type { TextDotsStyle } from './types.js'; export interface TextDotsRequest { text: string; /** CSS font shorthand the run is painted in. */ font: string; /** Distance between two dots along a stroke, px. */ spacingPx: number; letterSpacingPx?: number; rtl?: boolean; /** The language the run is shaped in (`ctx.lang`). */ lang?: string; } export interface TextDots { /** Dot centres, `x, y` pairs from the run's left edge and baseline, px. */ points: Float32Array; /** The run's advance, px, as the raster's context measured it. */ width: number; } /** * The dots `req.text` is traced with, or `null` where there is no canvas * to draw it on (the painter then fills the letters). */ export declare function textDots(req: TextDotsRequest): TextDots | null; /** Forget every run's dots (a face loaded or replaced under a name). */ export declare function clearTextDots(): void; /** * Dot centres (flat `x, y`, raster px) along the strokes of the ink in * `alpha` (coverage 0…1, `W × H`), `pitch` px apart. Exported for tests. */ export declare function dotsOnRaster(alpha: Float32Array, W: number, H: number, pitch: number): number[]; /** * The closed edges of the ink at coverage `level` (marching squares over * the pixel centres, each crossing placed by linear interpolation), as * flat `x, y` polylines, the ink on their right (y down). The raster's * border is taken as blank, so every edge closes. */ export declare function traceContours(alpha: Float32Array, W: number, H: number, level: number): number[][]; /** A `TextDotsStyle` in px, em being `fontSizePx`: `0.1em` apart, `0.05em` * across by default; a spacing never under the dot. */ export declare function resolveTextDots(style: TextDotsStyle, dpi: number, fontSizePx: number): { spacingPx: number; sizePx: number; }; //# sourceMappingURL=textDots.d.ts.map