Feature request: variable fonts (-> fewer files, smaller byte size, customisable)
pacien opened this issue · 1 comments
Is your feature request related to a problem? Please describe.
Currently, KaTeX relies on many font files for each variant (about
{AMS, Caligraphic, Fraktur, Main, Math, SansSerif, Script, Typewriter, Size1, .., Size4}
× {upright, italic} × {regular, bold}).
This amounts to about 350KB of font files for a each format.
This is quite a heavy to load,
as well as causing many requests,
causing multiple repaints and flickering on page load.
(This even if the math is pre-rendered).
Furthermore, customising the font weight or amount of slant for example
requires rebuilding the whole font set.
Describe the solution you'd like:
Using a variable font would resolve both issues
by having a single font file
defining the variants and being customisable through CSS.
At the time of writing, this is fairly well supported (96% browser coverage):
https://caniuse.com/variable-fonts
See also:
https://fonts.google.com/knowledge/introducing_type/introducing_variable_fonts
I don't think combining the existing fonts into one font will make them smaller. But plausibly there are some variable fonts that support e.g. roman and bold math from a common source, which could halve the size. But I don't know whether any such variable fonts exist yet, with all of LaTeX's mathematical symbols... Do you know one?