font: specific codepoint lookup in internals

This commit is contained in:
Mitchell Hashimoto
2022-11-17 15:49:14 -08:00
parent b91cd8e41c
commit da2942e083
7 changed files with 136 additions and 27 deletions

View File

@@ -51,6 +51,14 @@ pub const MutableDictionary = opaque {
))) orelse Allocator.Error.OutOfMemory;
}
pub fn createMutableCopy(cap: usize, src: *Dictionary) Allocator.Error!*MutableDictionary {
return @intToPtr(?*MutableDictionary, @ptrToInt(c.CFDictionaryCreateMutableCopy(
null,
@intCast(c.CFIndex, cap),
@ptrCast(c.CFDictionaryRef, src),
))) orelse Allocator.Error.OutOfMemory;
}
pub fn release(self: *MutableDictionary) void {
foundation.CFRelease(self);
}

View File

@@ -18,6 +18,19 @@ pub const FontDescriptor = opaque {
) orelse Allocator.Error.OutOfMemory;
}
pub fn createCopyWithAttributes(
original: *FontDescriptor,
dict: *foundation.Dictionary,
) Allocator.Error!*FontDescriptor {
return @intToPtr(
?*FontDescriptor,
@ptrToInt(c.CTFontDescriptorCreateCopyWithAttributes(
@ptrCast(c.CTFontDescriptorRef, original),
@ptrCast(c.CFDictionaryRef, dict),
)),
) orelse Allocator.Error.OutOfMemory;
}
pub fn release(self: *FontDescriptor) void {
c.CFRelease(self);
}
@@ -28,6 +41,12 @@ pub const FontDescriptor = opaque {
@ptrCast(c.CFStringRef, attr.key()),
)));
}
pub fn copyAttributes(self: *FontDescriptor) *foundation.Dictionary {
return @intToPtr(*foundation.Dictionary, @ptrToInt(c.CTFontDescriptorCopyAttributes(
@ptrCast(c.CTFontDescriptorRef, self),
)));
}
};
pub const FontAttribute = enum {