summaryrefslogtreecommitdiff
path: root/src/sketch/root.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-10 12:10:40 -0300
committerGabriel Schneider <[email protected]>2026-11-12 13:22:02 -0300
commitfaf40df6f31e98eb752fd5e96330221c8f7dbcc7 (patch)
treeab9356732afbbbb18e85f973945249a738863ae7 /src/sketch/root.zig
parent71e534631bf68f33f802d64794340870374b9f69 (diff)
downloadsketchbook-faf40df6f31e98eb752fd5e96330221c8f7dbcc7.tar.gz
sketchbook-faf40df6f31e98eb752fd5e96330221c8f7dbcc7.zip
sketchbook: text in six faces of the Go family, all bundled (f.textIn, host.textSizeIn, sk.Face)
Diffstat (limited to 'src/sketch/root.zig')
-rw-r--r--src/sketch/root.zig6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/sketch/root.zig b/src/sketch/root.zig
index 33c9ba7..01aa977 100644
--- a/src/sketch/root.zig
+++ b/src/sketch/root.zig
@@ -57,6 +57,7 @@ pub const Buffer = abi.Buffer;
pub const Cursor = abi.Cursor;
pub const Voice = abi.Voice;
pub const BlendMode = abi.BlendMode;
+pub const Face = abi.Face;
/// What `draw` receives: input, host services, memory by lifetime and the
/// command list. Commands may be built from anything: the methods copy what
@@ -146,6 +147,11 @@ pub const Frame = struct {
pub fn text(f: *Frame, x: f32, y: f32, scale: f32, bytes: []const u8, color: anytype) void {
f.emit(.{ .text = .{ .x = x, .y = y, .scale = scale, .color = paint(color), .bytes = f.keep(u8, bytes) } });
}
+ /// `text` in another face of the built-in family: bold or italic mono,
+ /// or the sans (`host.textSizeIn` measures it).
+ pub fn textIn(f: *Frame, face: Face, x: f32, y: f32, scale: f32, bytes: []const u8, color: anytype) void {
+ f.emit(.{ .text = .{ .x = x, .y = y, .scale = scale, .color = paint(color), .bytes = f.keep(u8, bytes), .face = face } });
+ }
pub fn print(f: *Frame, x: f32, y: f32, scale: f32, color: anytype, comptime fmt: []const u8, args: anytype) void {
f.emit(.{ .text = .{ .x = x, .y = y, .scale = scale, .color = paint(color), .bytes = f.format(fmt, args) } });
}