/** * Label sizing for shapes Mango draws itself. * * Shared deliberately by the story overlay and the annotation editor. The * canvas package clamps a label's size but cannot wrap it, and a sentence on a * region has to wrap somewhere — so both surfaces fit their labels here, which * is what stops the same annotation being laid out one way while playing and * another way while being edited. * * Two rules, and both exist because the previous version had neither. Sizes are * bounded: the search used to run up to 42% of the rectangle's height with no * ceiling, so a region covering a manuscript page produced a headline. And * sizes respond to the reader's text settings: an absolute pixel size in a * transformed SVG ignores browser text zoom entirely, which for anyone relying * on larger text means the one piece of text they cannot enlarge is the label. */ export type RectangleLabelLayout = { /** Screen pixels, clamped into the band. */ fontSize: number; lineHeight: number; lines: string[]; /** True when the label does not fit even at the smallest permitted size. */ overflow: boolean; /** * How many lines actually fit the region at this size. * * Equal to `lines.length` unless the label overflows, where it is what the * caller may show before clipping. A caller that clamps to a fixed number * either wastes room in a tall region or cuts a short label that would have * fitted. */ visibleLines: number; }; /** Lower and upper bound for a label, in screen pixels at default text size. */ export type LabelSizing = { min: number; max: number; }; /** * The story band is slightly larger than the editor band because story labels * are read from further back, in a presentation rather than an editing context. */ export declare const EDITOR_LABEL_SIZING: LabelSizing; export declare const STORY_LABEL_SIZING: LabelSizing; /** No label exceeds this, whatever the band asks for. */ export declare const LABEL_CEILING = 24; /** The root font size the bands above are expressed against. */ export declare const BASE_ROOT_FONT_SIZE = 16; /** Scales a band by the reader's text size, keeping the absolute ceiling. */ export declare const scaleSizing: (sizing: LabelSizing, root?: number) => LabelSizing; export type FitOptions = { sizing?: LabelSizing; /** Root font size to size against. Read from the document when omitted. */ root?: number; }; /** * Largest banded size at which the label fits the rectangle. * * `width` and `height` are screen pixels. Passing image coordinates would size * the label against the region rather than against the reader's screen, which * is the mistake this replaced. */ export declare const fitRectangleLabelLayout: (width: number, height: number, label: string, options?: FitOptions) => RectangleLabelLayout; export declare const fitRectangleLabelFontSize: (width: number, height: number, label: string, options?: FitOptions) => number; export declare const rectangleLabelOutlineWidth: (fontSize: number) => number;