Skip to content

Commit

Permalink
Enable using OT SVG in FreeType
Browse files Browse the repository at this point in the history
  • Loading branch information
tchayen committed Aug 26, 2024
1 parent 86fc802 commit 80fd898
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/freetype.zig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ pub const c = @cImport({
@cInclude("freetype/ftstroke.h");
@cInclude("freetype/fttrigon.h");
@cInclude("freetype/ftsynth.h");
@cInclude("freetype/otsvg.h");
@cInclude("freetype/ftmodapi.h");
});

pub const Affine23 = c.FT_Affine23;
Expand Down Expand Up @@ -260,6 +262,7 @@ pub const LoadFlags = packed struct(c_int) {
force_autohint: bool = false,
crop_bitmap: bool = false,
pedantic: bool = false,
advance_only: bool = false,
ignore_global_advance_with: bool = false,
no_recurse: bool = false,
ignore_transform: bool = false,
Expand All @@ -275,7 +278,9 @@ pub const LoadFlags = packed struct(c_int) {
color: bool = false,
compute_metrics: bool = false,
bitmap_metrics_only: bool = false,
_padding0: u9 = 0,
svg_only: bool = false,
no_svg: bool = false,
_padding0: u2 = 0,
};

pub const OpenFlags = packed struct(c_int) {
Expand Down Expand Up @@ -1044,6 +1049,10 @@ pub const Library = struct {
pub fn setLcdFilter(self: Library, lcd_filter: LcdFilter) Error!void {
return intToError(c.FT_Library_SetLcdFilter(self.handle, @intFromEnum(lcd_filter)));
}

pub fn setProperty(self: Library, module_name: [*c]const u8, property_name: [*c]const u8, value: *const anyopaque) Error!void {
return intToError(c.FT_Property_Set(self.handle, module_name, property_name, value));
}
};

pub const OpenArgs = struct {
Expand Down Expand Up @@ -1567,6 +1576,7 @@ pub const Error = error{
BbxTooBig,
CorruptedFontHeader,
CorruptedFontGlyphs,
MissingSVGHooks,
};

pub fn intToError(err: c_int) Error!void {
Expand Down Expand Up @@ -1661,6 +1671,7 @@ pub fn intToError(err: c_int) Error!void {
c.FT_Err_Bbx_Too_Big => Error.BbxTooBig,
c.FT_Err_Corrupted_Font_Header => Error.CorruptedFontHeader,
c.FT_Err_Corrupted_Font_Glyphs => Error.CorruptedFontGlyphs,
c.FT_Err_Missing_SVG_Hooks => Error.MissingSVGHooks,
else => unreachable,
};
}
Expand Down

0 comments on commit 80fd898

Please sign in to comment.