latex-rust 2.0.0
Upgrade notice. 2.0.0 fixes a crash on deeply nested input and several rendering errors in 1.x. It has breaking changes, listed below. If you cannot take breaking changes yet, use 1.0.5, which has the crash fix and the rendering fixes #1–#5 without API changes. If you use the egui backend, use 2.0.1, which fixes glyphs that failed to render there.
This release fixes the eight defects Tom Clark reported while integrating latex-rust into IronLAB (issues #1–#7 and #11). Several of them change what the renderer draws.
Breaking changes
BoxContent::Glyphhas a new field,scale: Dim, and the variant is now#[non_exhaustive]. Match it withBoxContent::Glyph { ch, glyph_id, .. }and build it withBoxContent::glyph(ch, glyph_id, scale). (#1)STIX_TWO_MATH_OTFis now astaticinstead of aconst. It can no longer be used in aconstcontext. (#11)- Parsing and layout return
Errfor input nested deeper thanDEFAULT_MAX_NESTING_DEPTH(32 parser levels): 15 nested fractions, roots, or scripts, or 31 nested groups,\left…\rightpairs, or environments. UseParseOptions/parse_with_optionsandlayout_with_max_depthto change the limit. (#6) - Output changes: variable letters are drawn in math italic, math-mode
-is drawn as U+2212, script glyphs are drawn smaller, and diacritic accents sit lower. Code that pinned the old dimensions or images will see new values.
Fixed
- Deeply nested input returns
Errinstead of aborting the process with a stack overflow. (#6) - Superscripts, subscripts, and limits are drawn at script size in the SVG, PNG, and egui renderers. Before, they were positioned at script size but drawn at full size. (#1)
- Diacritic accents (
\hat,\dot,\bar, and the rest) are placed by the TeX rule. Before, they sat one accent base height too high. (#5) - Font switches such as
\mathrmand\mathbfreach nested subformulae (script bases, fractions, radicals). (#4) - Unstyled Latin letters and lowercase Greek letters are set in math italic, as TeX does. Digits, uppercase Greek,
\mathrm,\text, and operator names stay upright. (#2) - A math-mode
-is drawn as U+2212 MINUS SIGN instead of the hyphen. (#3) STIX_TWO_MATH_OTFis linked into a binary once rather than once per use. (#11)
Added
BoxContent::glyph(ch, glyph_id, scale). (#1)Dim::as_ratio()returns aDim's exact value as a numerator and denominator. (#7)MathFont::face()exposes the parsed OpenType face, and the crate re-exportsttf_parser. (#7)ParseOptions,parse_with_options,layout_with_max_depth, andDEFAULT_MAX_NESTING_DEPTH. (#6)
Advisory
A RustSec advisory for the crash fixed by #6 is being requested. Its identifier will be added here once it is assigned.
Thanks
Tom Clark (IronLAB) reported all eight issues with reproductions and proposed fixes, and contributed the pull requests for #4, #7, and #11 and the first depth limit for #6.