diff options
Diffstat (limited to 'test/text.zig')
| -rw-r--r-- | test/text.zig | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/text.zig b/test/text.zig index d0e0eea..f60f13a 100644 --- a/test/text.zig +++ b/test/text.zig @@ -36,4 +36,13 @@ pub fn draw(f: *sk.Frame) void { if (line.raster > 0) f.textScaled(line.face, 10 * k, y, line.scale * k, line.raster * k, line.text, 0xffffff) else f.textIn(line.face, 10 * k, y, line.scale * k, line.text, 0xffffff); y += size[1] + 6 * k; } + // A paragraph (sk.text): wrapped at 200, centred, a span in red and + // one twice the size, its box from sk.text.layout and a caret drawn + // before "twice" from the Layout it returns. + const words = "Centred, wrapped at spaces, in red and twice the size."; + const p: sk.text.Paragraph = .{ .width = 200 * k, .@"align" = .center, .scale = k, .spans = &.{ .{ .start = 31, .color = .{ .r = 255, .g = 80, .b = 80 } }, .{ .start = 35 }, .{ .start = 39, .scale = 2 * k }, .{ .start = 44 } }, .caret = 39 }; + const l = sk.text.layout(words, p); + f.fill(sk.Rect{ .x = 420 * k, .y = 175 * k, .w = 200 * k, .h = l.h }, 0x204060); + const drawn = f.paragraph(420 * k, 175 * k, words, p); + f.fill(sk.Rect{ .x = drawn.caret.x, .y = drawn.caret.y, .w = k, .h = drawn.caret.h }, 0xffff00); } |
