@mocanvas/editor · function

resolveLineHeightPx

declare function resolveLineHeightPx(lineHeight: number | string | undefined, fontSizePx: number): number

A line height in page units, from whatever the theme or a shape gave.

Line height is the one text metric that is written two ways: as a unitless multiplier (1.4, meaning "of the font size") and as an absolute length ("22px"). Both are legal CSS and both turn up in themes and in pasted content, and measuring text against the wrong reading is off by a factor of the font size — which is not a subtle bug, but is a silent one.

SEMANTICS-ASSUMED: a bare number, or a number-valued string with no unit, is a multiplier; px is absolute; em and % are relative to the font size. That is CSS's own rule for line-height, which is where every one of these values came from.

mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.