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);
c.load_options = .{ .library = lib };
_ = try c.add(alloc, .regular, .{ .loaded = try Face.init(
lib,
testFont,
.{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } },
) });
if (font.options.backend != .coretext) {
// Coretext doesn't support Noto's format
{
errdefer c.deinit(alloc);
_ = try c.add(alloc, .regular, .{ .loaded = try Face.init(
lib,
testFont,
.{ .size = .{ .points = 12, .xdpi = 96, .ydpi = 96 } },
) });
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(
alloc,
.regular,
.{ .loaded = try Face.init(
lib,
testEmoji,
testEmojiText,
.{ .size = .{ .points = 12 } },
) },
);
}
_ = try c.add(
alloc,
.regular,
.{ .loaded = try Face.init(
lib,
testEmojiText,
.{ .size = .{ .points = 12 } },
) },
);
var r: CodepointResolver = .{ .collection = c };
defer r.deinit(alloc);
@ -429,7 +432,7 @@ test getIndex {
{
const idx = r.getIndex(alloc, 0x270C, .regular, .text).?;
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);
}
{

View File

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