cogra
GitHub

Fonts

In figures

The package ships TeX Gyre Heros (the sans-serif for figure labels) and TeX Gyre Schola (the serif, for labels="serif" and papers), and registers them with matplotlib on import. Figures use these clean faces; save_vintage() adds the wear afterwards, to the whole figure.

In slides and documents

For slides, word processors and design apps there are also scanned versions, installable as ordinary fonts: Schola Scan and Heros Scan, and softer Soft versions (download the .ttf files).

The 1-bit archival-scan texture from cogra.wear (--look scan), baked into installable TTF fonts for PowerPoint, Keynote, Canva, Word, etc.

Files

All 16 fonts are ready to install; there is nothing to build. Rebuild only to change the settings (see Knobs). - build_scan_font.py: rebuilds them from ../../src/cogra/fonts/texgyreschola-*.otf / texgyreheros-*.otf (Heros v2.004 from CTAN, fonts/tex-gyre/opentype). - specimen.html: preview page (serve this folder to view it); a checkbox switches to the Soft families. - GUST-FONT-LICENSE.txt: license, inherited from TeX Gyre.

Installing

How it works

Each glyph is rendered at 432 px/em and run through the same steps as the scan look in cogra.wear: a slight edge wobble, blurring plus a noisy threshold (copy fill-in), and a letter-scale threshold field so some letters come out heavier than others. Each glyph is then sampled down to a 36 px/em 1-bit grid and traced along the pixel edges, so the stair-stepped edges stay crisp at any size. Kerning and the f-ligatures come from the source font.

Every glyph has 3 noise variants. An OpenType calt feature rotates through them along a line, so repeated letters do not look stamped. Browsers and Keynote apply calt by default. PowerPoint and Canva may not, in which case every letter uses variant 0, which still looks scanned.

Soft

python3 build_scan_font.py --soft                  # Schola Scan Soft
python3 build_scan_font.py --soft --family heros   # Heros Scan Soft

The 1-bit glyphs are exactly those of Schola Scan / Heros Scan. Some edge pixels next to them get a grey bleed: one scanner pixel wide, mostly on the lower-right side of strokes (like a slight press shadow), broken up by fine noise so long stretches of edge stay crisp, and in two greys (17% and 30% of a warm black). Only pixels that share a side with the ink can bleed, not ones that touch it only at a corner, so corners stay round.

A font outline can only be solid, so the greys are colour-font layers (OpenType COLR v0 with a CPAL palette) drawn under the glyph.

where result
Chrome, Edge, Firefox; macOS apps that use Core Text (Keynote, Pages) the grey bleed is drawn (tested in Chromium and Core Text)
Windows (DirectWrite), Safari, PowerPoint, Word, Canva expected to work, not tested
apps without colour-font support the plain 1-bit glyph, the same as Schola Scan

Knobs:

python3 build_scan_font.py --soft --soft-amount 0.3                # less of the edge bleeds (default 0.45)
python3 build_scan_font.py --soft --soft-greys 0.14 0.25           # lighter greys (default 0.17 0.30)

The bleed colour is fixed (warm black at partial opacity), not the text colour, so it reads as intended on light backgrounds only. With coloured or white-on-dark text, use the non-soft fonts.

Knobs

python3 build_scan_font.py --family heros     # build Heros Scan instead of Schola Scan
python3 build_scan_font.py --em-px 28      # chunkier stair-steps (coarser scan)
python3 build_scan_font.py --em-px 56      # finer scan, closer to the clean face
python3 build_scan_font.py --fill 0.33     # heavier fill-in (the scan look's value)
python3 build_scan_font.py --weight 1.6    # more letter-to-letter weight variation
python3 build_scan_font.py --strength 1.5  # rougher edges

Rebuilding needs pip install "cogra[fonts]". A full build of one family (four styles) takes about 8 minutes on 8 cores, and overwrites the files in fonts/. All knobs combine with --family.

Caveats