mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
pkg/harfbuzz: shape
This commit is contained in:
@ -214,3 +214,32 @@ pub const Language = struct {
|
|||||||
return .{ .handle = c.hb_language_get_default() };
|
return .{ .handle = c.hb_language_get_default() };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// The hb_feature_t is the structure that holds information about requested
|
||||||
|
/// feature application. The feature will be applied with the given value to
|
||||||
|
/// all glyphs which are in clusters between start (inclusive) and end
|
||||||
|
/// (exclusive). Setting start to HB_FEATURE_GLOBAL_START and end to
|
||||||
|
/// HB_FEATURE_GLOBAL_END specifies that the feature always applies to the
|
||||||
|
/// entire buffer.
|
||||||
|
pub const Feature = extern struct {
|
||||||
|
tag: c.hb_tag_t,
|
||||||
|
value: u32,
|
||||||
|
start: c_uint,
|
||||||
|
end: c_uint,
|
||||||
|
|
||||||
|
pub fn fromString(str: []const u8) ?Feature {
|
||||||
|
var f: Feature = undefined;
|
||||||
|
return if (c.hb_feature_from_string(
|
||||||
|
str.ptr,
|
||||||
|
@intCast(c_int, str.len),
|
||||||
|
&f,
|
||||||
|
) > 1)
|
||||||
|
f
|
||||||
|
else
|
||||||
|
null;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn toString(self: *Feature, buf: []u8) void {
|
||||||
|
c.hb_feature_to_string(self, buf.ptr, @intCast(c_uint, buf.len));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@ -5,6 +5,7 @@ pub usingnamespace @import("common.zig");
|
|||||||
pub usingnamespace @import("errors.zig");
|
pub usingnamespace @import("errors.zig");
|
||||||
pub usingnamespace @import("face.zig");
|
pub usingnamespace @import("face.zig");
|
||||||
pub usingnamespace @import("font.zig");
|
pub usingnamespace @import("font.zig");
|
||||||
|
pub usingnamespace @import("shape.zig");
|
||||||
pub usingnamespace @import("version.zig");
|
pub usingnamespace @import("version.zig");
|
||||||
pub const Freetype = @import("freetype.zig");
|
pub const Freetype = @import("freetype.zig");
|
||||||
|
|
||||||
|
19
pkg/harfbuzz/shape.zig
Normal file
19
pkg/harfbuzz/shape.zig
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
const std = @import("std");
|
||||||
|
const c = @import("c.zig");
|
||||||
|
const Font = @import("font.zig").Font;
|
||||||
|
const Buffer = @import("buffer.zig").Buffer;
|
||||||
|
const Feature = @import("common.zig").Feature;
|
||||||
|
|
||||||
|
/// Shapes buffer using font turning its Unicode characters content to
|
||||||
|
/// positioned glyphs. If features is not NULL, it will be used to control
|
||||||
|
/// the features applied during shaping. If two features have the same tag
|
||||||
|
/// 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 {
|
||||||
|
c.hb_shape(
|
||||||
|
font.handle,
|
||||||
|
buf.handle,
|
||||||
|
if (features) |f| @ptrCast([*]const c.hb_feature_t, f.ptr) else null,
|
||||||
|
if (features) |f| @intCast(c_uint, f.len) else 0,
|
||||||
|
);
|
||||||
|
}
|
Reference in New Issue
Block a user