Skip to content

MathML in markup renders without a math font #39489

Description

@nschloe

Gitea Version

29.0.0+dev-1-ge0095af8c3 (demo.gitea.com)

What happened?

Since #38034 and #39337, <math> is allowed in markup, but Gitea doesn't set a font for it. Chrome then uses whatever font-family: math resolves to, which on Linux is not a font with an OpenType MATH table, even with math fonts installed. Brackets and braces don't stretch, ∑/∫ stay small and glyphs are mixed.

Setting a math font fixes the layout, but math fonts differ a lot in x-height (Latin Modern ≈ 0.43 em vs. ≈ 0.54 em for Noto Sans), so they look too small next to body text. KaTeX has the same issue and compensates with font-size: 1.21em. font-size-adjust: ex-height 0.52 (= 0.431 × 1.21) gives the same size for any math font.

Comparison in Chrome, math fonts with font-size-adjust: ex-height 0.52:

Image

New Computer Modern Math (OpenType Computer Modern) is nearly identical to KaTeX, so $…$ and <math> would look consistent. It is slightly heavier than Latin Modern Math, which reads better next to sans-serif text:

Image

Proposal:

.markup math {
  font-family: NewComputerModernMath, "Latin Modern Math", "STIX Two Math", "Cambria Math", math;
  font-size-adjust: ex-height 0.52;
}

plus bundling NewCMMath-Book.woff2 (670 KiB) via @font-face with local() first. It's only fetched on pages that contain <math>. The license is the GUST Font License, which should be checked. Alternatives are Latin Modern Math (same design but lighter, 379 KiB, also GUST) or STIX Two Math (OFL, 545 KiB).

The truncated overbrace in the screenshots is a Chrome bug, independent of the font: https://issues.chromium.org/issues/567630886.

How are you running Gitea?

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions