font: fix fontconfig leaks in unit tests

pull/8319/head
Mitchell Hashimoto 2025-08-21 06:53:57 -07:00
parent a57afd41ac
commit fe5eafac0a
No known key found for this signature in database
GPG Key ID: 523D5DC389D273BC
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