font/coretext: score discovered fonts

This commit is contained in:
Mitchell Hashimoto
2023-10-03 09:17:41 -07:00
parent fda56fd11f
commit 1127330b3a
8 changed files with 115 additions and 24 deletions

View File

@@ -63,7 +63,7 @@ pub const MutableArray = opaque {
a: *const Elem,
b: *const Elem,
context: ?*Context,
) ComparisonResult,
) callconv(.C) ComparisonResult,
) void {
CFArraySortValues(
self,
@@ -122,7 +122,7 @@ test "array sorting" {
void,
null,
struct {
fn compare(a: *const u8, b: *const u8, _: ?*void) ComparisonResult {
fn compare(a: *const u8, b: *const u8, _: ?*void) callconv(.C) ComparisonResult {
if (a.* > b.*) return .greater;
if (a.* == b.*) return .equal;
return .less;

View File

@@ -46,18 +46,22 @@ pub const FontDescriptor = opaque {
) orelse Allocator.Error.OutOfMemory;
}
pub fn retain(self: *FontDescriptor) void {
_ = c.CFRetain(self);
}
pub fn release(self: *FontDescriptor) void {
c.CFRelease(self);
}
pub fn copyAttribute(self: *FontDescriptor, comptime attr: FontAttribute) attr.Value() {
pub fn copyAttribute(self: *const FontDescriptor, comptime attr: FontAttribute) attr.Value() {
return @ptrFromInt(@intFromPtr(c.CTFontDescriptorCopyAttribute(
@ptrCast(self),
@ptrCast(attr.key()),
)));
}
pub fn copyAttributes(self: *FontDescriptor) *foundation.Dictionary {
pub fn copyAttributes(self: *const FontDescriptor) *foundation.Dictionary {
return @ptrFromInt(@intFromPtr(c.CTFontDescriptorCopyAttributes(
@ptrCast(self),
)));