All examples By author By category About

cben

Dumping ground: Latin Modern subsetted to just 0-9 digits, see https://github.com/cben/mathdown/issues/95

Abandoned work for https://github.com/cben/mathdown/issues/95

This didn't make the cut quality-wise, but I'm also not 100% I fully complied with Latin Modern's license.

This directory contains a tiny font derived from Latin Modern Ver. 2.004, 30.10.2009. Unlike the rest of mathdown I can NOT license it under MIT license; it's governed by Latin Modern's GFL/LPPL license - see LICENSE.

Goal

Mathdown strives to use system fonts for fast loading and the main font I use is Georgia (available basically everywhere except linuxes that didn't install msttcorefonts and android). I love Georgia except its 0-9 digits which are "old style numerals" and small. While cute, they are small such that zero is nearly indistinguishable from lowercase o, and distractingly different from other digits styles user will see - in math and in monospace.

So I decided to override just the digits. See https://github.com/cben/mathdown/issues/95 for long experiments. I first tried using unicode-range with system fonts only but it failed on compatibility grounds (especially Firefox). So instead I'm serving a tiny webfont consisting of only digits => perfect compatibility (expect IE8 that shows unmodified Georgia) and for some reason better kerning.

Now that I'm serving a webfont I could pick digits from any free font. Which one? I chose to match the digits MathJax uses, for consistency. Unfortunately I can't use the MathJax web font directly because it contains no bold italic but it's directly derived from Computer Modern, which is available as OTF from the Latin Modern project. (TODO: can I mix MathJax 3 variants with only bold italic here? Will size match? Could it make load slower for docs that have no math?)

Technique

For simplicity, I'm only serving WOFF format (IE9+), and embedding in CSS which puts it on the critical path. http://miranj.in/blog/2015/collateral-damage makes a good case that FOUT is better than FOIT but in my case it'd just digits within mixed text appearing/changing later so I think FOIT is OK. And it's only 15-20K.

I grabbed lmroman10-*.otf from https://www.ctan.org/tex-archive/fonts/lm/fonts/opentype/public/lm/ (size 10 being the only one with bold italic).

To subset the font I used Font Squirrel's Generator, asking to subset to only 0-9 digits, match Georgia's x-height, use ("flatten") tnum glyphs, and embed in base64 CSS. See font_squirrel_generator_config.txt.

I then renamed the files and the CSS font-famility (but did not change metadata inside the WOFF).