font: fix fontconfig leaks in unit tests

This commit is contained in:
Mitchell Hashimoto
2025-08-21 06:53:57 -07:00
parent a57afd41ac
commit fe5eafac0a
2 changed files with 5 additions and 1 deletions

View File

@@ -413,6 +413,7 @@ test "fontconfig" {
// Get a deferred face from fontconfig
var def = def: {
var fc = discovery.Fontconfig.init();
defer fc.deinit();
var it = try fc.discover(alloc, .{ .family = "monospace", .size = 12 });
defer it.deinit();
break :def (try it.next()).?;

View File

@@ -897,6 +897,7 @@ test "fontconfig" {
const alloc = testing.allocator;
var fc = Fontconfig.init();
defer fc.deinit();
var it = try fc.discover(alloc, .{ .family = "monospace", .size = 12 });
defer it.deinit();
}
@@ -908,12 +909,14 @@ test "fontconfig codepoint" {
const alloc = testing.allocator;
var fc = Fontconfig.init();
defer fc.deinit();
var it = try fc.discover(alloc, .{ .codepoint = 'A', .size = 12 });
defer it.deinit();
// The first result should have the codepoint. Later ones may not
// because fontconfig returns all fonts sorted.
const face = (try it.next()).?;
var face = (try it.next()).?;
defer face.deinit();
try testing.expect(face.hasCodepoint('A', null));
// Should have other codepoints too