ghostty/pkg/macos/text/font_collection.zig
Mitchell Hashimoto f9e1127317 pkg/macos: add CoreText
2022-09-30 14:48:06 -07:00

23 lines
660 B
Zig

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();
}