font: fix coretext test issues with harfbuzz shaper

This commit is contained in:
Mitchell Hashimoto
2024-05-08 18:33:14 -07:00
parent 435bd32cfd
commit 6dcf567554
2 changed files with 22 additions and 19 deletions

View File

@ -380,32 +380,35 @@ test getIndex {
var c = try Collection.init(alloc); var c = try Collection.init(alloc);
c.load_options = .{ .library = lib }; c.load_options = .{ .library = lib };
_ = try c.add(alloc, .regular, .{ .loaded = try Face.init( {
lib, errdefer c.deinit(alloc);
testFont, _ = try c.add(alloc, .regular, .{ .loaded = try Face.init(
.{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } }, lib,
) }); testFont,
if (font.options.backend != .coretext) { .{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } },
// Coretext doesn't support Noto's format ) });
if (comptime !font.options.backend.hasCoretext()) {
// Coretext doesn't support Noto's format
_ = try c.add(
alloc,
.regular,
.{ .loaded = try Face.init(
lib,
testEmoji,
.{ .size = .{ .points = 12 } },
) },
);
}
_ = try c.add( _ = try c.add(
alloc, alloc,
.regular, .regular,
.{ .loaded = try Face.init( .{ .loaded = try Face.init(
lib, lib,
testEmoji, testEmojiText,
.{ .size = .{ .points = 12 } }, .{ .size = .{ .points = 12 } },
) }, ) },
); );
} }
_ = try c.add(
alloc,
.regular,
.{ .loaded = try Face.init(
lib,
testEmojiText,
.{ .size = .{ .points = 12 } },
) },
);
var r: CodepointResolver = .{ .collection = c }; var r: CodepointResolver = .{ .collection = c };
defer r.deinit(alloc); defer r.deinit(alloc);
@ -429,7 +432,7 @@ test getIndex {
{ {
const idx = r.getIndex(alloc, 0x270C, .regular, .text).?; const idx = r.getIndex(alloc, 0x270C, .regular, .text).?;
try testing.expectEqual(Style.regular, idx.style); try testing.expectEqual(Style.regular, idx.style);
const text_idx = if (font.options.backend == .coretext) 1 else 2; const text_idx = if (comptime font.options.backend.hasCoretext()) 1 else 2;
try testing.expectEqual(@as(Collection.Index.IndexInt, text_idx), idx.idx); try testing.expectEqual(@as(Collection.Index.IndexInt, text_idx), idx.idx);
} }
{ {

View File

@ -1213,7 +1213,7 @@ fn testShaperWithFont(alloc: Allocator, font_req: TestFont) !TestShaper {
.{ .size = .{ .points = 12 } }, .{ .size = .{ .points = 12 } },
) }); ) });
if (font.options.backend != .coretext) { if (comptime !font.options.backend.hasCoretext()) {
// Coretext doesn't support Noto's format // Coretext doesn't support Noto's format
_ = try c.add(alloc, .regular, .{ .loaded = try Face.init( _ = try c.add(alloc, .regular, .{ .loaded = try Face.init(
lib, lib,