font: deferred face can load core text backend

This commit is contained in:
Mitchell Hashimoto
2022-10-09 11:28:28 -07:00
parent 97e989daa8
commit 9c99a49ac5
2 changed files with 26 additions and 11 deletions

View File

@ -339,7 +339,9 @@ pub fn create(alloc: Allocator, loop: libuv.Loop, config: *const Config) !*Windo
font.DeferredFace.initLoaded(try font.Face.init(font_lib, face_bold_ttf, font_size)),
);
// Emoji
// Emoji fallback. We don't include this on Mac since Mac is expected
// to always have the Apple Emoji available.
if (builtin.os.tag != .macos or font.Discover == void) {
try group.addFace(
alloc,
.regular,
@ -350,6 +352,7 @@ pub fn create(alloc: Allocator, loop: libuv.Loop, config: *const Config) !*Windo
.regular,
font.DeferredFace.initLoaded(try font.Face.init(font_lib, face_emoji_text_ttf, font_size)),
);
}
break :group group;
});

View File

@ -115,6 +115,7 @@ pub fn load(
// both here.
switch (font.Face) {
@import("face/freetype.zig").Face => try self.loadCoreTextFreetype(lib, size),
@import("face/coretext.zig").Face => try self.loadCoreText(lib, size),
else => unreachable,
}
@ -142,6 +143,17 @@ fn loadFontconfig(
self.face = try Face.initFile(lib, filename, face_index, size);
}
fn loadCoreText(
self: *DeferredFace,
lib: Library,
size: font.face.DesiredSize,
) !void {
_ = lib;
assert(self.face == null);
const ct = self.ct.?;
self.face = try Face.initFontCopy(ct.font, size);
}
fn loadCoreTextFreetype(
self: *DeferredFace,
lib: Library,