freetype: undepend to utils package
This commit is contained in:
parent
157b3b1bd4
commit
1572ed7fc6
9 changed files with 40 additions and 283 deletions
|
|
@ -7,21 +7,16 @@ const hb_root = thisDir() ++ "/upstream/harfbuzz";
|
|||
const hb_include_path = hb_root ++ "/src";
|
||||
const brotli_root = thisDir() ++ "/upstream/brotli";
|
||||
|
||||
const utils_pkg = std.build.Pkg{
|
||||
.name = "utils",
|
||||
.source = .{ .path = thisDir() ++ "/src/utils.zig" },
|
||||
};
|
||||
|
||||
pub const pkg = std.build.Pkg{
|
||||
.name = "freetype",
|
||||
.source = .{ .path = thisDir() ++ "/src/main.zig" },
|
||||
.dependencies = &.{utils_pkg},
|
||||
.dependencies = &.{},
|
||||
};
|
||||
|
||||
pub const harfbuzz_pkg = std.build.Pkg{
|
||||
.name = "harfbuzz",
|
||||
.source = .{ .path = thisDir() ++ "/src/harfbuzz/main.zig" },
|
||||
.dependencies = &.{ utils_pkg, pkg },
|
||||
.dependencies = &.{pkg},
|
||||
};
|
||||
|
||||
pub const Options = struct {
|
||||
|
|
@ -91,7 +86,6 @@ pub fn testStep(b: *Builder, mode: std.builtin.Mode, target: std.zig.CrossTarget
|
|||
const harfbuzz_tests = b.addTestExe("harfbuzz-tests", (comptime thisDir()) ++ "/src/harfbuzz/main.zig");
|
||||
harfbuzz_tests.setBuildMode(mode);
|
||||
harfbuzz_tests.setTarget(target);
|
||||
harfbuzz_tests.addPackage(utils_pkg);
|
||||
harfbuzz_tests.addPackage(pkg);
|
||||
link(b, harfbuzz_tests, .{
|
||||
.freetype = .{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
const std = @import("std");
|
||||
const utils = @import("utils");
|
||||
const c = @import("c.zig");
|
||||
const intToError = @import("error.zig").intToError;
|
||||
const Error = @import("error.zig").Error;
|
||||
|
|
@ -78,11 +77,11 @@ pub fn attachStream(self: Face, args: OpenArgs) Error!void {
|
|||
}
|
||||
|
||||
pub fn loadGlyph(self: Face, index: u32, flags: LoadFlags) Error!void {
|
||||
return intToError(c.FT_Load_Glyph(self.handle, index, flags.cast()));
|
||||
return intToError(c.FT_Load_Glyph(self.handle, index, @bitCast(i32, flags)));
|
||||
}
|
||||
|
||||
pub fn loadChar(self: Face, char: u32, flags: LoadFlags) Error!void {
|
||||
return intToError(c.FT_Load_Char(self.handle, char, flags.cast()));
|
||||
return intToError(c.FT_Load_Char(self.handle, char, @bitCast(i32, flags)));
|
||||
}
|
||||
|
||||
pub fn setCharSize(self: Face, pt_width: i32, pt_height: i32, horz_resolution: u16, vert_resolution: u16) Error!void {
|
||||
|
|
@ -161,7 +160,7 @@ pub fn setCharmap(self: Face, char_map: *CharMap) Error!void {
|
|||
}
|
||||
|
||||
pub fn getFSTypeFlags(self: Face) FSType {
|
||||
return FSType.from(c.FT_Get_FSType_Flags(self.handle));
|
||||
return @bitCast(FSType, c.FT_Get_FSType_Flags(self.handle));
|
||||
}
|
||||
|
||||
pub fn getCharVariantIndex(self: Face, char: u32, variant_selector: u32) ?u32 {
|
||||
|
|
@ -272,11 +271,11 @@ pub fn faceIndex(self: Face) u32 {
|
|||
}
|
||||
|
||||
pub fn faceFlags(self: Face) FaceFlags {
|
||||
return FaceFlags.from(self.handle.*.face_flags);
|
||||
return @bitCast(FaceFlags, self.handle.*.face_flags);
|
||||
}
|
||||
|
||||
pub fn styleFlags(self: Face) StyleFlags {
|
||||
return StyleFlags.from(self.handle.*.style_flags);
|
||||
return @bitCast(StyleFlags, self.handle.*.style_flags);
|
||||
}
|
||||
|
||||
pub fn numGlyphs(self: Face) u32 {
|
||||
|
|
@ -310,12 +309,12 @@ pub fn availableSizes(self: Face) ?BitmapSize {
|
|||
|
||||
pub fn getAdvance(self: Face, glyph_index: u32, load_flags: LoadFlags) Error!i32 {
|
||||
var a: i32 = 0;
|
||||
try intToError(c.FT_Get_Advance(self.handle, glyph_index, load_flags.cast(), &@intCast(c_long, a)));
|
||||
try intToError(c.FT_Get_Advance(self.handle, glyph_index, @bitCast(i32, load_flags), &@intCast(c_long, a)));
|
||||
return a;
|
||||
}
|
||||
|
||||
pub fn getAdvances(self: Face, start: u32, advances_out: []c_long, load_flags: LoadFlags) Error!void {
|
||||
try intToError(c.FT_Get_Advances(self.handle, start, @intCast(c_uint, advances_out.len), load_flags.cast(), advances_out.ptr));
|
||||
try intToError(c.FT_Get_Advances(self.handle, start, @intCast(u32, advances_out.len), @bitCast(i32, load_flags), advances_out.ptr));
|
||||
}
|
||||
|
||||
pub fn numCharmaps(self: Face) u32 {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
const utils = @import("utils.zig");
|
||||
const std = @import("std");
|
||||
const testing = std.testing;
|
||||
const c = @import("c.zig");
|
||||
const Face = @import("freetype.zig").Face;
|
||||
|
||||
|
|
@ -115,7 +116,7 @@ pub const PaletteData = struct {
|
|||
}
|
||||
|
||||
pub fn paletteFlag(self: PaletteData, index: u32) PaletteFlags {
|
||||
return PaletteFlags.from(self.handle.palette_flags[index]);
|
||||
return @bitCast(PaletteFlags, self.handle.palette_flags[index]);
|
||||
}
|
||||
|
||||
pub fn numPaletteEntries(self: PaletteData) u16 {
|
||||
|
|
@ -130,19 +131,7 @@ pub const PaletteData = struct {
|
|||
pub const PaletteFlags = packed struct {
|
||||
for_light_background: bool = false,
|
||||
for_dark_background: bool = false,
|
||||
|
||||
pub const Flag = enum(u2) {
|
||||
for_light_background = c.FT_PALETTE_FOR_LIGHT_BACKGROUND,
|
||||
for_dark_background = c.FT_PALETTE_FOR_DARK_BACKGROUND,
|
||||
};
|
||||
|
||||
pub fn from(bits: c_int) PaletteFlags {
|
||||
return utils.bitFieldsToStruct(PaletteFlags, Flag, bits);
|
||||
}
|
||||
|
||||
pub fn to(flags: PaletteFlags) c_int {
|
||||
return utils.structToBitFields(c_int, Flag, flags);
|
||||
}
|
||||
_padding: u14 = 0,
|
||||
};
|
||||
|
||||
pub const GlyphLayersIterator = struct {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const std = @import("std");
|
||||
const utils = @import("utils.zig");
|
||||
const testing = std.testing;
|
||||
const c = @import("c.zig");
|
||||
const intToError = @import("error.zig").intToError;
|
||||
const Error = @import("error.zig").Error;
|
||||
|
|
@ -95,43 +95,16 @@ pub const LoadFlags = packed struct {
|
|||
monochrome: bool = false,
|
||||
linear_design: bool = false,
|
||||
no_autohint: bool = false,
|
||||
_padding: u1 = 0,
|
||||
target_normal: bool = false,
|
||||
target_light: bool = false,
|
||||
target_mono: bool = false,
|
||||
target_lcd: bool = false,
|
||||
target_lcd_v: bool = false,
|
||||
color: bool = false,
|
||||
|
||||
pub const Flag = enum(u21) {
|
||||
no_scale = c.FT_LOAD_NO_SCALE,
|
||||
no_hinting = c.FT_LOAD_NO_HINTING,
|
||||
render = c.FT_LOAD_RENDER,
|
||||
no_bitmap = c.FT_LOAD_NO_BITMAP,
|
||||
vertical_layout = c.FT_LOAD_VERTICAL_LAYOUT,
|
||||
force_autohint = c.FT_LOAD_FORCE_AUTOHINT,
|
||||
crop_bitmap = c.FT_LOAD_CROP_BITMAP,
|
||||
pedantic = c.FT_LOAD_PEDANTIC,
|
||||
ignore_global_advance_with = c.FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH,
|
||||
no_recurse = c.FT_LOAD_NO_RECURSE,
|
||||
ignore_transform = c.FT_LOAD_IGNORE_TRANSFORM,
|
||||
monochrome = c.FT_LOAD_MONOCHROME,
|
||||
linear_design = c.FT_LOAD_LINEAR_DESIGN,
|
||||
no_autohint = c.FT_LOAD_NO_AUTOHINT,
|
||||
target_normal = c.FT_LOAD_TARGET_NORMAL,
|
||||
target_light = c.FT_LOAD_TARGET_LIGHT,
|
||||
target_mono = c.FT_LOAD_TARGET_MONO,
|
||||
target_lcd = c.FT_LOAD_TARGET_LCD,
|
||||
target_lcd_v = c.FT_LOAD_TARGET_LCD_V,
|
||||
color = c.FT_LOAD_COLOR,
|
||||
};
|
||||
|
||||
pub fn from(bits: c_int) LoadFlags {
|
||||
return utils.bitFieldsToStruct(LoadFlags, Flag, bits);
|
||||
}
|
||||
|
||||
pub fn cast(self: LoadFlags) c_int {
|
||||
return utils.structToBitFields(c_int, Flag, self);
|
||||
}
|
||||
compute_metrics: bool = false,
|
||||
bitmap_metrics_only: bool = false,
|
||||
_padding0: u9 = 0,
|
||||
};
|
||||
|
||||
pub const FaceFlags = packed struct {
|
||||
|
|
@ -154,36 +127,7 @@ pub const FaceFlags = packed struct {
|
|||
svg: bool = false,
|
||||
sbix: bool = false,
|
||||
sbix_overlay: bool = false,
|
||||
|
||||
pub const Flag = enum(u19) {
|
||||
scalable = c.FT_FACE_FLAG_SCALABLE,
|
||||
fixed_sizes = c.FT_FACE_FLAG_FIXED_SIZES,
|
||||
fixed_width = c.FT_FACE_FLAG_FIXED_WIDTH,
|
||||
sfnt = c.FT_FACE_FLAG_SFNT,
|
||||
horizontal = c.FT_FACE_FLAG_HORIZONTAL,
|
||||
vertical = c.FT_FACE_FLAG_VERTICAL,
|
||||
kerning = c.FT_FACE_FLAG_KERNING,
|
||||
fast_glyphs = c.FT_FACE_FLAG_FAST_GLYPHS,
|
||||
multiple_masters = c.FT_FACE_FLAG_MULTIPLE_MASTERS,
|
||||
glyph_names = c.FT_FACE_FLAG_GLYPH_NAMES,
|
||||
external_stream = c.FT_FACE_FLAG_EXTERNAL_STREAM,
|
||||
hinter = c.FT_FACE_FLAG_HINTER,
|
||||
cid_keyed = c.FT_FACE_FLAG_CID_KEYED,
|
||||
tricky = c.FT_FACE_FLAG_TRICKY,
|
||||
color = c.FT_FACE_FLAG_COLOR,
|
||||
variation = c.FT_FACE_FLAG_VARIATION,
|
||||
svg = c.FT_FACE_FLAG_SVG,
|
||||
sbix = c.FT_FACE_FLAG_SBIX,
|
||||
sbix_overlay = c.FT_FACE_FLAG_SBIX_OVERLAY,
|
||||
};
|
||||
|
||||
pub fn from(bits: c_long) FaceFlags {
|
||||
return utils.bitFieldsToStruct(FaceFlags, Flag, bits);
|
||||
}
|
||||
|
||||
pub fn cast(self: FaceFlags) c_long {
|
||||
return utils.structToBitFields(c_long, Flag, self);
|
||||
}
|
||||
_padding: u45 = 0,
|
||||
};
|
||||
|
||||
pub const FSType = packed struct {
|
||||
|
|
@ -191,43 +135,16 @@ pub const FSType = packed struct {
|
|||
restriced_license_embedding: bool = false,
|
||||
preview_and_print_embedding: bool = false,
|
||||
editable_embedding: bool = false,
|
||||
_padding: u4 = 0,
|
||||
no_subsetting: bool = false,
|
||||
bitmap_embedding_only: bool = false,
|
||||
|
||||
pub const Flag = enum(u10) {
|
||||
installable_embedding = c.FT_FSTYPE_INSTALLABLE_EMBEDDING,
|
||||
restriced_license_embedding = c.FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING,
|
||||
preview_and_print_embedding = c.FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING,
|
||||
editable_embedding = c.FT_FSTYPE_EDITABLE_EMBEDDING,
|
||||
no_subsetting = c.FT_FSTYPE_NO_SUBSETTING,
|
||||
bitmap_embedding_only = c.FT_FSTYPE_BITMAP_EMBEDDING_ONLY,
|
||||
};
|
||||
|
||||
pub fn from(bits: c_int) FSType {
|
||||
return utils.bitFieldsToStruct(FSType, Flag, bits);
|
||||
}
|
||||
|
||||
pub fn cast(self: FSType) c_int {
|
||||
return utils.structToBitFields(c_int, Flag, self);
|
||||
}
|
||||
_padding0: u6 = 0,
|
||||
};
|
||||
|
||||
pub const StyleFlags = packed struct {
|
||||
italic: bool = false,
|
||||
bold: bool = false,
|
||||
|
||||
pub const Flag = enum(u2) {
|
||||
italic = c.FT_STYLE_FLAG_ITALIC,
|
||||
bold = c.FT_STYLE_FLAG_BOLD,
|
||||
};
|
||||
|
||||
pub fn from(bits: c_long) StyleFlags {
|
||||
return utils.bitFieldsToStruct(StyleFlags, Flag, bits);
|
||||
}
|
||||
|
||||
pub fn cast(self: StyleFlags) c_long {
|
||||
return utils.structToBitFields(c_long, Flag, self);
|
||||
}
|
||||
_padding: u62 = 0,
|
||||
};
|
||||
|
||||
pub const OpenFlags = packed struct {
|
||||
|
|
@ -236,22 +153,7 @@ pub const OpenFlags = packed struct {
|
|||
path: bool = false,
|
||||
driver: bool = false,
|
||||
params: bool = false,
|
||||
|
||||
pub const Flag = enum(u5) {
|
||||
memory = c.FT_OPEN_MEMORY,
|
||||
stream = c.FT_OPEN_STREAM,
|
||||
path = c.FT_OPEN_PATHNAME,
|
||||
driver = c.FT_OPEN_DRIVER,
|
||||
params = c.FT_OPEN_PARAMS,
|
||||
};
|
||||
|
||||
pub fn from(bits: c_uint) OpenFlags {
|
||||
return utils.bitFieldsToStruct(OpenFlags, Flag, bits);
|
||||
}
|
||||
|
||||
pub fn cast(flags: OpenFlags) c_uint {
|
||||
return utils.structToBitFields(c_uint, Flag, flags);
|
||||
}
|
||||
_padding: u27 = 0,
|
||||
};
|
||||
pub const OpenArgs = struct {
|
||||
flags: OpenFlags,
|
||||
|
|
@ -265,7 +167,7 @@ pub const OpenArgs = struct {
|
|||
|
||||
pub fn cast(self: OpenArgs) c.FT_Open_Args {
|
||||
var oa: c.FT_Open_Args = undefined;
|
||||
oa.flags = self.flags.cast();
|
||||
oa.flags = @bitCast(u32, self.flags);
|
||||
switch (self.data) {
|
||||
.memory => |d| {
|
||||
oa.memory_base = d.ptr;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
const std = @import("std");
|
||||
const utils = @import("utils");
|
||||
const c = @import("c.zig");
|
||||
const Direction = @import("common.zig").Direction;
|
||||
const Script = @import("common.zig").Script;
|
||||
|
|
@ -32,7 +31,7 @@ pub const GlyphInfo = extern struct {
|
|||
var2: u32,
|
||||
|
||||
pub fn getFlags(self: GlyphInfo) GlyphFlags {
|
||||
return GlyphFlags.from(hb_glyph_info_get_glyph_flags(&self));
|
||||
return @bitCast(GlyphFlags, hb_glyph_info_get_glyph_flags(&self));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -46,19 +45,7 @@ pub const Position = extern struct {
|
|||
pub const GlyphFlags = packed struct {
|
||||
unsafe_to_break: bool = false,
|
||||
unsafe_to_concat: bool = false,
|
||||
|
||||
pub const Flag = enum(u2) {
|
||||
unsafe_to_break = c.HB_GLYPH_FLAG_UNSAFE_TO_BREAK,
|
||||
unsafe_to_concat = c.HB_GLYPH_FLAG_UNSAFE_TO_CONCAT,
|
||||
};
|
||||
|
||||
pub fn from(bits: c_uint) GlyphFlags {
|
||||
return utils.bitFieldsToStruct(GlyphFlags, Flag, bits);
|
||||
}
|
||||
|
||||
pub fn cast(self: GlyphFlags) c_uint {
|
||||
return utils.structToBitFields(c_uint, Flag, self);
|
||||
}
|
||||
_padding: u30 = 0,
|
||||
};
|
||||
|
||||
pub const SegmentProps = struct {
|
||||
|
|
@ -104,27 +91,10 @@ pub const SerializeFlags = packed struct {
|
|||
glyph_extents: bool = false,
|
||||
glyph_flags: bool = false,
|
||||
no_advances: bool = false,
|
||||
|
||||
pub const Flag = enum(u6) {
|
||||
no_clusters = c.HB_BUFFER_SERIALIZE_FLAG_NO_CLUSTERS,
|
||||
no_positions = c.HB_BUFFER_SERIALIZE_FLAG_NO_POSITIONS,
|
||||
no_glyph_names = c.HB_BUFFER_SERIALIZE_FLAG_NO_GLYPH_NAMES,
|
||||
glyph_extents = c.HB_BUFFER_SERIALIZE_FLAG_GLYPH_EXTENTS,
|
||||
glyph_flags = c.HB_BUFFER_SERIALIZE_FLAG_GLYPH_FLAGS,
|
||||
no_advances = c.HB_BUFFER_SERIALIZE_FLAG_NO_ADVANCES,
|
||||
};
|
||||
|
||||
pub fn from(bits: u6) SerializeFlags {
|
||||
return utils.bitFieldsToStruct(SerializeFlags, Flag, bits);
|
||||
}
|
||||
|
||||
pub fn cast(self: SerializeFlags) u6 {
|
||||
return utils.structToBitFields(u6, Flag, self);
|
||||
}
|
||||
_padding: u26 = 0,
|
||||
};
|
||||
|
||||
pub const DiffFlags = packed struct {
|
||||
equal: bool = false,
|
||||
content_type_mismatch: bool = false,
|
||||
length_mismatch: bool = false,
|
||||
notdef_present: bool = false,
|
||||
|
|
@ -133,26 +103,7 @@ pub const DiffFlags = packed struct {
|
|||
cluster_mismatch: bool = false,
|
||||
glyph_flags_mismatch: bool = false,
|
||||
position_mismatch: bool = false,
|
||||
|
||||
pub const Flag = enum(u8) {
|
||||
equal = c.HB_BUFFER_DIFF_FLAG_EQUAL,
|
||||
content_type_mismatch = c.HB_BUFFER_DIFF_FLAG_CONTENT_TYPE_MISMATCH,
|
||||
length_mismatch = c.HB_BUFFER_DIFF_FLAG_LENGTH_MISMATCH,
|
||||
notdef_present = c.HB_BUFFER_DIFF_FLAG_NOTDEF_PRESENT,
|
||||
dotted_circle_present = c.HB_BUFFER_DIFF_FLAG_DOTTED_CIRCLE_PRESENT,
|
||||
codepoint_mismatch = c.HB_BUFFER_DIFF_FLAG_CODEPOINT_MISMATCH,
|
||||
cluster_mismatch = c.HB_BUFFER_DIFF_FLAG_CLUSTER_MISMATCH,
|
||||
glyph_flags_mismatch = c.HB_BUFFER_DIFF_FLAG_GLYPH_FLAGS_MISMATCH,
|
||||
position_mismatch = c.HB_BUFFER_DIFF_FLAG_POSITION_MISMATCH,
|
||||
};
|
||||
|
||||
pub fn from(bits: c_uint) DiffFlags {
|
||||
return utils.bitFieldsToStruct(DiffFlags, Flag, bits);
|
||||
}
|
||||
|
||||
pub fn cast(self: DiffFlags) c_uint {
|
||||
return utils.structToBitFields(c_uint, Flag, self);
|
||||
}
|
||||
_padding: u24 = 0,
|
||||
};
|
||||
|
||||
pub const Buffer = struct {
|
||||
|
|
@ -164,24 +115,7 @@ pub const Buffer = struct {
|
|||
do_not_insert_dotted_circle: bool = false,
|
||||
verify: bool = false,
|
||||
produce_unsafe_to_concat: bool = false,
|
||||
|
||||
pub const Flag = enum(u7) {
|
||||
bot = c.HB_BUFFER_FLAG_BOT,
|
||||
eot = c.HB_BUFFER_FLAG_EOT,
|
||||
preserve_default_ignorables = c.HB_BUFFER_FLAG_PRESERVE_DEFAULT_IGNORABLES,
|
||||
remove_default_ignorables = c.HB_BUFFER_FLAG_REMOVE_DEFAULT_IGNORABLES,
|
||||
do_not_insert_dotted_circle = c.HB_BUFFER_FLAG_DO_NOT_INSERT_DOTTED_CIRCLE,
|
||||
verify = c.HB_BUFFER_FLAG_VERIFY,
|
||||
produce_unsafe_to_concat = c.HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT,
|
||||
};
|
||||
|
||||
pub fn from(bits: c_uint) Flags {
|
||||
return utils.bitFieldsToStruct(Flags, Flag, bits);
|
||||
}
|
||||
|
||||
pub fn cast(self: Flags) c_uint {
|
||||
return utils.structToBitFields(c_uint, Flag, self);
|
||||
}
|
||||
_padding: u25 = 0,
|
||||
};
|
||||
|
||||
handle: *c.hb_buffer_t,
|
||||
|
|
@ -292,11 +226,11 @@ pub const Buffer = struct {
|
|||
}
|
||||
|
||||
pub fn getFlags(self: Buffer) Flags {
|
||||
return Flags.from(c.hb_buffer_get_flags(self.handle));
|
||||
return @bitCast(Flags, c.hb_buffer_get_flags(self.handle));
|
||||
}
|
||||
|
||||
pub fn setFlags(self: Buffer, flags: Flags) void {
|
||||
c.hb_buffer_set_flags(self.handle, flags.cast());
|
||||
c.hb_buffer_set_flags(self.handle, @bitCast(u32, flags));
|
||||
}
|
||||
|
||||
pub fn getClusterLevel(self: Buffer) ClusterLevel {
|
||||
|
|
@ -388,7 +322,7 @@ pub const Buffer = struct {
|
|||
}
|
||||
|
||||
pub fn diff(self: Buffer, ref: Buffer, dottedcircle_glyph: u32, position_fuzz: u32) DiffFlags {
|
||||
return DiffFlags.from(c.hb_buffer_diff(self.handle, ref.handle, dottedcircle_glyph, position_fuzz));
|
||||
return @bitCast(DiffFlags, c.hb_buffer_diff(self.handle, ref.handle, dottedcircle_glyph, position_fuzz));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -27,12 +27,12 @@ pub const Font = struct {
|
|||
c.hb_font_destroy(self.handle);
|
||||
}
|
||||
|
||||
pub fn ftFaceChanged(self: Font) void {
|
||||
pub fn freetypeFaceChanged(self: Font) void {
|
||||
c.hb_ft_font_changed(self.handle);
|
||||
}
|
||||
|
||||
pub fn setFtLoadFlags(self: Font, flags: freetype.LoadFlags) void {
|
||||
c.hb_ft_font_set_load_flags(self.handle, flags.cast());
|
||||
pub fn setFreetypeLoadFlags(self: Font, flags: freetype.LoadFlags) void {
|
||||
c.hb_ft_font_set_load_flags(self.handle, @bitCast(i32, flags));
|
||||
}
|
||||
|
||||
pub fn getFace(self: Font) Face {
|
||||
|
|
|
|||
|
|
@ -7,12 +7,6 @@ pub usingnamespace @import("shape.zig");
|
|||
pub usingnamespace @import("shape_plan.zig");
|
||||
|
||||
const std = @import("std");
|
||||
|
||||
// Remove once the stage2 compiler fixes pkg std not found
|
||||
comptime {
|
||||
_ = @import("utils");
|
||||
}
|
||||
|
||||
test {
|
||||
std.testing.refAllDeclsRecursive(@This());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
const builtin = @import("builtin");
|
||||
const std = @import("std");
|
||||
const testing = std.testing;
|
||||
const c = @import("c.zig");
|
||||
const utils = @import("utils.zig");
|
||||
const intToError = @import("error.zig").intToError;
|
||||
const errorToInt = @import("error.zig").errorToInt;
|
||||
const Error = @import("error.zig").Error;
|
||||
|
|
@ -109,7 +109,6 @@ pub const Outline = struct {
|
|||
};
|
||||
|
||||
pub const Flags = packed struct {
|
||||
none: bool = false,
|
||||
owner: bool = false,
|
||||
even_odd_fill: bool = false,
|
||||
reverse_fill: bool = false,
|
||||
|
|
@ -117,29 +116,10 @@ pub const Outline = struct {
|
|||
smart_dropouts: bool = false,
|
||||
include_stubs: bool = false,
|
||||
overlap: bool = false,
|
||||
_padding: u1 = 0,
|
||||
high_precision: bool = false,
|
||||
single_pass: bool = false,
|
||||
|
||||
pub const Flag = enum(u21) {
|
||||
none = c.FT_OUTLINE_NONE,
|
||||
owner = c.FT_OUTLINE_OWNER,
|
||||
even_odd_fill = c.FT_OUTLINE_EVEN_ODD_FILL,
|
||||
reverse_fill = c.FT_OUTLINE_REVERSE_FILL,
|
||||
ignore_dropouts = c.FT_OUTLINE_IGNORE_DROPOUTS,
|
||||
smart_dropouts = c.FT_OUTLINE_SMART_DROPOUTS,
|
||||
include_stubs = c.FT_OUTLINE_INCLUDE_STUBS,
|
||||
overlap = c.FT_OUTLINE_OVERLAP,
|
||||
high_precision = c.FT_OUTLINE_HIGH_PRECISION,
|
||||
single_pass = c.FT_OUTLINE_SINGLE_PASS,
|
||||
};
|
||||
|
||||
pub fn from(bits: c_int) Flags {
|
||||
return utils.bitFieldsToStruct(Flags, Flag, bits);
|
||||
}
|
||||
|
||||
pub fn cast(self: Flags) c_int {
|
||||
return utils.structToBitFields(c_int, Flag, self);
|
||||
}
|
||||
_padding0: u22 = 0,
|
||||
};
|
||||
|
||||
handle: *c.FT_Outline,
|
||||
|
|
@ -165,7 +145,7 @@ pub const Outline = struct {
|
|||
}
|
||||
|
||||
pub fn flags(self: Outline) Flags {
|
||||
return Flags.from(self.handle.*.flags);
|
||||
return @bitCast(Flags, self.handle.*.flags);
|
||||
}
|
||||
|
||||
pub fn copy(self: Outline) Error!Outline {
|
||||
|
|
@ -361,20 +341,6 @@ pub const Raster = struct {
|
|||
direct: bool = false,
|
||||
clip: bool = false,
|
||||
sdf: bool = false,
|
||||
|
||||
pub const Flag = enum(u10) {
|
||||
aa = c.FT_RASTER_FLAG_AA,
|
||||
direct = c.FT_RASTER_FLAG_DIRECT,
|
||||
clip = c.FT_RASTER_FLAG_CLIP,
|
||||
sdf = c.FT_RASTER_FLAG_SDF,
|
||||
};
|
||||
|
||||
pub fn from(bits: c_int) Flags {
|
||||
return utils.bitFieldsToStruct(Flags, Flag, bits);
|
||||
}
|
||||
|
||||
pub fn cast(self: Flags) c_int {
|
||||
return utils.structToBitFields(c_int, Flag, self);
|
||||
}
|
||||
_padding: u28 = 0,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
const std = @import("std");
|
||||
|
||||
pub fn structToBitFields(comptime IntType: type, comptime EnumDataType: type, flags: anytype) IntType {
|
||||
var value: IntType = 0;
|
||||
inline for (comptime std.meta.fieldNames(EnumDataType)) |field_name| {
|
||||
if (@field(flags, field_name)) {
|
||||
value |= @enumToInt(@field(EnumDataType, field_name));
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
pub fn bitFieldsToStruct(comptime StructType: type, comptime EnumDataType: type, flags: anytype) StructType {
|
||||
var value = std.mem.zeroes(StructType);
|
||||
inline for (comptime std.meta.fieldNames(EnumDataType)) |field_name| {
|
||||
if (flags & (@enumToInt(@field(EnumDataType, field_name))) != 0) {
|
||||
@field(value, field_name) = true;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue