diff options
Diffstat (limited to 'src/abi.zig')
| -rw-r--r-- | src/abi.zig | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/abi.zig b/src/abi.zig index 03e2978..b30b7ae 100644 --- a/src/abi.zig +++ b/src/abi.zig @@ -180,6 +180,9 @@ pub const Input = struct { started: bool = false, /// The console is open and owns the keyboard. console: bool = false, + /// The host is exporting frames (`--export`): nobody watches or clicks, + /// so a player runs through once, without its controls, and quits. + exporting: bool = false, /// The canvas. width: f32 = 0, height: f32 = 0, @@ -578,6 +581,9 @@ pub const Host = struct { freeBuffer: *const fn (*anyopaque, Buffer) void, /// Zero while unknown. imageSize: *const fn (*anyopaque, Image) [2]u32, + /// What `Command.text` gives the bytes at a scale: the width they + /// advance and the height of their line, in canvas units. + textSize: *const fn (*anyopaque, f32, []const u8) [2]f32, /// `.none` if the file does not load. loadSound: *const fn (*anyopaque, []const u8) Audio, /// WAV, FLAC or Ogg Vorbis bytes in memory. Not cached. `.none` if @@ -625,6 +631,14 @@ pub const Host = struct { pub fn imageSize(h: Host, image: Image) [2]u32 { return h.vtable.imageSize(h.ctx, image); } + /// The size `f.text(x, y, scale, bytes, ...)` covers from `x, y`: width + /// and line height in canvas units, for laying text out (in `draw`: + /// `update` gets no host). Native text is shaped and hinted at the size + /// it is drawn, so a width is not a multiple of the scale: measure at + /// the scale drawn. + pub fn textSize(h: Host, scale: f32, bytes: []const u8) [2]f32 { + return h.vtable.textSize(h.ctx, scale, bytes); + } pub fn loadSound(h: Host, path: []const u8) Audio { return h.vtable.loadSound(h.ctx, path); } |
