mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-04-27 20:08:41 +03:00

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.
24 lines
804 B
Zig
24 lines
804 B
Zig
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 {
|
|
return @ptrFromInt(@intFromPtr(c.CTFontManagerCreateFontDescriptorsFromURL(
|
|
@ptrCast(url),
|
|
)));
|
|
}
|
|
|
|
pub fn createFontDescriptorsFromData(data: *foundation.Data) ?*foundation.Array {
|
|
return @ptrFromInt(@intFromPtr(c.CTFontManagerCreateFontDescriptorsFromData(
|
|
@ptrCast(data),
|
|
)));
|
|
}
|
|
|
|
pub fn createFontDescriptorFromData(data: *foundation.Data) ?*FontDescriptor {
|
|
return @ptrFromInt(@intFromPtr(c.CTFontManagerCreateFontDescriptorFromData(
|
|
@ptrCast(data),
|
|
)));
|
|
}
|