pkg/macos: more APIs

This commit is contained in:
Mitchell Hashimoto
2023-12-11 20:48:45 -08:00
parent fcd9de0311
commit cc0b615552
3 changed files with 22 additions and 0 deletions

View File

@ -39,6 +39,23 @@ pub const Dictionary = opaque {
key,
)));
}
pub fn getKeysAndValues(self: *Dictionary, alloc: Allocator) !struct {
keys: []?*const anyopaque,
values: []?*const anyopaque,
} {
const count = self.getCount();
const keys = try alloc.alloc(?*const anyopaque, count);
errdefer alloc.free(keys);
const values = try alloc.alloc(?*const anyopaque, count);
errdefer alloc.free(values);
c.CFDictionaryGetKeysAndValues(
@ptrCast(self),
@ptrCast(keys.ptr),
@ptrCast(values.ptr),
);
return .{ .keys = keys, .values = values };
}
};
pub const MutableDictionary = opaque {

View File

@ -1,3 +1,4 @@
pub const c = @import("text/c.zig");
pub usingnamespace @import("text/font.zig");
pub usingnamespace @import("text/font_collection.zig");
pub usingnamespace @import("text/font_descriptor.zig");

View File

@ -47,6 +47,10 @@ pub const Font = opaque {
return @ptrCast(@constCast(c.CTFontCopyFontDescriptor(@ptrCast(self))));
}
pub fn copyFeatures(self: *Font) *foundation.Array {
return @ptrCast(@constCast(c.CTFontCopyFeatures(@ptrCast(self))));
}
pub fn getGlyphCount(self: *Font) usize {
return @intCast(c.CTFontGetGlyphCount(@ptrCast(self)));
}