summaryrefslogtreecommitdiff
path: root/vendor/fonts/README.md
blob: d1bf9d93c768dc6c7305ae62476c2a7cc1709a69 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Native text

Linux Sketchbook text uses bundled **Go Mono** through PangoCairo: HarfBuzz
shaping, Fontconfig fallback and FreeType/Cairo grayscale antialiasing with light
hinting. This follows the rendering quality choices in Pardes `src/gui/font.c`;
it does not copy Pardes's terminal-cell shaping, bold synthesis or glyph atlas.

`Go-Mono.ttf` is from the Go project's official `golang/image` repository:
https://github.com/golang/image/tree/master/font/gofont/ttfs
SHA-256: `8bc66a0154bbf69cd24e5bde41a12ec9495c8a242c5def2255e4a164900f1ed7`.
The complete Bigelow & Holmes / Go font license is in `LICENSE`.

The font is embedded in the binary with C23 `#embed`. It is registered in a
private Fontconfig config through a Linux memfd, so moving the executable does
not require a font installation or the source checkout. Installed outline fonts
provide Unicode fallback, in the order listed in `vendor/text.c`; actual glyph
coverage and emoji color depend on those fonts. Color font paint is preserved.
No system Fontconfig settings are modified.

The `f.text`/`f.print` API is unchanged. Their x/y positions mean line-box top.
Scale 1 uses a nominal 13px font: Go Mono measures 8px ASCII advance and 16px
line height on the tested stack. At other sizes advances may round to a physical
pixel. Applications should allow a 16×scale line box and avoid slicing UTF-8 at
arbitrary byte boundaries. Pango shapes each supplied string independently;
applications still perform wrapping and clipping. Explicit newlines are not a
layout API. Other platforms retain SDL's debug-font fallback for now.

`sk_text_measure` lays a string out the same way and returns its advance
width and line height (`Host.textSize`). `SKETCHBOOK_FONT`, in the
environment, names an installed family to put before Go Mono.

Text is rasterized at the renderer's physical pixel density (including logical
presentation scale), and texture origins snap to physical pixels. Whole-run
textures retain antialiasing and shaping; no scaled 8×8 bitmap text is involved.
The renderer-owned cache retains at most 512 strings / 16 MiB of pixel data.
Only prior-frame textures can be evicted; exceptionally dense frames flush and
release temporary textures rather than growing the cache. Renderer destruction
releases the font map, descriptors and keys after SDL releases its textures.

Native Linux builds need `pkg-config`, `pangocairo`, and `pangoft2` development
packages, in addition to SDL. The resulting executable uses the system Pango,
Cairo, HarfBuzz, Fontconfig and FreeType libraries.

Run the independent regression and specimen (with system SDL3):

```sh
cc -std=c23 -Wall -Wextra -Werror -O2 test/fonts.c -o /tmp/sketchbook-fonts \
  $(pkg-config --cflags --libs sdl3 pangocairo pangoft2) -lm
/tmp/sketchbook-fonts /tmp/sketchbook-fonts.png
```

It checks the primary font's advance/line box, Unicode fallback, zero-advance
combining marks, Arabic lam-alef shaping, 2× rendering density, clipping, cache
eviction and renderer cleanup. The specimen includes Latin, Greek, Cyrillic,
Japanese, Arabic, Hebrew and symbols/emoji. Missing fallback fonts fail the
coverage assertion rather than silently claiming complete Unicode support.