From faf40df6f31e98eb752fd5e96330221c8f7dbcc7 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 10 Nov 2026 12:10:40 -0300 Subject: sketchbook: text in six faces of the Go family, all bundled (f.textIn, host.textSizeIn, sk.Face) --- src/anim/root.zig | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/anim/root.zig') diff --git a/src/anim/root.zig b/src/anim/root.zig index 00e9362..a676f38 100644 --- a/src/anim/root.zig +++ b/src/anim/root.zig @@ -186,6 +186,18 @@ pub const Placed = struct { f.text(at[0], at[1], scale * p.scale, bytes, p.faded(ink)); } + /// `text` in another face (`sk.Face`: bold or italic mono, the sans). + pub fn textIn(p: Placed, f: *sk.Frame, face: sk.Face, x: f32, y: f32, scale: f32, bytes: []const u8, ink: sk.Color) void { + const at = p.xf.apply(.{ x, y }); + f.textIn(face, at[0], at[1], scale * p.scale, bytes, p.faded(ink)); + } + + /// The width and line height `textIn` covers, in the object's units. + pub fn textSizeIn(p: Placed, f: *sk.Frame, face: sk.Face, scale: f32, bytes: []const u8) [2]f32 { + const size = f.host.textSizeIn(face, scale * p.scale, bytes); + return .{ size[0] / p.scale, size[1] / p.scale }; + } + /// The width and line height `text` covers, in the object's units. pub fn textSize(p: Placed, f: *sk.Frame, scale: f32, bytes: []const u8) [2]f32 { const size = f.host.textSize(scale * p.scale, bytes); -- cgit v1.3