mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
pkg/macos: add CoreText
This commit is contained in:
@ -184,7 +184,12 @@ fn addDeps(
|
|||||||
step.addPackage(glfw.pkg);
|
step.addPackage(glfw.pkg);
|
||||||
step.addPackage(libuv.pkg);
|
step.addPackage(libuv.pkg);
|
||||||
step.addPackage(utf8proc.pkg);
|
step.addPackage(utf8proc.pkg);
|
||||||
if (step.target.isDarwin()) step.addPackage(macos.pkg);
|
|
||||||
|
// Mac Stuff
|
||||||
|
if (step.target.isDarwin()) {
|
||||||
|
step.addPackage(macos.pkg);
|
||||||
|
_ = try macos.link(b, step, .{});
|
||||||
|
}
|
||||||
|
|
||||||
// We always statically compile glad
|
// We always statically compile glad
|
||||||
step.addIncludePath("vendor/glad/include/");
|
step.addIncludePath("vendor/glad/include/");
|
||||||
|
@ -20,5 +20,6 @@ pub fn link(
|
|||||||
_ = opt;
|
_ = opt;
|
||||||
const lib = b.addStaticLibrary("macos", null);
|
const lib = b.addStaticLibrary("macos", null);
|
||||||
step.linkFramework("CoreFoundation");
|
step.linkFramework("CoreFoundation");
|
||||||
|
step.linkFramework("CoreText");
|
||||||
return lib;
|
return lib;
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
pub usingnamespace @import("foundation/dictionary.zig");
|
||||||
pub usingnamespace @import("foundation/string.zig");
|
pub usingnamespace @import("foundation/string.zig");
|
||||||
pub usingnamespace @import("foundation/type.zig");
|
pub usingnamespace @import("foundation/type.zig");
|
||||||
|
|
||||||
|
37
pkg/macos/foundation/dictionary.zig
Normal file
37
pkg/macos/foundation/dictionary.zig
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
const std = @import("std");
|
||||||
|
const Allocator = std.mem.Allocator;
|
||||||
|
const cftype = @import("type.zig");
|
||||||
|
|
||||||
|
pub const Dictionary = opaque {
|
||||||
|
pub fn create() Allocator.Error!*Dictionary {
|
||||||
|
return CFDictionaryCreate(
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
0,
|
||||||
|
&kCFTypeDictionaryKeyCallBacks,
|
||||||
|
&kCFTypeDictionaryValueCallBacks,
|
||||||
|
) orelse Allocator.Error.OutOfMemory;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn release(self: *Dictionary) void {
|
||||||
|
cftype.CFRelease(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub extern "c" fn CFDictionaryCreate(
|
||||||
|
allocator: ?*anyopaque,
|
||||||
|
keys: ?[*]*const anyopaque,
|
||||||
|
values: ?[*]*const anyopaque,
|
||||||
|
num_values: usize,
|
||||||
|
key_callbacks: *const anyopaque,
|
||||||
|
value_callbacks: *const anyopaque,
|
||||||
|
) ?*Dictionary;
|
||||||
|
|
||||||
|
extern "c" var kCFTypeDictionaryKeyCallBacks: anyopaque;
|
||||||
|
extern "c" var kCFTypeDictionaryValueCallBacks: anyopaque;
|
||||||
|
};
|
||||||
|
|
||||||
|
test "dictionary" {
|
||||||
|
const dict = try Dictionary.create();
|
||||||
|
defer dict.release();
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
pub const foundation = @import("foundation.zig");
|
pub const foundation = @import("foundation.zig");
|
||||||
|
pub const text = @import("text.zig");
|
||||||
|
|
||||||
test {
|
test {
|
||||||
@import("std").testing.refAllDecls(@This());
|
@import("std").testing.refAllDecls(@This());
|
||||||
|
5
pkg/macos/text.zig
Normal file
5
pkg/macos/text.zig
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
pub usingnamespace @import("text/font_collection.zig");
|
||||||
|
|
||||||
|
test {
|
||||||
|
@import("std").testing.refAllDecls(@This());
|
||||||
|
}
|
22
pkg/macos/text/font_collection.zig
Normal file
22
pkg/macos/text/font_collection.zig
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
const std = @import("std");
|
||||||
|
const Allocator = std.mem.Allocator;
|
||||||
|
const foundation = @import("../foundation.zig");
|
||||||
|
|
||||||
|
pub const FontCollection = opaque {
|
||||||
|
pub fn createFromAvailableFonts() Allocator.Error!*FontCollection {
|
||||||
|
return CTFontCollectionCreateFromAvailableFonts(null) orelse Allocator.Error.OutOfMemory;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn release(self: *FontCollection) void {
|
||||||
|
foundation.CFRelease(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub extern "c" fn CTFontCollectionCreateFromAvailableFonts(
|
||||||
|
options: ?*foundation.Dictionary,
|
||||||
|
) ?*FontCollection;
|
||||||
|
};
|
||||||
|
|
||||||
|
test "collection" {
|
||||||
|
const v = try FontCollection.createFromAvailableFonts();
|
||||||
|
defer v.release();
|
||||||
|
}
|
Reference in New Issue
Block a user