Skip to content

latex-rust 2.0.0

Choose a tag to compare

@jscarr64 jscarr64 released this 28 Sep 04:10
· 3 commits to main since this release

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::Glyph has a new field, scale: Dim, and the variant is now #[non_exhaustive]. Match it with BoxContent::Glyph { ch, glyph_id, .. } and build it with BoxContent::glyph(ch, glyph_id, scale). (#1)
  • STIX_TWO_MATH_OTF is now a static instead of a const. It can no longer be used in a const context. (#11)
  • Parsing and layout return Err for input nested deeper than DEFAULT_MAX_NESTING_DEPTH (32 parser levels): 15 nested fractions, roots, or scripts, or 31 nested groups, \left…\right pairs, or environments. Use ParseOptions / parse_with_options and layout_with_max_depth to 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 Err instead 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 \mathrm and \mathbf reach 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_OTF is linked into a binary once rather than once per use. (#11)

Added

  • BoxContent::glyph(ch, glyph_id, scale). (#1)
  • Dim::as_ratio() returns a Dim's exact value as a numerator and denominator. (#7)
  • MathFont::face() exposes the parsed OpenType face, and the crate re-exports ttf_parser. (#7)
  • ParseOptions, parse_with_options, layout_with_max_depth, and DEFAULT_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.