diff --git a/freetype/src/harfbuzz/face.zig b/freetype/src/harfbuzz/face.zig index bb6429f7..1bb3de2f 100644 --- a/freetype/src/harfbuzz/face.zig +++ b/freetype/src/harfbuzz/face.zig @@ -1,3 +1,4 @@ +const freetype = @import("freetype"); const c = @import("c"); const Blob = @import("blob.zig").Blob; @@ -21,6 +22,10 @@ pub const Face = struct { return .{ .handle = c.hb_face_create(blob.handle, index).? }; } + pub fn fromFtFace(face: freetype.Face) Face { + return .{ .handle = c.hb_ft_face_create_referenced(face.handle).? }; + } + pub fn initEmpty() Face { return .{ .handle = c.hb_face_get_empty().? }; } diff --git a/freetype/src/harfbuzz/font.zig b/freetype/src/harfbuzz/font.zig index 9a5fdda3..bee44500 100644 --- a/freetype/src/harfbuzz/font.zig +++ b/freetype/src/harfbuzz/font.zig @@ -1,3 +1,4 @@ +const freetype = @import("freetype"); const c = @import("c"); const Face = @import("face.zig").Face; const Buffer = @import("buffer.zig").Buffer; @@ -11,6 +12,10 @@ pub const Font = struct { return .{ .handle = c.hb_font_create(face.handle).? }; } + pub fn fromFtFace(face: freetype.Face) Font { + return .{ .handle = c.hb_ft_font_create_referenced(face.handle).? }; + } + pub fn createSubFont(self: Font) Font { return .{ .handle = c.hb_font_create_sub_font(self.handle).?, @@ -21,10 +26,22 @@ pub const Font = struct { c.hb_font_destroy(self.handle); } + pub fn ftFaceChanged(self: Font) void { + c.hb_ft_font_changed(self.handle); + } + + pub fn setFtLoadFlags(self: Font, flags: freetype.LoadFlags) void { + c.hb_ft_font_set_load_flags(self.handle, flags.cast()); + } + pub fn getFace(self: Font) Face { return .{ .handle = c.hb_font_get_face(self.handle).? }; } + pub fn getFreetypeFace(self: Font) freetype.Face { + return .{ .handle = c.hb_ft_font_get_face(self.handle) }; + } + pub fn getGlyph(self: Font, unicode: u32, variation_selector: u32) ?u32 { var g: u32 = 0; return if (c.hb_font_get_glyph(self.handle, unicode, variation_selector, &g) > 0)