/** * Japanese ruby geometry (furigana, #422), after JIS X 4051 §12 and JLReq * §3.3: where a reading sits on its base, how far a longer one may run * past the base before the base is spread, and how the readings of a * jukugo ruby (熟語ルビ) share a word. * * Pure arithmetic along the line, in px of the flow frame: the composer * (`cjkCompose.ts`) gives each base's advance and its reading's * characters, and how far the reading may pass the base on each side * (`allow`: what the neighbour outside takes, 0 at a line edge, where * the reading is set flush with the edge and the base moves in); it gets * back each base's box (its advance on the line), where the base's first * glyph starts in the box (`inset`), the spacing after each base * character (`tracking`) and the reading's pieces, placed from the box's * start. * * - A reading no longer than its base (JLReq §3.3.6 a) leaves the box as * the base: `center` centres it, `start` sets it from the base's start, * `jis` spreads it 1:2:1 (half a unit before the first character and * after the last, a unit between characters), or, when that half unit * would be more than a ruby character, from one end of the base to the * other (space-between). One character is centred by either. * - A longer reading (§3.3.6 b) runs past the base as far as each side * allows, evenly while both sides can take it; what is left spreads the * base: 1:2:1 under `jis` (half a unit before the first character and * after the last, a unit between), centred in its box otherwise. The * reading is set solid. * - A jukugo ruby (§3.3.7) is set as mono ruby while every reading fits * its base. When one does not, each reading stays by its own base and * may run onto the next or the previous base of the word by up to one * ruby character, the readings never overlapping, the first and the * last passing the word by what the neighbours outside allow. When even * that does not hold them, the word takes its readings as one, a group * ruby over the whole word. */ /** A ruby base and its reading. */ export interface JisRubyBase { /** The base's advance (its characters at their own spacing), px. */ width: number; /** How many characters (graphemes) the base holds. */ graphemes: number; /** The reading's characters as painted, with their advances (px). */ reading: readonly { text: string; width: number; }[]; } /** Where a reading sits (see `CjkRubyAlign`). */ export type JisRubyAlign = 'center' | 'jis' | 'start'; /** How far a reading may pass its base, or a jukugo word, on each side, px. */ export interface JisRubyAllow { start: number; end: number; } /** A piece of a reading: its text, its advance and where it starts, px * from the start of its base's box (negative: before the box). */ export interface JisRubyPiece { text: string; dx: number; width: number; } /** How a ruby base is set (see the module comment). */ export interface JisRubyBox { /** The box's advance on the line, px. */ width: number; /** Where the base's first glyph starts in the box, px. */ inset: number; /** Space after each base character (a spread base of two or more), px; * counted in `width`. */ tracking: number; pieces: JisRubyPiece[]; } /** How far a longer reading passes its base on each side: evenly while * both sides take it, then the side that takes more (`start` alignment: * only after the base). */ export declare function overhangs(need: number, allow: JisRubyAllow, align: JisRubyAlign): { start: number; end: number; }; /** * One base and its reading: a mono ruby's character, or a group ruby's * base (see the module comment). `rubyEm` is the reading's em, for the * limit of the 1:2:1 spread. */ export declare function layoutJisRuby(base: JisRubyBase, align: JisRubyAlign, rubyEm: number, allow: JisRubyAllow): JisRubyBox; /** * A jukugo ruby's characters (a word, or the part of it on a line): one * box per base (see the module comment). `allow` is what the word's * neighbours outside it take. */ export declare function layoutJukugo(bases: readonly JisRubyBase[], align: JisRubyAlign, rubyEm: number, allow: JisRubyAllow): JisRubyBox[]; /** The total advance of boxes. */ export declare function boxesWidth(boxes: readonly JisRubyBox[]): number; /** A reading with its small kana full size (がっこう → がつこう). */ export declare function fullSizeKana(reading: string): string; //# sourceMappingURL=rubyJis.d.ts.map