From e9e32d71e41c7d7c7a846b2406b449e28d44e3e9 Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Sun, 10 Aug 2025 20:10:24 -0500 Subject: [PATCH] font/freetype: add a test for face name decoding using embedded fonts --- src/font/face/freetype.zig | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/font/face/freetype.zig b/src/font/face/freetype.zig index 4ca06cb58..61ec735c3 100644 --- a/src/font/face/freetype.zig +++ b/src/font/face/freetype.zig @@ -181,6 +181,33 @@ pub const Face = struct { return ""; } + test "face name" { + const embedded = @import("../embedded.zig"); + + var lib: Library = try .init(testing.allocator); + defer lib.deinit(); + + { + var face: Face = try .init(lib, embedded.variable, .{ .size = .{ .points = 14 } }); + defer face.deinit(); + + var buf: [1024]u8 = undefined; + const actual = try face.name(&buf); + + try testing.expectEqualStrings("JetBrains Mono", actual); + } + + { + var face: Face = try .init(lib, embedded.inconsolata, .{ .size = .{ .points = 14 } }); + defer face.deinit(); + + var buf: [1024]u8 = undefined; + const actual = try face.name(&buf); + + try testing.expectEqualStrings("Inconsolata", actual); + } + } + /// Return a new face that is the same as this but also has synthetic /// bold applied. pub fn syntheticBold(self: *const Face, opts: font.face.Options) !Face {