Fontlex ·
All demos ·
Download
Fontlex Math
The box below is a plain text box holding a little LaTeX. The font typesets it: fractions,
roots, superscripts and subscripts, Greek letters and a few symbols, laid out by the text engine that lays out
the letters, as you type. The characters stay exactly as typed. No script on this page lays anything out.
Each line is read on its own. A construct that isn't complete yet, or that breaks a rule
below, stays as its characters until it is. Inside a fraction the caret stays at the fraction's start: the
fraction's glyphs are drawn where they belong, but take no room of their own.
What it typesets
\frac{a}{b}, \sqrt{x}, x^2, x_1,
x^{n+1}, and both scripts at once, stacked (x_1^2, in either order).
- Braces as groups:
{a+b}^2.
- Symbols:
\alpha α\beta β\gamma γ\delta δ\epsilon ε\varepsilon ε\zeta ζ\eta η\theta θ\iota ι\kappa κ\lambda λ\mu μ\nu ν\xi ξ\pi π\rho ρ\sigma σ\tau τ\upsilon υ\phi ϕ\varphi φ\chi χ\psi ψ\omega ω\Gamma Γ\Delta Δ\Theta Θ\Lambda Λ\Xi Ξ\Pi Π\Sigma Σ\Phi Φ\Psi Ψ\Omega Ω\cdot ·\times ×\div ÷\pm ±\mp ∓\circ ∘\le ≤\leq ≤\ge ≥\geq ≥\ne ≠\neq ≠\approx ≈\equiv ≡\sim ∼\ll ≪\gg ≫\perp ⊥\parallel ∥\in ∈\notin ∉\subset ⊂\subseteq ⊆\cup ∪\cap ∩\forall ∀\exists ∃\neg ¬\land ∧\lor ∨\infty ∞\partial ∂\nabla ∇\sum ∑\prod ∏\int ∫\to →\rightarrow →\leftarrow ←\leftrightarrow ↔\Rightarrow ⇒\iff ⇔\ldots …\cdots ⋯\prime ′
- Constructs inside constructs, 3 deep, with at most 2 fractions inside one another,
and at most 24 characters in a construct that isn't inside another. Text inside a fraction or a
script is set smaller, in three sizes.
- A space inside a construct leaves it as its characters (WebKit gives every glyph of a space a space's
width, which would break the layout); spaces between formulas are fine.
How it works
Every character gets four empty glyphs after its own, and 238 passes, compiled to OpenType
substitutions, rewrite them: they match braces, check what is complete, give each character its role and
size, add up widths (in two digits, so the rules stay few), and finally turn every glyph into something
drawn or a mover. Positioning then does the layout. Outside fractions, text keeps its advance and is
raised or lowered. Inside a fraction nothing advances: each glyph is a mark attached to the one before it,
and movers between them carry the fraction's chain to the numerator, back over the bar and down to the
denominator, with the bars and root signs' overbars drawn by pieces hung off the chain.
The compiled font has 47,653 glyphs and 1,097 substitution and 301 positioning lookups. OpenType's lookup list holds only a few
thousand, so the compiler shares nested lookups between passes and splits any glyph that would need more
than a few dozen outcomes in one pass into two steps.
Results
Each line is shaped with the font, what it draws is read back from the glyphs (characters by name and
size, rules from their outlines), and compared with a separate Python model of the layout
(layout.py), to the font unit. Core Text (Safari, macOS) gives the same results.
| Lines | Count | HarfBuzz |
| Edge cases (incomplete and broken input) | 44 | 100.0% |
| Random formulas, some mistyped | 2,000 | 100.0% |
This page checks a sample each time it is built. The full check, 20,000 random lines and the
edge cases in HarfBuzz and Core Text, matches the model on every line: see
math/README.md.
Checked by screenshot (text against the outlines placed as HarfBuzz places them) in Chrome
and Safari's WebKit on macOS, and in Chromium and Firefox on Linux and Windows; and by typing into the box key
by key, which ends as the same text set at once does. A keystroke that completes a construct changes glyphs
before the caret, and with a simpler test font Chrome kept their old shaping, so this page still makes it lay
the box out again on every input (by switching font-kerning). Native Windows apps (DirectWrite)
aren't checked.
Base font: JetBrains Mono (SIL Open Font License).