mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-21 04:02:53 +02:00
fix(markup): prefer sturdier math fonts over Latin Modern Math (#39811)
In Firefox and in Chromium on Linux, the `math` font family resolves to Latin Modern Math when it is installed. Its hairline strokes are too thin for screens, so MathML looks noticeably weaker than KaTeX on the same page. List sturdier math fonts before `math`: Cambria Math, STIX Two Math, New Computer Modern Math Book (aliased via `local()` because it shares its family name with the thinner Regular), Libertinus Math and DejaVu Math TeX Gyre. `math` stays as the fallback before Noto Sans Math. No fonts are shipped, so systems with only Latin Modern Math, or no math font at all, are unchanged. Fixes: https://github.com/go-gitea/gitea/issues/39665 Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
1 parent
7f420f8d82
commit
b0df5e4abe
1 file changed
+7
-2
@@ -2,8 +2,8 @@
|
||||
/* fonts */
|
||||
--fonts-proportional: -apple-system, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial;
|
||||
--fonts-monospace: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace, var(--fonts-emoji);
|
||||
/* Chromium's "math" is a font Linux and ChromeOS don't ship, so fall back to the math fonts they do, https://issues.chromium.org/issues/40069293 */
|
||||
--fonts-math: math, "STIX Two Math", "DejaVu Math TeX Gyre", "Noto Sans Math";
|
||||
/* sturdier fonts precede "math", which is thin Latin Modern Math in Firefox and Linux Chromium, DejaVu Math follows it for its small display operators, https://issues.chromium.org/issues/40069293 */
|
||||
--fonts-math: "Cambria Math", "STIX Two Math", gitea-math-book, "Libertinus Math", math, "DejaVu Math TeX Gyre", "Noto Sans Math";
|
||||
/* GitHub explicitly sets font names like: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Twemoji Mozilla";
|
||||
Actually "Twemoji Mozilla" emoji font is widely used by browsers like Firefox, Pale Moon, and it is more likely up-to-dated than the system emoji font.
|
||||
So not setting emoji font seems to be the best choice, here we just use a non-existing dummy font name and let browsers choose. */
|
||||
@@ -109,6 +109,11 @@ samp,
|
||||
font-size: 0.95em; /* compensate for monospace fonts being usually slightly larger */
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: gitea-math-book; /* the Book weight shares its family name with the thinner Regular */
|
||||
src: local("NewComputerModernMath-Book"), local("NewCMMath-Book");
|
||||
}
|
||||
|
||||
math {
|
||||
font-family: var(--fonts-math);
|
||||
font-size-adjust: ex-height 0.52; /* match KaTeX's x-height (0.431 × 1.21em) regardless of math font, https://github.com/w3c/mathml-core/issues/41 */
|
||||
|
||||
Reference in new issue
Block a user