mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
pkg/harfbuzz: fixing some APIs
This commit is contained in:
@ -228,13 +228,13 @@ pub const Feature = extern struct {
|
||||
end: c_uint,
|
||||
|
||||
pub fn fromString(str: []const u8) ?Feature {
|
||||
var f: Feature = undefined;
|
||||
var f: c.hb_feature_t = undefined;
|
||||
return if (c.hb_feature_from_string(
|
||||
str.ptr,
|
||||
@intCast(c_int, str.len),
|
||||
&f,
|
||||
) > 1)
|
||||
f
|
||||
) > 0)
|
||||
@bitCast(Feature, f)
|
||||
else
|
||||
null;
|
||||
}
|
||||
@ -243,3 +243,8 @@ pub const Feature = extern struct {
|
||||
c.hb_feature_to_string(self, buf.ptr, @intCast(c_uint, buf.len));
|
||||
}
|
||||
};
|
||||
|
||||
test "feature from string" {
|
||||
const testing = std.testing;
|
||||
try testing.expect(Feature.fromString("dlig") != null);
|
||||
}
|
||||
|
@ -10,10 +10,20 @@ const Feature = @import("common.zig").Feature;
|
||||
/// but overlapping ranges the value of the feature with the higher index
|
||||
/// takes precedence.
|
||||
pub fn shape(font: Font, buf: Buffer, features: ?[]const Feature) void {
|
||||
const hb_feats: [*c]const c.hb_feature_t = feats: {
|
||||
if (features) |fs| {
|
||||
if (fs.len > 0) {
|
||||
break :feats @ptrCast([*]const c.hb_feature_t, fs.ptr);
|
||||
}
|
||||
}
|
||||
|
||||
break :feats null;
|
||||
};
|
||||
|
||||
c.hb_shape(
|
||||
font.handle,
|
||||
buf.handle,
|
||||
if (features) |f| @ptrCast([*]const c.hb_feature_t, f.ptr) else null,
|
||||
hb_feats,
|
||||
if (features) |f| @intCast(c_uint, f.len) else 0,
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user