From 7dd447b7c8a21187af4fabade2111a0016e4b3a3 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 14:38:11 -0300 Subject: sketchbook: JetBrains Mono NL (no ligatures) for the code faces, and its medium weight (.code_medium) --- README.md | 6 +++--- src/abi.zig | 5 +++-- test/text.script | 8 ++++---- test/text.zig | 6 +++--- vendor/fonts/JetBrainsMono-Bold.ttf | Bin 277828 -> 0 bytes vendor/fonts/JetBrainsMono-Italic.ttf | Bin 276840 -> 0 bytes vendor/fonts/JetBrainsMono-Regular.ttf | Bin 273900 -> 0 bytes vendor/fonts/JetBrainsMonoNL-Bold.ttf | Bin 0 -> 210988 bytes vendor/fonts/JetBrainsMonoNL-Italic.ttf | Bin 0 -> 211624 bytes vendor/fonts/JetBrainsMonoNL-Medium.ttf | Bin 0 -> 208276 bytes vendor/fonts/JetBrainsMonoNL-Regular.ttf | Bin 0 -> 208576 bytes vendor/fonts/README.md | 7 ++++--- vendor/text.c | 19 ++++++++++++------- vendor/text.h | 2 +- 14 files changed, 30 insertions(+), 23 deletions(-) delete mode 100644 vendor/fonts/JetBrainsMono-Bold.ttf delete mode 100644 vendor/fonts/JetBrainsMono-Italic.ttf delete mode 100644 vendor/fonts/JetBrainsMono-Regular.ttf create mode 100644 vendor/fonts/JetBrainsMonoNL-Bold.ttf create mode 100644 vendor/fonts/JetBrainsMonoNL-Italic.ttf create mode 100644 vendor/fonts/JetBrainsMonoNL-Medium.ttf create mode 100644 vendor/fonts/JetBrainsMonoNL-Regular.ttf diff --git a/README.md b/README.md index 01c86cb..e2d8ab6 100644 --- a/README.md +++ b/README.md @@ -114,9 +114,9 @@ character. face of the Go family, all six bundled in the binary (`sk.Face`): `.mono`, `.mono_bold`, `.mono_italic` for data and code, `.sans`, `.sans_medium`, `.sans_bold` for what is said about it; and `.code`, `.code_bold`, -`.code_italic` are JetBrains Mono, bundled too, for programs. -`f.host.textSizeIn(face, scale, bytes)` measures a line. The six -monospaced faces advance alike (0.6 em: whole pixels at 20, 25, 30, 35, 45 +`.code_italic`, `.code_medium` are JetBrains Mono NL (no ligatures), +bundled too, for programs. `f.host.textSizeIn(face, scale, bytes)` +measures a line. The seven monospaced faces advance alike (0.6 em: whole pixels at 20, 25, 30, 35, 45 and 60 px and at their doubles), so columns of text need no measuring; JetBrains Mono's line box is taller (ascent 1.02 em, where Go's is 0.945). The web host draws every face as its one. diff --git a/src/abi.zig b/src/abi.zig index 0cce939..a7a5cce 100644 --- a/src/abi.zig +++ b/src/abi.zig @@ -57,11 +57,12 @@ pub const Color = extern struct { } }; -/// The face a text is set in: the Go family, and JetBrains Mono (`code`) +/// The face a text is set in: the Go family, and JetBrains Mono NL (`code`, +/// without ligatures; its medium weight for small sizes on a dark ground) /// for programs, all bundled with the native host. Mono is for data, sans /// for what is said about it. The web host has one face, the page's /// `monospace`. -pub const Face = enum(u8) { mono, mono_bold, mono_italic, sans, sans_medium, sans_bold, code, code_bold, code_italic }; +pub const Face = enum(u8) { mono, mono_bold, mono_italic, sans, sans_medium, sans_bold, code, code_bold, code_italic, code_medium }; /// How 2D drawing combines with what is already there (`Command.blend`). /// Both are fixed-function on both hosts and match: `alpha` is source diff --git a/test/text.script b/test/text.script index 82ce32c..776cc41 100644 --- a/test/text.script +++ b/test/text.script @@ -15,7 +15,7 @@ expect-pixel .zig-cache/text/native.png 180 222 16 16 16 255 # of scale 3's 230), not the 120 that scale 1.5 would shape. expect-pixel .zig-cache/text/native.png 123 265 32 64 96 255 expect-pixel .zig-cache/text/native.png 127 256 16 16 16 255 -# JetBrains Mono (`.code`) advances as the mono faces do: eleven characters -# at scale 2 are 176 px, on its own taller line. -expect-pixel .zig-cache/text/native.png 184 275 32 64 96 255 -expect-pixel .zig-cache/text/native.png 190 290 16 16 16 255 +# JetBrains Mono NL (`.code_medium`) advances as the mono faces do, with no +# ligatures: twelve characters at scale 2 are 192 px, on its own taller line. +expect-pixel .zig-cache/text/native.png 200 275 32 64 96 255 +expect-pixel .zig-cache/text/native.png 206 290 16 16 16 255 diff --git a/test/text.zig b/test/text.zig index 1318d1f..d0e0eea 100644 --- a/test/text.zig +++ b/test/text.zig @@ -16,9 +16,9 @@ const lines = [_]struct { scale: f32, text: []const u8, face: sk.Face = .mono, r // Rasterized at 3 and drawn at 1.5: half of what scale 3 covers (115 px // for ten digits), not what scale 1.5 would shape (120). .{ .scale = 1.5, .text = "0123456789", .raster = 3 }, - // JetBrains Mono, for code, advances as Go Mono does: ten columns - // at scale 2 are the 160 px of the bold line above. - .{ .scale = 2, .text = "rsp \u{2014}\u{25b8} 0x10", .face = .code }, + // JetBrains Mono NL, for code, advances as Go Mono does. + // No ligatures: `->` is two characters, as it is in a source. + .{ .scale = 2, .text = "p->n != 0x10", .face = .code_medium }, }; pub fn draw(f: *sk.Frame) void { diff --git a/vendor/fonts/JetBrainsMono-Bold.ttf b/vendor/fonts/JetBrainsMono-Bold.ttf deleted file mode 100644 index 8c93043..0000000 Binary files a/vendor/fonts/JetBrainsMono-Bold.ttf and /dev/null differ diff --git a/vendor/fonts/JetBrainsMono-Italic.ttf b/vendor/fonts/JetBrainsMono-Italic.ttf deleted file mode 100644 index ccc9d6a..0000000 Binary files a/vendor/fonts/JetBrainsMono-Italic.ttf and /dev/null differ diff --git a/vendor/fonts/JetBrainsMono-Regular.ttf b/vendor/fonts/JetBrainsMono-Regular.ttf deleted file mode 100644 index dff66cc..0000000 Binary files a/vendor/fonts/JetBrainsMono-Regular.ttf and /dev/null differ diff --git a/vendor/fonts/JetBrainsMonoNL-Bold.ttf b/vendor/fonts/JetBrainsMonoNL-Bold.ttf new file mode 100644 index 0000000..f78f84f Binary files /dev/null and b/vendor/fonts/JetBrainsMonoNL-Bold.ttf differ diff --git a/vendor/fonts/JetBrainsMonoNL-Italic.ttf b/vendor/fonts/JetBrainsMonoNL-Italic.ttf new file mode 100644 index 0000000..4e9c380 Binary files /dev/null and b/vendor/fonts/JetBrainsMonoNL-Italic.ttf differ diff --git a/vendor/fonts/JetBrainsMonoNL-Medium.ttf b/vendor/fonts/JetBrainsMonoNL-Medium.ttf new file mode 100644 index 0000000..1454372 Binary files /dev/null and b/vendor/fonts/JetBrainsMonoNL-Medium.ttf differ diff --git a/vendor/fonts/JetBrainsMonoNL-Regular.ttf b/vendor/fonts/JetBrainsMonoNL-Regular.ttf new file mode 100644 index 0000000..70d2ec9 Binary files /dev/null and b/vendor/fonts/JetBrainsMonoNL-Regular.ttf differ diff --git a/vendor/fonts/README.md b/vendor/fonts/README.md index 34b26a0..41a51fc 100644 --- a/vendor/fonts/README.md +++ b/vendor/fonts/README.md @@ -17,9 +17,10 @@ Five more faces of the same family are bundled the same way, for Each is a font description of its own (`sk_text_draw_face`); the sans faces fall back to installed sans families instead of mono ones. -Three faces of **JetBrains Mono** follow them (`.code`, `.code_bold`, -`.code_italic`): `JetBrainsMono-Regular.ttf`, `-Bold.ttf` and -`-Italic.ttf` as the `ttf-jetbrains-mono` package installs them, under the +Four faces of **JetBrains Mono NL** (the family without ligatures) follow +them (`.code`, `.code_bold`, `.code_italic`, `.code_medium`): +`JetBrainsMonoNL-Regular.ttf`, `-Bold.ttf`, `-Italic.ttf` and `-Medium.ttf` +as the `ttf-jetbrains-mono` package installs them, under the SIL Open Font License in `LICENSE-JetBrainsMono`. They fall back as the mono faces do. diff --git a/vendor/text.c b/vendor/text.c index f901f90..26297e4 100644 --- a/vendor/text.c +++ b/vendor/text.c @@ -36,15 +36,19 @@ static const unsigned char go_medium[] = { static const unsigned char go_bold[] = { #embed "fonts/Go-Bold.ttf" }; -/* JetBrains Mono, for code: the same 0.6 em advance as Go Mono. */ +/* JetBrains Mono NL, for code: the same 0.6 em advance as Go Mono, and no + ligatures (`->` stays two characters, as it is in the source). */ static const unsigned char jb_mono[] = { -#embed "fonts/JetBrainsMono-Regular.ttf" +#embed "fonts/JetBrainsMonoNL-Regular.ttf" }; static const unsigned char jb_mono_bold[] = { -#embed "fonts/JetBrainsMono-Bold.ttf" +#embed "fonts/JetBrainsMonoNL-Bold.ttf" }; static const unsigned char jb_mono_italic[] = { -#embed "fonts/JetBrainsMono-Italic.ttf" +#embed "fonts/JetBrainsMonoNL-Italic.ttf" +}; +static const unsigned char jb_mono_medium[] = { +#embed "fonts/JetBrainsMonoNL-Medium.ttf" }; static const struct { const unsigned char *bytes; size_t len; const char *family, *style; } faces[SK_TEXT_FACES] = { {go_mono, sizeof(go_mono), "Go Mono", ""}, @@ -53,9 +57,10 @@ static const struct { const unsigned char *bytes; size_t len; const char *family {go_regular, sizeof(go_regular), "Go", ""}, {go_medium, sizeof(go_medium), "Go Medium", ""}, {go_bold, sizeof(go_bold), "Go", " Bold"}, - {jb_mono, sizeof(jb_mono), "JetBrains Mono", ""}, - {jb_mono_bold, sizeof(jb_mono_bold), "JetBrains Mono", " Bold"}, - {jb_mono_italic, sizeof(jb_mono_italic), "JetBrains Mono", " Italic"}, + {jb_mono, sizeof(jb_mono), "JetBrains Mono NL", ""}, + {jb_mono_bold, sizeof(jb_mono_bold), "JetBrains Mono NL", " Bold"}, + {jb_mono_italic, sizeof(jb_mono_italic), "JetBrains Mono NL", " Italic"}, + {jb_mono_medium, sizeof(jb_mono_medium), "JetBrains Mono NL", " Medium"}, }; typedef struct { diff --git a/vendor/text.h b/vendor/text.h index 71cf0d1..aa49db8 100644 --- a/vendor/text.h +++ b/vendor/text.h @@ -11,7 +11,7 @@ bool sk_text_draw(SDL_Renderer *, float x, float y, float scale, bool sk_text_measure(SDL_Renderer *, float scale, const char *utf8, size_t len, float *width, float *height); /* The same in another face of the bundled Go family (`abi.Face`'s order). */ -enum { SK_TEXT_MONO, SK_TEXT_MONO_BOLD, SK_TEXT_MONO_ITALIC, SK_TEXT_SANS, SK_TEXT_SANS_MEDIUM, SK_TEXT_SANS_BOLD, SK_TEXT_CODE, SK_TEXT_CODE_BOLD, SK_TEXT_CODE_ITALIC, SK_TEXT_FACES }; +enum { SK_TEXT_MONO, SK_TEXT_MONO_BOLD, SK_TEXT_MONO_ITALIC, SK_TEXT_SANS, SK_TEXT_SANS_MEDIUM, SK_TEXT_SANS_BOLD, SK_TEXT_CODE, SK_TEXT_CODE_BOLD, SK_TEXT_CODE_ITALIC, SK_TEXT_CODE_MEDIUM, SK_TEXT_FACES }; bool sk_text_draw_face(SDL_Renderer *, int face, float x, float y, float scale, const char *utf8, size_t len, Uint8 r, Uint8 g, Uint8 b, Uint8 a); bool sk_text_measure_face(SDL_Renderer *, int face, float scale, const char *utf8, size_t len, -- cgit v1.3