/** * Geometry of ruby readings (#194), warichu notes (#195) and kanbun * reading marks (#430) inside a line, for the CJK composer. * * Everything is in the flow frame: `dx` along the line from where the * annotated segment starts, `dy` across it from the line's baseline to the * annotation's baseline, positive towards the line's foot (down in * horizontal text, left in vertical text). A character's em box is centred * on the font's central axis, {@link CENTRAL} em above the baseline, the * axis vertical text is set on (`VDTFlowFrame.centralBaselines`) and the * middle of a CJK face's ideographic em box in horizontal text. * * - Ruby over or under the base sits in the line gap, against the base's em * box, centred on the base; a reading wider than its base widens the base's * box (the base is centred in it) less what it may pass the base by: a * quarter of the ruby em onto a neighbour without ruby, none past a line * edge (the composer shifts it back), and it keeps a quarter of the ruby * em from a neighbour's reading (two zhuyin readings: a quarter of the * symbols' em). * - Zhuyin right of the base (horizontal text) stacks its symbols in a * column beside each character, at 60 % of the ruby size (0.3 em by * default, clreq §5.5.3.2), the tone mark right of the column with half * of its ink above the top of the last symbol (§5.5.3.3), the * neutral-tone dot above the first in a tenth of an em; the character's * box grows by the column. Zhuyin over the base of vertical text is the * same column down the line, its tone mark and dot standing upright. * Tone marks and the dot are placed by their ink (the measurer's ink * box): fonts set these modifier letters high in their em box. * - A warichu note's part on a line folds into two rows of the note size, * centred on the line's axis with no gap between them. A fold is valid * when the lower row does not open with a mark that may not start a line * and the upper row does not end with one that may not end a line (an * opening bracket). The fold taken is the first valid one whose upper * row is at least half the part, so the second row is not the longer. * When every such fold would open the lower row with a mark (`本名。`), * the last valid fold before the half point is taken and the lower row * is the longer (#719); a part with no valid fold (one character with * its marks) stays one row. * - Kanbun marks (訓点, JIS X 4051 §5) go with the last character of * their base, at half its size: the 返り点 right after it with its box * against the line's foot side (the left half of a vertical line, the * lower half of a horizontal one, §5.5), the 送り仮名 against its head * side (right of vertical text, over horizontal text) from half-way * along it, or right after a reading on that side (§5.6), the 竪点 a * thin rule half an em long on the line's axis in the gap after the * character (§5.7). Inline (the default) the room after the character * is its own advance: the larger of the 返り点 and the 竪点, and as far * as 送り仮名 reach (they never run beside the next character, §5.6.4). * Interlinear, the 返り点 sit in the line gap beside the character's * lower half and nothing takes advance. */ import type { VDTAnnotationRun, VDTKunten } from '../vdt.js'; /** The central axis of a face, in em above its baseline. */ export declare const CENTRAL = 0.38; /** Zhuyin is set at this fraction of the ruby size (0.3 em of the text for * the default half-em ruby). */ export declare const ZHUYIN_SIZE_RATIO = 0.6; /** Whether a reading is zhuyin (bopomofo). */ export declare function isZhuyin(reading: string): boolean; /** `font` at `sizePx`, style, weight and family kept. */ export declare function withFontSize(font: string, sizePx: number): string; /** What a ruby base is set with. */ export interface RubyInput { reading: string; fontString: string; /** `over` / `under` the base, or `right` of each character in the line * (zhuyin, horizontal text). */ position: 'over' | 'under' | 'right'; /** The base's advance and the text's em (px). */ baseWidth: number; em: number; /** How far the reading may pass the base's box on each side (px): a * quarter of the ruby em onto a neighbour without ruby, 0 at a line * edge, negative (keep apart) next to another reading. */ allowLeft: number; allowRight: number; } /** How a ruby base is set: its box's advance, where the base sits in it * (`inset`), the reading's advance and the runs painted. */ export interface RubyGeometry { width: number; inset: number; rtWidth: number; runs: VDTAnnotationRun[]; /** What the reading could pass the box by on each side (the input's). */ allowLeft: number; allowRight: number; /** Space after each base character, px, counted in `width`: a base of * several characters spread 1:2:1 under a longer reading (Japanese * ruby, `rubyJis.ts`). Unset: the base keeps its own spacing. */ tracking?: number; } /** The baseline (`dy`) of a reading over or under its base, px from the * line's baseline: against the base's em box, a Latin reading over the * base lifted clear of the base (`rubyLift.ts`). */ export declare function readingBaseline(reading: string, fontString: string, position: 'over' | 'under', em: number): number; /** * The geometry of a ruby base (see the module comment). Measured in the * writing mode the composer runs in: a vertical reading advances cell by * cell down the line. */ export declare function rubyGeometry(input: RubyInput): RubyGeometry; /** * The run of a footnote marker set in the line gap (`footnotes.markerPosition: * 'side'`, JLReq §4.2.3): `text` at `fontString` over the text — right of a * vertical line, above a horizontal one — against the em box of the text * (`em` px), as a ruby reading over its base. It ends where its segment * starts, the end of the character it marks (the marker's foot aligned with * the word's last character), and changes nothing in the line. */ export declare function sideMarkerRun(text: string, fontString: string, em: number): VDTAnnotationRun; /** The advance of a reading along the line (a zhuyin reading: its * symbols' column, tone marks aside), before its base is sized. */ export declare function readingAdvance(reading: string, fontString: string, position: 'over' | 'under' | 'right'): number; /** What a character with kanbun marks is set with (see the module * comment). Lengths are px along the line, from where its unit starts. */ export interface KuntenInput { kaeri?: string; okuri?: string; tate?: boolean; /** The marks' font (at their size) and colour. */ fontString: string; color?: string; placement: 'inline' | 'interlinear'; /** The text's em, px. */ em: number; /** Where the character ends, and the unit's advance so far. */ baseEnd: number; width: number; /** Where a ruby reading over (right of vertical text) or under the base * ends, if it has one on that side. */ readingOverEnd?: number; readingUnderEnd?: number; } /** * The marks of a character with kanbun marks, and the advance they add * after its unit (0 when they are set interlinear). Measured in the * writing mode the composer runs in: down a vertical line each mark is an * upright cell. */ export declare function kuntenGeometry(input: KuntenInput): { extra: number; kunten: VDTKunten; }; /** Where the upper row of a warichu part ends (units `[0, at)`): see the * module comment. `startProhibited[i]`: unit `i` may not open a row; * `endProhibited[i]`: unit `i` may not close one (an opening bracket), so * the upper row takes the unit after it too. `n` (every unit in the upper * row) when no fold keeps both rules. */ export declare function splitNote(widths: readonly number[], startProhibited: readonly boolean[], endProhibited?: readonly boolean[]): number; /** The advance of a warichu part folded at `at`: the wider row. */ export declare function foldWidth(widths: readonly number[], at: number): number; /** The baselines of a warichu part's rows (px from the line's baseline): * the upper row's em box ends at the line's axis, the lower one's starts * there. */ export declare function noteRowBaselines(em: number, noteEm: number): { upper: number; lower: number; }; //# sourceMappingURL=cjkAnnotate.d.ts.map