/** * Measurement in vertical text (`layout.writingMode: 'vertical-rl'`). * * A vertical line is measured as a horizontal one in the turned flow frame * (see `VDTPage.flow`), cut into the runs the renderers paint * (`verticalRuns`): a Latin word or number set sideways keeps its * horizontal advance, and every character that stands in a cell of its own * (Han, Chinese punctuation, dashes, ellipses, and the symbols Unicode sets * upright — × © ± ℃ ① —, inside a Latin word or number too) advances its * cell down the line, whatever its horizontal width. {@link cellAdvance} is * the one place a cell's advance is decided; the composer then applies the * punctuation widths (`cjkPunctuation.ts`: compression, line-edge trims, * hanging, the Han–Latin space) to the cells as it does to horizontal * advances, along the line. {@link verticalTextWidth} measures any run of * text with it. */ import type { CjkRegion, WritingMode } from '../types.js'; import type { CjkClass } from './cjkClasses.js'; import { type UprightDigits } from '../writingMode.js'; /** Set the writing mode text is measured in, and the CJK region whose * cells it uses (the mainland interpunct takes half a cell, Japan sets * !? upright). The build * does, from the layout of the pages it is placing (a styled section may * change it), and puts back what it found when it is done. */ export declare function setMeasureWritingMode(mode: WritingMode, region?: CjkRegion): void; /** The writing mode text is measured in (see {@link setMeasureWritingMode}); * horizontal outside a build. */ export declare function getMeasureWritingMode(): WritingMode; /** Set how many ASCII digits a number may have to be set in one upright * cell in vertical text (`cjk.uprightDigits`; 0: none). The build does, * from the document's configuration, and puts back what it found. */ export declare function setMeasureUprightDigits(digits: UprightDigits): void; /** See {@link setMeasureUprightDigits}; 2 outside a build. */ export declare function getMeasureUprightDigits(): UprightDigits; /** The CJK region (Chinese or Japanese) vertical cells are measured * for. */ export declare function getMeasureRegion(): CjkRegion; /** Whether text is measured vertically now. */ export declare function measuringVertically(): boolean; /** Run `fn` with text measured in `mode` (and `region`), then put back the * mode in force before — also when `fn` throws. */ export declare function withMeasureWritingMode(mode: WritingMode, fn: () => T, region?: CjkRegion): T; /** The em of a font string (its size in px), 16 when it names none. */ export declare function fontEm(font: string): number; /** * The advance of one CJK grapheme along its line. Horizontal: its measured * width. Vertical: its cell for every character that stands in one (one * em; half an em for the mainland interpunct, `verticalCellEms`); a * character set sideways keeps its horizontal width. `cls` is the * grapheme's line-break class, when the caller has it. This is a mark's * full advance: the composition takes its blank off afterwards * (`punctuationBox`), in either writing mode. */ export declare function cellAdvance(grapheme: string, font: string, vertical: boolean, cls?: CjkClass): number; /** * The advance of `text` along a vertical line: its sideways runs at * `measureRun`'s width (the horizontal one), each cell at * {@link cellAdvance}. The same runs the renderers paint * (`verticalRuns`), so what is measured is what is painted. Text with no * cell is one sideways run: `measureRun(text)`. */ export declare function verticalTextWidth(text: string, font: string, measureRun?: (run: string) => number): number; /** How many times tracking follows the characters of `text` in a vertical * line: once per grapheme, a number set in one cell (tate-chu-yoko) * counting as one. */ export declare function verticalTrackCount(text: string): number; /** * The advance of text painted in the page's flow (design text, list * markers, contents rows, box titles): `measureTextWidth`, except in * vertical text, where what stands in a cell advances its cell * ({@link verticalTextWidth}), as the renderers paint it. ASCII text with * no cell reads the same either way ({@link mayHoldVerticalCell}). */ export declare function flowTextWidth(text: string, font: string): number; /** Whether `text` may hold a cell in vertical text (see `verticalRuns`): * any non-ASCII character, a digit when short numbers stand in one cell * (`cjk.uprightDigits`), two exclamation or question marks in Japanese * text (`isUprightMarkPair`). ASCII text with none of them runs sideways * whole. */ export declare function mayHoldVerticalCell(text: string): boolean; /** A font string's first family, unquoted: the key of * `VDTFlowFrame.centralBaselines`. */ export declare function fontFamilyOf(font: string): string; /** Drop the measured axes (fonts changed). */ export declare function clearCentralBaselineCache(): void; /** * Where the ideographic em box's centre sits above the alphabetic baseline * of `family`, in ems: the axis upright characters are centred on. Read * from the ink of 中 at 100 px, whose long stroke runs the height of the * em box: the centre of its ink is the centre of the box within a few * hundredths of an em (0.380 in Noto Serif and Sans SC and TC, whose box * centre is 0.38; 0.357 in LXGW WenKai) — and every Chinese, Japanese and * Korean face has the character, where a face for one script lacks the * other's (國 is not in a Simplified Chinese font: the canvas measured a * fallback face's, 0.04 em off). Kept between 0.25 and 0.5 em; a measurer * with no ink metrics gives {@link DEFAULT_CENTRAL_BASELINE}. */ export declare function measureCentralBaseline(family: string): number; /** * How far below the top of its line box a line of `font` has its baseline, * for a line box `lineHeightPx` tall. Horizontal text: 0.8 of the line * height, as it always was. Vertical text: the line box runs down the * column and its height is the pitch across it, and the characters stand * centred on the font's central axis ({@link measureCentralBaseline}), so * the baseline goes where that axis falls in the middle of the box: a * column of characters in the middle of its pitch, as CSS sets a vertical * line and as a rule drawn between two columns expects. `font`'s family * and size decide the axis; the renderers turn each character about the * same one (`VDTFlowFrame.centralBaselines`). */ export declare function lineBaselineOffset(lineHeightPx: number, font: string): number; //# sourceMappingURL=vertical.d.ts.map