/** * Drop caps in body paragraphs (#623). A paragraph style (the first * paragraph of a `:::paragraphs` group, or each one) or a heading level or * style (the first body paragraph after the heading) opens a paragraph with * its first letter set large. The letter is taken out of the text the * measurers break, and the paragraph's first `sink` lines are indented by * its width and the gap (`MeasureBlockOptions.lineIndentsPx`, #620), so * Knuth–Plass, the line-by-line breakers and the CJK composer set them * short like any indented line; the block carries the letter * (`VDTBlock.dropCap`) for the renderers to paint beside them. The plain * text and source map stay the paragraph's own: the first line's * `plainStart` counts past the letter, which holds the range before it. * * Decided here: whether a paragraph takes a drop cap, what it prints, its * size (cap heights measured from the faces), the indents and the lead-in. * The placement (`build.ts`) keeps a raised initial's rise clear above the * paragraph, never breaks it before its line `sink` and stamps the letter on * the fragment that holds its first line. */ import type { ContentBlock } from '../parse/index.js'; import type { ResolvedConfig } from '../vdt.js'; import type { BlockStyle } from './styles.js'; import type { HeadingLevelResolver } from './headingStyles.js'; import { type DropCapSettings } from '../defaults/dropCap.js'; /** The share of a letter's size its capitals take when a face gives no * ink metrics (the design text's `CAP_HEIGHT_RATIO`, EF-127). */ export declare const FALLBACK_CAP_HEIGHT_RATIO = 0.72; /** What the drop cap decision reads besides the block. */ export interface DropCapContext { resolved: ResolvedConfig; contentBlocks: readonly ContentBlock[]; headingLevels?: HeadingLevelResolver; floatedIds: ReadonlySet; /** Boxes that left the flow (see `BlockMeasureContext.leftFlow`). */ leftFlow?: ReadonlySet; } /** Whether the paragraph `raw` asks for a drop cap that is not set * because it sits in a box (#922): a `:::paragraphs{dropcap}` group or a * paragraph style with one, inside a `:::callout`. A heading level's drop * cap does not reach into a box and asks nothing. */ export declare function dropCapRefusedInBox(raw: ContentBlock, idx: number, style: BlockStyle, ctx: DropCapContext): boolean; /** The drop cap the paragraph `raw` (content index `idx`, set in `style`) * opens with, or undefined. */ export declare function paragraphDropCap(raw: ContentBlock, idx: number, style: BlockStyle, ctx: DropCapContext): DropCapSettings | undefined; /** Whether the first body paragraph after the heading at `headingIdx` * opens with a drop cap, and how many lines it sinks: what a heading kept * with its text needs under it. */ export declare function dropCapSinkAfter(headingIdx: number, ctx: DropCapContext): number; /** How far the capitals of `font` rise above the baseline (px): the ink of * `sample` (an `H`, or the initial itself in CJK text), else 0.72 of the * size. */ export declare function capHeightOf(font: string, sizePx: number, sample?: string): number; /** The paragraph a drop cap opens, ready to measure, and the letter. */ export interface PreparedDropCap { /** The block without the initial (and with the lead-in), as measured. */ block: ContentBlock; /** The plain-text range taken out of `block.text` (the initial, an * opening mark set with it or hung, the space after a one-letter * word). */ removed: { start: number; end: number; }; /** What the initial prints, its face and size, its advance. */ text: string; fontString: string; fontSizePx: number; width: number; color: string; /** The indent of each of the first `sink` lines (the initial's width and * the gap; line 0 a word space more after a one-letter word). */ indents: number[]; /** px the initial's capitals rise above those of the first line (a * raised initial). */ rise: number; lines: number; sink: number; /** The plain range the initial stands for (an opening mark hung or set * with it included). */ plainStart: number; plainEnd: number; word: string; wordRest: number; hang?: { text: string; fontString: string; width: number; }; settings: DropCapSettings; } /** Why a paragraph meant to open with a drop cap does not. */ export type DropCapSkip = 'joiningScript' | 'noLetter'; /** * Take the initial out of the paragraph `block` (set in `style`) and work * out its face, size, width and the indents of the lines it shortens. * `leadInWords` is the number of words the lead-in takes when its setting * says `'line'` and the first setting counted them. */ export declare function prepareDropCap(block: ContentBlock, settings: DropCapSettings, style: BlockStyle, resolved: ResolvedConfig, leadInWords?: number): PreparedDropCap | DropCapSkip; /** A plain offset of the measured text (the initial taken out) as an * offset of the paragraph's own text. */ export declare function fullPlainOffset(prepared: Pick, offset: number): number; /** A drop cap as the placement reads it from a measured block (see * `MeasuredContentBlock.dropCap`): the letter's geometry relative to the * block's column. */ export interface MeasuredDropCap { text: string; fontString: string; fontSizePx: number; color: string; width: number; /** Left edge of the initial, from the column's left edge (flow frame). */ x: number; lines: number; sink: number; /** px kept clear above the paragraph's first line (a raised initial). */ rise: number; /** The block is set at least this many lines tall (`'reserve'`). */ minLines: number; plainStart: number; plainEnd: number; sourceStart?: number; sourceEnd?: number; word: string; wordRest: number; hang?: { text: string; fontString: string; x: number; width: number; }; } //# sourceMappingURL=dropCap.d.ts.map