freetype: Glyph Stroker 100% API Coverage
This commit is contained in:
parent
8184ce82f7
commit
2388eb1c3a
2 changed files with 71 additions and 0 deletions
|
|
@ -6,6 +6,7 @@ const Error = @import("error.zig").Error;
|
|||
const Matrix = @import("types.zig").Matrix;
|
||||
const BBox = @import("types.zig").BBox;
|
||||
const Vector = @import("image.zig").Vector;
|
||||
const Stroker = @import("stroke.zig").Stroker;
|
||||
|
||||
const Outline = @This();
|
||||
|
||||
|
|
@ -39,6 +40,14 @@ pub fn transform(self: Outline, matrix: ?Matrix) void {
|
|||
c.FT_Outline_Transform(self.handle, if (matrix) |m| &m else null);
|
||||
}
|
||||
|
||||
pub fn getInsideBorder(self: Outline) Stroker.Border {
|
||||
return @intToEnum(Stroker.Border, c.FT_Outline_GetInsideBorder(self.handle));
|
||||
}
|
||||
|
||||
pub fn getOutsideBorder(self: Outline) Stroker.Border {
|
||||
return @intToEnum(Stroker.Border, c.FT_Outline_GetOutsideBorder(self.handle));
|
||||
}
|
||||
|
||||
pub fn bbox(self: Outline) Error!BBox {
|
||||
var b: BBox = undefined;
|
||||
try intToError(c.FT_Outline_Get_BBox(self.handle, &b));
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
const c = @import("c");
|
||||
const intToError = @import("error.zig").intToError;
|
||||
const Error = @import("error.zig").Error;
|
||||
const Outline = @import("Outline.zig");
|
||||
const Vector = @import("image.zig").Vector;
|
||||
|
||||
pub const LineCap = enum(u2) {
|
||||
butt = c.FT_STROKER_LINECAP_BUTT,
|
||||
|
|
@ -14,12 +18,70 @@ pub const LineJoin = enum(u2) {
|
|||
};
|
||||
|
||||
pub const Stroker = struct {
|
||||
pub const Border = enum(u1) {
|
||||
left,
|
||||
right,
|
||||
};
|
||||
|
||||
pub const BorderCounts = struct {
|
||||
points: u32,
|
||||
contours: u32,
|
||||
};
|
||||
|
||||
handle: c.FT_Stroker,
|
||||
|
||||
pub fn set(self: Stroker, radius: i32, line_cap: LineCap, line_join: LineJoin, miter_limit: i32) void {
|
||||
c.FT_Stroker_Set(self.handle, radius, @enumToInt(line_cap), @enumToInt(line_join), miter_limit);
|
||||
}
|
||||
|
||||
pub fn rewind(self: Stroker) void {
|
||||
c.FT_Stroker_Rewind(self.handle);
|
||||
}
|
||||
|
||||
pub fn parseOutline(self: Stroker, outline: Outline, opened: bool) Error!void {
|
||||
try intToError(c.FT_Stroker_ParseOutline(self.handle, outline.handle, if (opened) 1 else 0));
|
||||
}
|
||||
|
||||
pub fn beginSubPath(self: Stroker, to: *Vector, open: bool) Error!void {
|
||||
try intToError(c.FT_Stroker_BeginSubPath(self.handle, to, if (open) 1 else 0));
|
||||
}
|
||||
|
||||
pub fn endSubPath(self: Stroker) Error!void {
|
||||
try intToError(c.FT_Stroker_EndSubPath(self.handle));
|
||||
}
|
||||
|
||||
pub fn lineTo(self: Stroker, to: *Vector) Error!void {
|
||||
try intToError(c.FT_Stroker_LineTo(self.handle, to));
|
||||
}
|
||||
|
||||
pub fn conicTo(self: Stroker, control: *Vector, to: *Vector) Error!void {
|
||||
try intToError(c.FT_Stroker_ConicTo(self.handle, control, to));
|
||||
}
|
||||
|
||||
pub fn cubicTo(self: Stroker, control_0: *Vector, control_1: *Vector, to: *Vector) Error!void {
|
||||
try intToError(c.FT_Stroker_CubicTo(self.handle, control_0, control_1, to));
|
||||
}
|
||||
|
||||
pub fn getBorderCounts(self: Stroker, border: Border) Error!BorderCounts {
|
||||
var counts: BorderCounts = undefined;
|
||||
try intToError(c.FT_Stroker_GetBorderCounts(self.handle, @enumToInt(border), &counts.points, &counts.contours));
|
||||
return counts;
|
||||
}
|
||||
|
||||
pub fn exportBorder(self: Stroker, border: Border, outline: *Outline) void {
|
||||
c.FT_Stroker_ExportBorder(self.handle, @enumToInt(border), outline.handle);
|
||||
}
|
||||
|
||||
pub fn getCounts(self: Stroker) Error!BorderCounts {
|
||||
var counts: BorderCounts = undefined;
|
||||
try intToError(c.FT_Stroker_GetCounts(self.handle, &counts.points, &counts.contours));
|
||||
return counts;
|
||||
}
|
||||
|
||||
pub fn exportAll(self: Stroker, outline: *Outline) void {
|
||||
c.FT_Stroker_Export(self.handle, outline.handle);
|
||||
}
|
||||
|
||||
pub fn deinit(self: Stroker) void {
|
||||
c.FT_Stroker_Done(self.handle);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue