Motivation
Would you consider supporting alternative mathematical fonts, starting with STIX Two Math?
I use RaTeX as a pure-Rust formula renderer for vector previews embedded in DOCX/WMF output. The current KaTeX/Computer-Modern-like appearance works well, but some publishers and existing MathType documents expect a Times-like mathematical style. STIX Two Math would provide a complete OpenType math font for that use case and would be safer than substituting ordinary Times New Roman glyphs.
Current limitation
From the current 0.1.13 APIs and source, my understanding is:
LayoutOptions does not expose a math-font selection or font-provider option.
ratex-font uses fixed FontId roles and pre-extracted KaTeX metrics/math constants.
SvgOptions::font_dir is a directory for the expected KaTeX TTF filenames, rather than a general math-font selector.
- With
embed-fonts, font_dir is ignored and the embedded KaTeX fonts are used.
Because layout metrics are already determined before SVG rendering, replacing or renaming the TTF files alone would make advances, height/depth, italic corrections, stretchy delimiters, and glyph outlines inconsistent.
PR #93 appears to add a custom host font for the React Native/Expo InlineTeX component, rather than custom fonts for the core mathematical layout engine, so I believe this is a separate request.
Possible scope
A useful design might provide:
- A public math-font/font-provider abstraction.
- Glyph metrics and OpenType
MATH constants from the selected font.
- Glyph outlines from the same font in SVG and other renderers.
- STIX Two Math as the first supported alternative.
- The existing KaTeX fonts and output as the unchanged default.
Questions
- Is support for STIX Two Math or other OpenType math fonts within RaTeX's intended scope?
- Is there already a preferred architecture for a pluggable font provider?
- Would a scoped contribution that first adds STIX Two Math support be welcome?
Thanks for considering it.
Motivation
Would you consider supporting alternative mathematical fonts, starting with STIX Two Math?
I use RaTeX as a pure-Rust formula renderer for vector previews embedded in DOCX/WMF output. The current KaTeX/Computer-Modern-like appearance works well, but some publishers and existing MathType documents expect a Times-like mathematical style. STIX Two Math would provide a complete OpenType math font for that use case and would be safer than substituting ordinary Times New Roman glyphs.
Current limitation
From the current
0.1.13APIs and source, my understanding is:LayoutOptionsdoes not expose a math-font selection or font-provider option.ratex-fontuses fixedFontIdroles and pre-extracted KaTeX metrics/math constants.SvgOptions::font_diris a directory for the expected KaTeX TTF filenames, rather than a general math-font selector.embed-fonts,font_diris ignored and the embedded KaTeX fonts are used.Because layout metrics are already determined before SVG rendering, replacing or renaming the TTF files alone would make advances, height/depth, italic corrections, stretchy delimiters, and glyph outlines inconsistent.
PR #93 appears to add a custom host font for the React Native/Expo
InlineTeXcomponent, rather than custom fonts for the core mathematical layout engine, so I believe this is a separate request.Possible scope
A useful design might provide:
MATHconstants from the selected font.Questions
Thanks for considering it.