From 371a7f79cb4b747d3363d958b857d97ac9ee3a33 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 15 Nov 2022 20:29:58 -0800 Subject: [PATCH] coretext: implement resizing --- src/font/face/coretext.zig | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/font/face/coretext.zig b/src/font/face/coretext.zig index bdb7338e4..c95d8d724 100644 --- a/src/font/face/coretext.zig +++ b/src/font/face/coretext.zig @@ -65,6 +65,15 @@ pub const Face = struct { self.* = undefined; } + /// Resize the font in-place. If this succeeds, the caller is responsible + /// for clearing any glyph caches, font atlas data, etc. + pub fn setSize(self: *Face, size: font.face.DesiredSize) !void { + // We just create a copy and replace ourself + const face = try initFontCopy(self.font, size); + self.deinit(); + self.* = face; + } + /// Returns the glyph index for the given Unicode code point. If this /// face doesn't support this glyph, null is returned. pub fn glyphIndex(self: Face, cp: u32) ?u32 {