<feed xmlns='http://www.w3.org/2005/Atom'>
<title>sketchbook.git/src/host/TimingAtlas.zig, branch main</title>
<subtitle>A small Zig platform for sketching games and toys</subtitle>
<id>https://git.0x4200.cafe/sketchbook.git/atom?h=main</id>
<link rel='self' href='https://git.0x4200.cafe/sketchbook.git/atom?h=main'/>
<link rel='alternate' type='text/html' href='https://git.0x4200.cafe/sketchbook.git/'/>
<updated>2026-11-17T15:15:01Z</updated>
<entry>
<title>text: sk.text measures anywhere, Frame.paragraph wraps, aligns, spans, reveals and finds a caret</title>
<updated>2026-11-17T15:15:01Z</updated>
<author>
<name>Gabriel Schneider</name>
<email>gbrls@0x4200.cafe</email>
</author>
<published>2026-11-17T12:06:20Z</published>
<link rel='alternate' type='text/html' href='https://git.0x4200.cafe/sketchbook.git/commit/?id=303478956e0086467a9073d7f6fa67b51b6580ad'/>
<id>urn:sha1:303478956e0086467a9073d7f6fa67b51b6580ad</id>
<content type='text'>
The ABI's one text entry is textRun (Host.VTable.textSize goes): a run in
a face at a scale, as data, its advance and line box and each byte's x,
a pure function of the font, the scale and the bytes, never of the
display; and font, a face for a sketch's own TTF/OTF bytes (abi.Face is
non-exhaustive: faces past the ten are a sketch's). The native host
serves them from vendor/text.c (sk_text_run, sk_text_font), the web host
from canvas measureText and FontFace (web/host.js), and the web draws
each run in the page's monospace or sans-serif in the face's weight and
style instead of 8 px a character.

src/sketch/text.zig (sk.text) does the rest in plain Zig, the same on
every host: size, layout and font anywhere, update included (the glue
sets the host before each call into the sketch; a test binary has none
and calls sketchbook-text directly, which App.addTest now links); a
Paragraph is a face, scale and colour, a width to wrap at spaces, an
alignment, spans (from a byte on: a colour, a face, a scale), reveal
(the first N glyphs drawn, the layout the whole text's) and a caret
byte, and its Layout the size, lines, glyphs and the caret's place.
f.paragraph draws one, a Command.text a piece. f.text, f.textIn and
f.print are a paragraph with no width when the bytes hold a \n, else
the one command they were; host.textSize and textSizeIn stay, one line
through textRun.

Test: sk.text's own tests (a wrap, the space not counted, centred and
right, a caret at a line's start and end and after a \n, a span twice
the size, a word wider than the width, an empty text; reveal drawing the
first glyphs of the same layout), run through sketchbook-text; and
test/text.zig draws a centred paragraph with a red and a double-size span
and a caret from its Layout, which test/text.script pins. zig build
test-text runs these and the atlas's comparison with pardes's raster.
Every other pinned pixel of test/text.script holds: the lines it pins are
the same pixels Pango drew.

Co-Authored-By: Claude Opus 5.5 &lt;noreply@anthropic.com&gt;
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
</content>
</entry>
<entry>
<title>text: FreeType and HarfBuzz in the build, Pango, Cairo and glib out, glyphs from one atlas</title>
<updated>2026-11-17T15:15:01Z</updated>
<author>
<name>Gabriel Schneider</name>
<email>gbrls@0x4200.cafe</email>
</author>
<published>2026-11-17T07:02:44Z</published>
<link rel='alternate' type='text/html' href='https://git.0x4200.cafe/sketchbook.git/commit/?id=1f9fa4fc66c68e66e7653498f04d17052833d6c3'/>
<id>urn:sha1:1f9fa4fc66c68e66e7653498f04d17052833d6c3</id>
<content type='text'>
build.zig.zon gains the freetype and harfbuzz packages pardes pins (lazy:
a gpu-only embedder brings its own), and build.zig compiles them, with the
flags pardes's window uses, together with pardes's vendor/font.c
(unchanged) and a new vendor/text.c into one static library,
sketchbook-text, which the host links. vendor/text.c replaces the Pango
shim: the ten bundled faces by #embed, opened on first use by FreeType
(font.c) and by HarfBuzz's own OpenType functions over the same bytes;
sk_text_shape shapes a run left to right at a pixel size, each advance
rounded to a whole pixel, with the line box font.c's cell metrics give;
a codepoint the face lacks comes from one fallback face (ponytail: no
fontconfig, no bidi); sk_text_font takes a sketch's own font from bytes.

src/host/Glyphs.zig is the renderer: a text command is shaped at its
canvas size, each glyph rastered by font.c's ui_font_raster at its device
size and kept, trimmed to its ink (Atlas.inkBounds), in shelves of one
2048x2048 atlas, white premultiplied by coverage, cleared and refilled
when full. Consecutive text commands are one SDL_RenderGeometry call;
upright text lands on whole device pixels, NEAREST; textScaled (and a
glyph past 512 device pixels) is unsnapped, LINEAR. The SDL debug font
fallback off Linux goes: the faces are built in everywhere.
Host.textSize measures with the same call. test/fonts.c (a Pango
specimen outside the build) goes.

Measured: a cold Debug build of the host 39.8 s before, 43.7 s after;
the Debug host 117.7 MB (35.6 MB stripped) before, 159.5 MB (46.8 MB)
after, with 6 shared libraries where it loaded 41 (pango, cairo, glib,
fontconfig, the system freetype and harfbuzz and theirs). A frame of
4500 glyphs, half changing every frame (ReleaseFast, headless): 27.5 M
instructions and 2.80 ms of CPU before, 5.33 M and 0.40 ms after; all
static: 6.44 M and 0.47 ms before, 5.28 M and 0.42 ms after.

zig build test: 192/192 steps, 146/146 tests; test/text.script's pinned
pixels hold.

Co-Authored-By: Claude Opus 5.5 &lt;noreply@anthropic.com&gt;
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
</content>
</entry>
<entry>
<title>Add display-paced frame timing and presentation feedback in Zig</title>
<updated>2026-11-16T23:31:59Z</updated>
<author>
<name>Gabriel Schneider</name>
<email>gbrls@0x4200.cafe</email>
</author>
<published>2026-11-16T23:31:59Z</published>
<link rel='alternate' type='text/html' href='https://git.0x4200.cafe/sketchbook.git/commit/?id=82fca5c9f29124f37f6dcd08e73e6999ce44a69d'/>
<id>urn:sha1:82fca5c9f29124f37f6dcd08e73e6999ce44a69d</id>
<content type='text'>
</content>
</entry>
</feed>
