Native rich-text numeric math

The native XHTML rich-text decoder evaluates finite calc, min, max and clamp expressions in font-size, font shorthand size and slash height, line-height, letter-spacing and word-spacing

<body xmlns="http://www.w3.org/1999/xhtml" style="font-size:10pt;line-height:calc(1rem + 2pt)">
  <p style="letter-spacing:calc(.1em + 1pt);word-spacing:clamp(1pt, 3pt, 4pt)">Spaced text</p>
</body>

This example computes a 12-point line height, 2-point letter spacing and 3-point word spacing using the caller's supplied fonts and existing paragraph layout

Parenthesized arithmetic supports addition, subtraction, multiplication and division with matching dimensions for sums; multiplication and division track length powers, including cancellation in an expression such as calc(20pt / 10pt * 6pt)

Binary addition and subtraction require whitespace on both sides; min and max accept compatible comma-separated expressions, and clamp takes three compatible expressions, with its lower bound winning when the bounds are reversed

Supported length units are pt, px at 96 dpi, pc, in, cm, mm, q, em, rem, vw, vh, vmin and vmax; decimal and exponent numbers use the existing finite decimal conversion

Font-size em and percentages use the enclosing computed font size; line-height em and percentages and spacing em use the declaring element's final cascaded font size before inheritance

rem uses the computed body font size; the body's own font-size expression uses the initial root size from DefaultStyle.FontSize, while its other metrics use its final computed size

Viewport units use explicit width and height entries in MediaFeatures; these host dimensions are point-compatible lengths, and em or rem host dimensions use MediaInitialFontSize with its existing 12-point fallback when zero

Host dimensions, resolution and nonzero initial media font sizes retain the existing 0.000001 lower bound and 1000000 upper bound; exact lower-bound values use a shared Double comparison consistently across compiler targets, while values below the bound remain refused

vw requires width, vh requires height, and vmin or vmax require both; missing dimensions leave the declaration unadmitted, with no desktop, page-size or browser viewport inference

Line-height can compute to a unitless inherited factor or a point length; computed negative math heights clamp to zero, while font-size retains its existing positive admission range and spacing retains signed point lengths

Letter and word spacing require length results; their existing bare zero syntax remains available, and percentage spacing is not part of this profile

The existing per-property cascade, important priorities and explicit inheritance apply; deferred line and spacing math uses the winning final font size, and font shorthand accepts spaces and division inside balanced math functions

Invalid font declarations preserve an admitted fallback; a syntactically admitted winning metric that cannot compute to a finite bounded result raises EHPDFHeadlessRichTextCodecError before runs are returned

Converted values and stored binary64 arithmetic results must have magnitude at most 1e100, with length powers from -64 through 64; existing font-size and metric budgets still apply

Multiplication and division preflight extreme values before the operation so an unmasked floating-point overflow cannot escape; final checks use the same Double bound on all compiler targets, including subnormal divisors and values at the profile boundary

Math scans honor MaxNodes and recursive expressions honor MaxDepth; cancellation retains EHPDFOperationCancelled and returns no partial decoded runs, with fresh and reused decode options remaining usable afterward

Computed point values feed actual typed appearances and canonical RV serialization; default-profile rich FDF/XFDF imports use the same decoder without transporting custom viewport profiles

This finite profile does not provide other CSS math functions, numeric constants, escaped math function or unit names, metric-derived font units, logical or dynamic viewport units, custom properties or general CSS layout

The arithmetic and root-relative rules follow the supported portions of CSS Values and Units Level 4; the bounded supported profile above defines the library's current behavior

Native decoder · Decode options · Line height · Run spacing · Font shorthand