Skip to content

Feature request: support STIX Two Math and pluggable OpenType math fonts #131

Description

@cesaryuan

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:

  1. A public math-font/font-provider abstraction.
  2. Glyph metrics and OpenType MATH constants from the selected font.
  3. Glyph outlines from the same font in SVG and other renderers.
  4. STIX Two Math as the first supported alternative.
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions