From 962be81f710b50df9ab005ec64546c9459bc0e49 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 5 Jan 2024 21:03:37 -0800 Subject: [PATCH 1/2] core: add Apple Color Emoji on macOS if its available --- src/Surface.zig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Surface.zig b/src/Surface.zig index 0ed3b47d3..dbc800654 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -410,6 +410,21 @@ pub fn init( _ = try group.addFace(.bold_italic, .{ .deferred = face }); } else log.warn("font-family-bold-italic not found: {s}", .{family}); } + + // On macOS, always search for and add the Apple Emoji font + // as our preferred emoji font for fallback. We do this in case + // people add other emoji fonts to their system, we always want to + // prefer the official one. Users can override this by explicitly + // specifying a font-family for emoji. + if (comptime builtin.os.tag == .macos) { + var disco_it = try disco.discover(alloc, .{ + .family = "Apple Color Emoji", + }); + defer disco_it.deinit(); + if (try disco_it.next()) |face| { + _ = try group.addFace(.regular, .{ .fallback_deferred = face }); + } + } } // Our built-in font will be used as a backup From efd196e5c92b1b6d8c03373e07018d0dc2125f56 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 5 Jan 2024 21:08:39 -0800 Subject: [PATCH 2/2] pkg/freetype: unknown errors should be reported, not unreachable --- pkg/freetype/errors.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/freetype/errors.zig b/pkg/freetype/errors.zig index e4f98db87..3fe6dccb8 100644 --- a/pkg/freetype/errors.zig +++ b/pkg/freetype/errors.zig @@ -94,6 +94,7 @@ pub const Error = error{ BbxTooBig, CorruptedFontHeader, CorruptedFontGlyphs, + UnknownFreetypeError, }; pub fn intToError(err: c_int) Error!void { @@ -188,7 +189,7 @@ pub fn intToError(err: c_int) Error!void { c.FT_Err_Bbx_Too_Big => Error.BbxTooBig, c.FT_Err_Corrupted_Font_Header => Error.CorruptedFontHeader, c.FT_Err_Corrupted_Font_Glyphs => Error.CorruptedFontGlyphs, - else => unreachable, + else => Error.UnknownFreetypeError, }; }