font: do not use Noto on macOS for tests, it doesn't work

This commit is contained in:
Mitchell Hashimoto
2023-07-01 13:51:31 -07:00
parent 0a718ec3eb
commit 1d1b868958
3 changed files with 14 additions and 4 deletions

View File

@ -411,9 +411,13 @@ test {
defer group.deinit();
try group.addFace(alloc, .regular, DeferredFace.initLoaded(try Face.init(lib, testFont, .{ .points = 12 })));
try group.addFace(alloc, .regular, DeferredFace.initLoaded(try Face.init(lib, testEmoji, .{ .points = 12 })));
try group.addFace(alloc, .regular, DeferredFace.initLoaded(try Face.init(lib, testEmojiText, .{ .points = 12 })));
if (font.options.backend != .coretext) {
// Coretext doesn't support Noto's format
try group.addFace(alloc, .regular, DeferredFace.initLoaded(try Face.init(lib, testEmoji, .{ .points = 12 })));
}
// Should find all visible ASCII
var i: u32 = 32;
while (i < 127) : (i += 1) {
@ -437,14 +441,16 @@ test {
{
const idx = group.indexForCodepoint('🥸', .regular, null).?;
try testing.expectEqual(Style.regular, idx.style);
try testing.expectEqual(@as(FontIndex.IndexInt, 1), idx.idx);
const expected: FontIndex.IndexInt = if (font.options.backend == .coretext) 1 else 2;
try testing.expectEqual(expected, idx.idx);
}
// Try text emoji
{
const idx = group.indexForCodepoint(0x270C, .regular, .text).?;
try testing.expectEqual(Style.regular, idx.style);
try testing.expectEqual(@as(FontIndex.IndexInt, 2), idx.idx);
try testing.expectEqual(@as(FontIndex.IndexInt, 1), idx.idx);
}
{
const idx = group.indexForCodepoint(0x270C, .regular, .emoji).?;

View File

@ -30,6 +30,7 @@ pub const Face = struct {
const arr = macos.text.createFontDescriptorsFromData(data) orelse
return error.FontInitFailure;
defer arr.release();
if (arr.getCount() == 0) return error.FontInitFailure;
const desc = arr.getValueAtIndex(macos.text.FontDescriptor, 0);
const ct_font = try macos.text.Font.createWithFontDescriptor(desc, 12);

View File

@ -648,8 +648,11 @@ fn testShaper(alloc: Allocator) !TestShaper {
// Setup group
try cache_ptr.group.addFace(alloc, .regular, DeferredFace.initLoaded(try Face.init(lib, testFont, .{ .points = 12 })));
try cache_ptr.group.addFace(alloc, .regular, DeferredFace.initLoaded(try Face.init(lib, testEmoji, .{ .points = 12 })));
try cache_ptr.group.addFace(alloc, .regular, DeferredFace.initLoaded(try Face.init(lib, testEmojiText, .{ .points = 12 })));
if (font.options.backend != .coretext) {
// Coretext doesn't support Noto's format
try cache_ptr.group.addFace(alloc, .regular, DeferredFace.initLoaded(try Face.init(lib, testEmoji, .{ .points = 12 })));
}
var cell_buf = try alloc.alloc(font.shape.Cell, 80);
errdefer alloc.free(cell_buf);