Pixel font: Monocraft-based bitmap font with Greek and math symbols #20

Closed
opened 2026-11-01 23:25:32 +00:00 by Weissstreifen · 0 comments

Our own pixel font, with the Latin, Greek and math coverage the charts and formulas (#18) need, as a bitmap font in the format of parin_kit#141 (PNG sheet + txt).

Base: Monocraft (v4.2.1, OFL-1.1, Minecraft style, 1475 glyphs; there is also a Nerd Fonts-patched build in its releases). Checked:

  • Pixel grid: 120 units per pixel at 1080 units per em, so it is 9 px per em, 6 px advance. Rasterized at exactly 9 px without anti-aliasing it gives perfect pixels. Draw it x2 or x3 on the 1280x720 canvas.
  • Covered: all Greek (upper and lower), äöüÄÖÜß, ± × ÷ · − ∞ ∂ ∑ ∫ ≠ → ← ⇒ ⇔ ∀ ∃ ¬ ∧ ∨ ° ‰, superscript and subscript digits.
  • Missing, to draw ourselves: √ ∇ ∏ ∬ ≈ ≡ ≤ ≥ ≪ ≫ ∈ ∪ ∅ ⁿ, ℕ ℤ ℚ ℝ ℂ ℏ ℓ, ⟨ ⟩ ⌈ ⌉ ⌊ ⌋ ‖. (√, big brackets and fraction bars are drawn as shapes by the formula renderer anyway, but text needs them too.)
  • Weights: Regular for labels, Bold or Black for titles and big numbers.
  • It is monospaced. The sheet loader finds each glyph's width from its opaque columns, which makes it proportional like Minecraft's own font. Digits keep a fixed width (tabularDigits = true) so counting numbers don't jitter.

Work:

  1. tools/make_font.py (Pillow + fontTools): rasterize the chosen characters of Monocraft at 9 px (fontmode = "1") into assets/fonts/text.png + text.txt, one sheet per weight, with the baseline and offsets read from the font.
  2. Draw the missing glyphs into the sheet in Aseprite (they reload live once parin_kit#141 has hot reload), and touch up glyphs that should look different (e.g. ß comes out like a β).
  3. A script sheet for exponents and limits in formulas (#18): Monocraft's superscript digits are a start. Letters need a small 5-6 px font, drawn or taken from another OFL font.
  4. Put Monocraft's OFL.txt in assets/fonts/ and credit it in the README (the OFL allows changes and embedding, but the changed font must not be called "Monocraft").
  5. Theme (#3) chooses the font per role: title, label, number, formula.

Until parin_kit#141 lands, keep a small loader in source/bitmap_font.d with // TODO: move to parin_kit, see parin_kit#141.

Done when: labels, numbers, Greek and the math symbols draw crisp at x2 and x3, the missing glyphs are drawn, and editing the PNG updates the running player.

Our own pixel font, with the Latin, Greek and math coverage the charts and formulas (#18) need, as a bitmap font in the format of **parin_kit#141** (PNG sheet + txt). **Base: [Monocraft](https://github.com/IdreesInc/Monocraft)** (v4.2.1, OFL-1.1, Minecraft style, 1475 glyphs; there is also a Nerd Fonts-patched build in its releases). Checked: - Pixel grid: 120 units per pixel at 1080 units per em, so it is **9 px per em, 6 px advance**. Rasterized at exactly 9 px without anti-aliasing it gives perfect pixels. Draw it x2 or x3 on the 1280x720 canvas. - Covered: all Greek (upper and lower), äöüÄÖÜß, `± × ÷ · − ∞ ∂ ∑ ∫ ≠ → ← ⇒ ⇔ ∀ ∃ ¬ ∧ ∨ ° ‰`, superscript and subscript digits. - **Missing, to draw ourselves:** `√ ∇ ∏ ∬ ≈ ≡ ≤ ≥ ≪ ≫ ∈ ∪ ∅ ⁿ`, `ℕ ℤ ℚ ℝ ℂ ℏ ℓ`, `⟨ ⟩ ⌈ ⌉ ⌊ ⌋ ‖`. (`√`, big brackets and fraction bars are drawn as shapes by the formula renderer anyway, but text needs them too.) - Weights: Regular for labels, Bold or Black for titles and big numbers. - It is monospaced. The sheet loader finds each glyph's width from its opaque columns, which makes it proportional like Minecraft's own font. Digits keep a fixed width (`tabularDigits = true`) so counting numbers don't jitter. **Work:** 1. `tools/make_font.py` (Pillow + fontTools): rasterize the chosen characters of Monocraft at 9 px (`fontmode = "1"`) into `assets/fonts/text.png` + `text.txt`, one sheet per weight, with the baseline and offsets read from the font. 2. Draw the missing glyphs into the sheet in Aseprite (they reload live once parin_kit#141 has hot reload), and touch up glyphs that should look different (e.g. `ß` comes out like a `β`). 3. A script sheet for exponents and limits in formulas (#18): Monocraft's superscript digits are a start. Letters need a small 5-6 px font, drawn or taken from another OFL font. 4. Put Monocraft's `OFL.txt` in `assets/fonts/` and credit it in the README (the OFL allows changes and embedding, but the changed font must not be called "Monocraft"). 5. Theme (#3) chooses the font per role: title, label, number, formula. Until parin_kit#141 lands, keep a small loader in `source/bitmap_font.d` with `// TODO: move to parin_kit, see parin_kit#141`. **Done when:** labels, numbers, Greek and the math symbols draw crisp at x2 and x3, the missing glyphs are drawn, and editing the PNG updates the running player.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Weissstreifen/daviz#20
No description provided.