font: move auto-italicization to Group

This commit is contained in:
Mitchell Hashimoto
2023-08-25 13:16:42 -07:00
parent 1dcf921ed9
commit ad6c2b6cc8
5 changed files with 60 additions and 91 deletions

View File

@@ -72,13 +72,6 @@ pub const CoreText = struct {
self.font.release();
self.* = undefined;
}
/// Auto-italicize the font by applying a skew.
pub fn italicize(self: *const CoreText) !CoreText {
const ct_font = try self.font.copyWithAttributes(0.0, &Face.italic_skew, null);
errdefer ct_font.release();
return .{ .font = ct_font };
}
};
/// WebCanvas specific data. This is only present when building with canvas.
@@ -351,40 +344,6 @@ pub fn hasCodepoint(self: DeferredFace, cp: u32, p: ?Presentation) bool {
unreachable;
}
/// Returns true if our deferred font implementation supports auto-itacilization.
pub fn canItalicize() bool {
return @hasDecl(FaceState, "italicize") and @hasDecl(Face, "italicize");
}
/// Returns a new deferred face with the italicized version of this face
/// by applying a skew. This is NOT TRUE italics. You should use the discovery
/// mechanism to try to find an italic font. This is a fallback for when
/// that fails.
pub fn italicize(self: *const DeferredFace) !?DeferredFace {
if (comptime !canItalicize()) return null;
var result: DeferredFace = .{};
if (self.face) |face| {
result.face = try face.italicize();
}
switch (options.backend) {
.freetype => {},
.fontconfig_freetype => if (self.fc) |*fc| {
result.fc = try fc.italicize();
},
.coretext, .coretext_freetype => if (self.ct) |*ct| {
result.ct = try ct.italicize();
},
.web_canvas => if (self.wc) |*wc| {
result.wc = try wc.italicize();
},
}
return result;
}
/// The wasm-compatible API.
pub const Wasm = struct {
const wasm = @import("../os/wasm.zig");