aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/pkg/harfbuzz/coretext.zig
diff options
context:
space:
mode:
authorCan Celik <ogulcancelik@gmail.com>2026-04-04 19:22:04 +0300
committerCan Celik <ogulcancelik@gmail.com>2026-04-05 01:23:06 +0300
commit41dd733ca7123c9ac4bfc6c781697a660e95b052 (patch)
tree3fc91815ca139ef2e0b281bba0abda4ef15175f4 /vendor/libghostty-vt/pkg/harfbuzz/coretext.zig
parent55c138263e190a1e79d4b997bfb9397306c0ec1f (diff)
feat: finish ghostty pane backend integration
Diffstat (limited to 'vendor/libghostty-vt/pkg/harfbuzz/coretext.zig')
-rw-r--r--vendor/libghostty-vt/pkg/harfbuzz/coretext.zig30
1 files changed, 30 insertions, 0 deletions
diff --git a/vendor/libghostty-vt/pkg/harfbuzz/coretext.zig b/vendor/libghostty-vt/pkg/harfbuzz/coretext.zig
new file mode 100644
index 00000000..73042624
--- /dev/null
+++ b/vendor/libghostty-vt/pkg/harfbuzz/coretext.zig
@@ -0,0 +1,30 @@
+const macos = @import("macos");
+const std = @import("std");
+const c = @import("c.zig").c;
+const Face = @import("face.zig").Face;
+const Font = @import("font.zig").Font;
+const Error = @import("errors.zig").Error;
+
+// Use custom extern functions so that the proper CoreText structs are used
+// without a ptrcast.
+extern fn hb_coretext_font_create(ct_face: *macos.text.Font) ?*c.hb_font_t;
+
+/// Creates an hb_font_t font object from the specified CTFontRef.
+pub fn createFont(face: *macos.text.Font) Error!Font {
+ const handle = hb_coretext_font_create(face) orelse return Error.HarfbuzzFailed;
+ return Font{ .handle = handle };
+}
+
+test {
+ if (!@hasDecl(c, "hb_coretext_font_create")) return error.SkipZigTest;
+
+ const name = try macos.foundation.String.createWithBytes("Monaco", .utf8, false);
+ defer name.release();
+ const desc = try macos.text.FontDescriptor.createWithNameAndSize(name, 12);
+ defer desc.release();
+ const font = try macos.text.Font.createWithFontDescriptor(desc, 12);
+ defer font.release();
+
+ var hb_font = try createFont(font);
+ defer hb_font.destroy();
+}