Files
docx/scripts
Dolan f03253eb22 feat(layout): lay out equations Word builds up, as Word does (#3685)
* feat(layout): lay out equations Word builds up, as Word does

Lay out the equations Word builds up (fractions, scripts, roots, sums and
integrals with their limits, brackets that grow, matrices and cases,
accents, bars, functions and limits, and braces) by the rules of Cambria
Math's OpenType MATH table, with the font's own widths, ink and
constants, as Word's PDFs of word-stops-equations, -equation-settings
and -equation-font show. Each probe's width in its line of text is
Word's to within 0.03 points and its line's height within Word's own
drawing grid, but two roots, which are within 0.1 points.

What of Cambria Math the layout needs is generated from Word's own copy
of the font by scripts/generate-cambria-math.ts into
src/layout/cambria-math.ts, which replaces the widths read from Word's
PDFs (equation-widths.ts) and the table of Cambria Math's own widths
within 1.5 thousandths of an em, the integrals with their italic
correction, and ◇, which Cambria Math hasn't, stops.

The layout keeps stopping where Word's PDFs leave the result unsettled:
scripts in sizes other than 11 points, superscripts in cramped parts,
brackets between two sizes, matrices whose rows are too tall to be
single spaced, thin spaces beside fractions, brackets, sums and
functions, boxes, normal text, equations too long for their line, maths
fonts other than Cambria Math, margins of displayed equations and space
between equations side by side in one m:oMathPara. Guessing past a stop,
an equation alone in its paragraph is laid out displayed first.
word-stops-equations2.ts writes the probes that settle them, each
validated against ooxml-schemas/.

* fix(layout): stop at a digit in a bold run or another alphabet, which Word hasn't been seen drawing

A digit in a bold or bold italic run was laid out as the plain digit, though Word draws a bold run's letters in
Unicode's bold alphabet (word-stops-equations.docx EQ19), which has bold digits too, wider than the plain ones. No
probe has shown which Word draws, so the layout stops there, as it does for a digit in another alphabet, and
word-stops-equations2.ts's EQ45 asks Word. The alphabets' unused first digits are gone.

* fix(layout): lay out an equation in a line of text in a numbered paragraph, stopping only at one alone after its list's number

* test(layout): probe an equation displayed (m:oMathPara) alone after its list's number too, as EQ38d
2026-10-05 15:41:50 +01:00
..