summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorQwerasd <qwerasd205@users.noreply.github.com>2024-12-11 21:14:21 -0500
committerQwerasd <qwerasd205@users.noreply.github.com>2024-12-11 21:14:21 -0500
commitfb50143cec9bfec1f86d1fbfda87799519a87829 (patch)
tree10a88b07e01ac2caf3efc9a3893363c7d95649b8 /pkg
parentbd1845231011d2b445a78bef07a5b54f0b077479 (diff)
font(coretext): add metrics test case for CT, fix variable font init
Variable font init used to just select the first available predefined instance, if there were any, which is often not desirable- using createFontDescriptorFromData instead of createFontDescritorsFromData ensures that the default variation config is selected. In the future we should probably allow selection of predefined instances, but for now this is the correct behavior. I found this bug when adding the metrics calculation test case for CoreText, hence why fixing it is part of the same commit.
Diffstat (limited to 'pkg')
-rw-r--r--pkg/macos/text.zig1
-rw-r--r--pkg/macos/text/font_manager.zig7
2 files changed, 8 insertions, 0 deletions
diff --git a/pkg/macos/text.zig b/pkg/macos/text.zig
index 149cef66b..0589f8692 100644
--- a/pkg/macos/text.zig
+++ b/pkg/macos/text.zig
@@ -20,6 +20,7 @@ pub const FontVariationAxisKey = font_descriptor.FontVariationAxisKey;
pub const FontSymbolicTraits = font_descriptor.FontSymbolicTraits;
pub const createFontDescriptorsFromURL = font_manager.createFontDescriptorsFromURL;
pub const createFontDescriptorsFromData = font_manager.createFontDescriptorsFromData;
+pub const createFontDescriptorFromData = font_manager.createFontDescriptorFromData;
pub const Frame = frame.Frame;
pub const Framesetter = framesetter.Framesetter;
pub const Line = line.Line;
diff --git a/pkg/macos/text/font_manager.zig b/pkg/macos/text/font_manager.zig
index f918167a0..988da1220 100644
--- a/pkg/macos/text/font_manager.zig
+++ b/pkg/macos/text/font_manager.zig
@@ -1,6 +1,7 @@
const std = @import("std");
const Allocator = std.mem.Allocator;
const foundation = @import("../foundation.zig");
+const FontDescriptor = @import("./font_descriptor.zig").FontDescriptor;
const c = @import("c.zig").c;
pub fn createFontDescriptorsFromURL(url: *foundation.URL) ?*foundation.Array {
@@ -14,3 +15,9 @@ pub fn createFontDescriptorsFromData(data: *foundation.Data) ?*foundation.Array
@ptrCast(data),
)));
}
+
+pub fn createFontDescriptorFromData(data: *foundation.Data) ?*FontDescriptor {
+ return @ptrFromInt(@intFromPtr(c.CTFontManagerCreateFontDescriptorFromData(
+ @ptrCast(data),
+ )));
+}