all: update to latest Zig APIs (zig fmt)
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
d95a453e78
commit
4bc32adeb8
61 changed files with 806 additions and 806 deletions
|
|
@ -37,12 +37,12 @@ pub const CharmapIterator = struct {
|
|||
return .{
|
||||
.face = face,
|
||||
.index = i,
|
||||
.charcode = @intCast(u32, cc),
|
||||
.charcode = @as(u32, @intCast(cc)),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn next(self: *CharmapIterator) ?u32 {
|
||||
self.charcode = @intCast(u32, c.FT_Get_Next_Char(self.face.handle, self.charcode, &self.index));
|
||||
self.charcode = @as(u32, @intCast(c.FT_Get_Next_Char(self.face.handle, self.charcode, &self.index)));
|
||||
return if (self.index != 0)
|
||||
self.charcode
|
||||
else
|
||||
|
|
@ -77,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, @bitCast(i32, flags)));
|
||||
return intToError(c.FT_Load_Glyph(self.handle, index, @as(i32, @bitCast(flags))));
|
||||
}
|
||||
|
||||
pub fn loadChar(self: Face, char: u32, flags: LoadFlags) Error!void {
|
||||
return intToError(c.FT_Load_Char(self.handle, char, @bitCast(i32, flags)));
|
||||
return intToError(c.FT_Load_Char(self.handle, char, @as(i32, @bitCast(flags))));
|
||||
}
|
||||
|
||||
pub fn setCharSize(self: Face, pt_width: i32, pt_height: i32, horz_resolution: u16, vert_resolution: u16) Error!void {
|
||||
|
|
@ -133,16 +133,16 @@ pub fn getKerning(self: Face, left_char_index: u32, right_char_index: u32, mode:
|
|||
pub fn getTrackKerning(self: Face, point_size: i32, degree: i32) Error!i32 {
|
||||
var kerning: c_long = 0;
|
||||
try intToError(c.FT_Get_Track_Kerning(self.handle, point_size, degree, kerning));
|
||||
return @intCast(i32, kerning);
|
||||
return @as(i32, @intCast(kerning));
|
||||
}
|
||||
|
||||
pub fn getGlyphName(self: Face, index: u32, buf: []u8) Error!void {
|
||||
try intToError(c.FT_Get_Glyph_Name(self.handle, index, buf.ptr, @intCast(c_uint, buf.len)));
|
||||
try intToError(c.FT_Get_Glyph_Name(self.handle, index, buf.ptr, @as(c_uint, @intCast(buf.len))));
|
||||
}
|
||||
|
||||
pub fn getPostscriptName(self: Face) ?[:0]const u8 {
|
||||
return if (c.FT_Get_Postscript_Name(self.handle)) |face_name|
|
||||
std.mem.span(@ptrCast([*:0]const u8, face_name))
|
||||
std.mem.span(@as([*:0]const u8, @ptrCast(face_name)))
|
||||
else
|
||||
null;
|
||||
}
|
||||
|
|
@ -160,7 +160,7 @@ pub fn setCharmap(self: Face, char_map: *CharMap) Error!void {
|
|||
}
|
||||
|
||||
pub fn getFSTypeFlags(self: Face) FSType {
|
||||
return @bitCast(FSType, c.FT_Get_FSType_Flags(self.handle));
|
||||
return @as(FSType, @bitCast(c.FT_Get_FSType_Flags(self.handle)));
|
||||
}
|
||||
|
||||
pub fn getCharVariantIndex(self: Face, char: u32, variant_selector: u32) ?u32 {
|
||||
|
|
@ -181,21 +181,21 @@ pub fn getCharVariantIsDefault(self: Face, char: u32, variant_selector: u32) ?bo
|
|||
|
||||
pub fn getVariantSelectors(self: Face) ?[]u32 {
|
||||
return if (c.FT_Face_GetVariantSelectors(self.handle)) |chars|
|
||||
@ptrCast([]u32, std.mem.sliceTo(@ptrCast([*:0]u32, chars), 0))
|
||||
@as([]u32, @ptrCast(std.mem.sliceTo(@as([*:0]u32, @ptrCast(chars)), 0)))
|
||||
else
|
||||
null;
|
||||
}
|
||||
|
||||
pub fn getVariantsOfChar(self: Face, char: u32) ?[]u32 {
|
||||
return if (c.FT_Face_GetVariantsOfChar(self.handle, char)) |variants|
|
||||
@ptrCast([]u32, std.mem.sliceTo(@ptrCast([*:0]u32, variants), 0))
|
||||
@as([]u32, @ptrCast(std.mem.sliceTo(@as([*:0]u32, @ptrCast(variants)), 0)))
|
||||
else
|
||||
null;
|
||||
}
|
||||
|
||||
pub fn getCharsOfVariant(self: Face, variant_selector: u32) ?[]u32 {
|
||||
return if (c.FT_Face_GetCharsOfVariant(self.handle, variant_selector)) |chars|
|
||||
@ptrCast([]u32, std.mem.sliceTo(@ptrCast([*:0]u32, chars), 0))
|
||||
@as([]u32, @ptrCast(std.mem.sliceTo(@as([*:0]u32, @ptrCast(chars)), 0)))
|
||||
else
|
||||
null;
|
||||
}
|
||||
|
|
@ -239,7 +239,7 @@ pub fn getPaint(self: Face, opaque_paint: OpaquePaint) ?Paint {
|
|||
var p: c.FT_COLR_Paint = undefined;
|
||||
if (c.FT_Get_Paint(self.handle, opaque_paint, &p) == 0)
|
||||
return null;
|
||||
return switch (@enumFromInt(PaintFormat, p.format)) {
|
||||
return switch (@as(PaintFormat, @enumFromInt(p.format))) {
|
||||
.color_layers => Paint{ .color_layers = p.u.colr_layers },
|
||||
.glyph => Paint{ .glyph = p.u.glyph },
|
||||
.solid => Paint{ .solid = p.u.solid },
|
||||
|
|
@ -263,41 +263,41 @@ pub fn newSize(self: Face) Error!Size {
|
|||
}
|
||||
|
||||
pub fn numFaces(self: Face) u32 {
|
||||
return @intCast(u32, self.handle.*.num_faces);
|
||||
return @as(u32, @intCast(self.handle.*.num_faces));
|
||||
}
|
||||
|
||||
pub fn faceIndex(self: Face) u32 {
|
||||
return @intCast(u32, self.handle.*.face_index);
|
||||
return @as(u32, @intCast(self.handle.*.face_index));
|
||||
}
|
||||
|
||||
pub fn faceFlags(self: Face) FaceFlags {
|
||||
return @bitCast(FaceFlags, self.handle.*.face_flags);
|
||||
return @as(FaceFlags, @bitCast(self.handle.*.face_flags));
|
||||
}
|
||||
|
||||
pub fn styleFlags(self: Face) StyleFlags {
|
||||
return @bitCast(StyleFlags, self.handle.*.style_flags);
|
||||
return @as(StyleFlags, @bitCast(self.handle.*.style_flags));
|
||||
}
|
||||
|
||||
pub fn numGlyphs(self: Face) u32 {
|
||||
return @intCast(u32, self.handle.*.num_glyphs);
|
||||
return @as(u32, @intCast(self.handle.*.num_glyphs));
|
||||
}
|
||||
|
||||
pub fn familyName(self: Face) ?[:0]const u8 {
|
||||
return if (self.handle.*.family_name) |family|
|
||||
std.mem.span(@ptrCast([*:0]const u8, family))
|
||||
std.mem.span(@as([*:0]const u8, @ptrCast(family)))
|
||||
else
|
||||
null;
|
||||
}
|
||||
|
||||
pub fn styleName(self: Face) ?[:0]const u8 {
|
||||
return if (self.handle.*.style_name) |style_name|
|
||||
std.mem.span(@ptrCast([*:0]const u8, style_name))
|
||||
std.mem.span(@as([*:0]const u8, @ptrCast(style_name)))
|
||||
else
|
||||
null;
|
||||
}
|
||||
|
||||
pub fn numFixedSizes(self: Face) u32 {
|
||||
return @intCast(u32, self.handle.*.num_fixed_sizes);
|
||||
return @as(u32, @intCast(self.handle.*.num_fixed_sizes));
|
||||
}
|
||||
|
||||
pub fn availableSizes(self: Face) []BitmapSize {
|
||||
|
|
@ -309,20 +309,20 @@ pub fn availableSizes(self: Face) []BitmapSize {
|
|||
|
||||
pub fn getAdvance(self: Face, glyph_index: u32, load_flags: LoadFlags) Error!i32 {
|
||||
var a: c_long = 0;
|
||||
try intToError(c.FT_Get_Advance(self.handle, glyph_index, @bitCast(i32, load_flags), &a));
|
||||
return @intCast(i32, a);
|
||||
try intToError(c.FT_Get_Advance(self.handle, glyph_index, @as(i32, @bitCast(load_flags)), &a));
|
||||
return @as(i32, @intCast(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(u32, advances_out.len), @bitCast(i32, load_flags), advances_out.ptr));
|
||||
try intToError(c.FT_Get_Advances(self.handle, start, @as(u32, @intCast(advances_out.len)), @as(i32, @bitCast(load_flags)), advances_out.ptr));
|
||||
}
|
||||
|
||||
pub fn numCharmaps(self: Face) u32 {
|
||||
return @intCast(u32, self.handle.*.num_charmaps);
|
||||
return @as(u32, @intCast(self.handle.*.num_charmaps));
|
||||
}
|
||||
|
||||
pub fn charmaps(self: Face) []const CharMap {
|
||||
return @ptrCast([*]const CharMap, self.handle.*.charmaps)[0..self.numCharmaps()];
|
||||
return @as([*]const CharMap, @ptrCast(self.handle.*.charmaps))[0..self.numCharmaps()];
|
||||
}
|
||||
|
||||
pub fn bbox(self: Face) BBox {
|
||||
|
|
|
|||
|
|
@ -45,11 +45,11 @@ pub fn metrics(self: GlyphSlot) GlyphMetrics {
|
|||
}
|
||||
|
||||
pub fn linearHoriAdvance(self: GlyphSlot) i32 {
|
||||
return @intCast(i32, self.handle.*.linearHoriAdvance);
|
||||
return @as(i32, @intCast(self.handle.*.linearHoriAdvance));
|
||||
}
|
||||
|
||||
pub fn linearVertAdvance(self: GlyphSlot) i32 {
|
||||
return @intCast(i32, self.handle.*.linearVertAdvance);
|
||||
return @as(i32, @intCast(self.handle.*.linearVertAdvance));
|
||||
}
|
||||
|
||||
pub fn advance(self: GlyphSlot) Vector {
|
||||
|
|
@ -57,7 +57,7 @@ pub fn advance(self: GlyphSlot) Vector {
|
|||
}
|
||||
|
||||
pub fn format(self: GlyphSlot) GlyphFormat {
|
||||
return @enumFromInt(GlyphFormat, self.handle.*.format);
|
||||
return @as(GlyphFormat, @enumFromInt(self.handle.*.format));
|
||||
}
|
||||
|
||||
pub fn ownBitmap(self: GlyphSlot) Error!void {
|
||||
|
|
@ -81,11 +81,11 @@ pub fn outline(self: GlyphSlot) ?Outline {
|
|||
}
|
||||
|
||||
pub fn lsbDelta(self: GlyphSlot) i32 {
|
||||
return @intCast(i32, self.handle.*.lsb_delta);
|
||||
return @as(i32, @intCast(self.handle.*.lsb_delta));
|
||||
}
|
||||
|
||||
pub fn rsbDelta(self: GlyphSlot) i32 {
|
||||
return @intCast(i32, self.handle.*.rsb_delta);
|
||||
return @as(i32, @intCast(self.handle.*.rsb_delta));
|
||||
}
|
||||
|
||||
pub fn render(self: GlyphSlot, render_mode: RenderMode) Error!void {
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ pub const PaletteData = struct {
|
|||
}
|
||||
|
||||
pub fn paletteFlag(self: PaletteData, index: u32) PaletteFlags {
|
||||
return @bitCast(PaletteFlags, self.handle.palette_flags[index]);
|
||||
return @as(PaletteFlags, @bitCast(self.handle.palette_flags[index]));
|
||||
}
|
||||
|
||||
pub fn numPaletteEntries(self: PaletteData) u16 {
|
||||
|
|
|
|||
|
|
@ -11,27 +11,27 @@ pub const angel_pi2 = _c.FT_ANGLE_PI2;
|
|||
pub const angel_pi4 = _c.FT_ANGLE_PI4;
|
||||
|
||||
pub fn mulDiv(a: i32, b: i32, c: i32) i32 {
|
||||
return @intCast(i32, _c.FT_MulDiv(a, b, c));
|
||||
return @as(i32, @intCast(_c.FT_MulDiv(a, b, c)));
|
||||
}
|
||||
|
||||
pub fn mulFix(a: i32, b: i32) i32 {
|
||||
return @intCast(i32, _c.FT_MulFix(a, b));
|
||||
return @as(i32, @intCast(_c.FT_MulFix(a, b)));
|
||||
}
|
||||
|
||||
pub fn divFix(a: i32, b: i32) i32 {
|
||||
return @intCast(i32, _c.FT_DivFix(a, b));
|
||||
return @as(i32, @intCast(_c.FT_DivFix(a, b)));
|
||||
}
|
||||
|
||||
pub fn roundFix(a: i32) i32 {
|
||||
return @intCast(i32, _c.FT_RoundFix(a));
|
||||
return @as(i32, @intCast(_c.FT_RoundFix(a)));
|
||||
}
|
||||
|
||||
pub fn ceilFix(a: i32) i32 {
|
||||
return @intCast(i32, _c.FT_CeilFix(a));
|
||||
return @as(i32, @intCast(_c.FT_CeilFix(a)));
|
||||
}
|
||||
|
||||
pub fn floorFix(a: i32) i32 {
|
||||
return @intCast(i32, _c.FT_FloorFix(a));
|
||||
return @as(i32, @intCast(_c.FT_FloorFix(a)));
|
||||
}
|
||||
|
||||
pub fn vectorTransform(vec: *Vector, matrix: Matrix) void {
|
||||
|
|
@ -47,7 +47,7 @@ pub fn matrixInvert(m: *Matrix) Error!void {
|
|||
}
|
||||
|
||||
pub fn angleDiff(a: i32, b: i32) i32 {
|
||||
return @intCast(i32, _c.FT_Angle_Diff(a, b));
|
||||
return @as(i32, @intCast(_c.FT_Angle_Diff(a, b)));
|
||||
}
|
||||
|
||||
pub fn vectorUnit(vec: *Vector, angle: i32) void {
|
||||
|
|
@ -59,7 +59,7 @@ pub fn vectorRotate(vec: *Vector, angle: i32) void {
|
|||
}
|
||||
|
||||
pub fn vectorLength(vec: *Vector) i32 {
|
||||
return @intCast(i32, _c.FT_Vector_Length(vec));
|
||||
return @as(i32, @intCast(_c.FT_Vector_Length(vec)));
|
||||
}
|
||||
|
||||
pub fn vectorPolarize(vec: *Vector, length: *c_long, angle: *c_long) void {
|
||||
|
|
|
|||
|
|
@ -167,11 +167,11 @@ pub const OpenArgs = struct {
|
|||
|
||||
pub fn cast(self: OpenArgs) c.FT_Open_Args {
|
||||
var oa: c.FT_Open_Args = undefined;
|
||||
oa.flags = @bitCast(u32, self.flags);
|
||||
oa.flags = @as(u32, @bitCast(self.flags));
|
||||
switch (self.data) {
|
||||
.memory => |d| {
|
||||
oa.memory_base = d.ptr;
|
||||
oa.memory_size = @intCast(u31, d.len);
|
||||
oa.memory_size = @as(u31, @intCast(d.len));
|
||||
},
|
||||
// The Freetype API requires a mutable string.
|
||||
// This is an oversight, Freetype actually never writes to this string.
|
||||
|
|
@ -179,8 +179,8 @@ pub const OpenArgs = struct {
|
|||
.stream => |d| oa.stream = d,
|
||||
.driver => |d| oa.driver = d,
|
||||
.params => |*d| {
|
||||
oa.params = @ptrFromInt(*c.FT_Parameter, @intFromPtr(d.ptr));
|
||||
oa.num_params = @intCast(u31, d.len);
|
||||
oa.params = @as(*c.FT_Parameter, @ptrFromInt(@intFromPtr(d.ptr)));
|
||||
oa.num_params = @as(u31, @intCast(d.len));
|
||||
},
|
||||
}
|
||||
return oa;
|
||||
|
|
@ -189,5 +189,5 @@ pub const OpenArgs = struct {
|
|||
|
||||
pub fn getCharmapIndex(self: [*c]CharMap) ?u32 {
|
||||
const i = c.FT_Get_Charmap_Index(self);
|
||||
return if (i == -1) null else @intCast(u32, i);
|
||||
return if (i == -1) null else @as(u32, @intCast(i));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,24 +54,24 @@ pub const Glyph = struct {
|
|||
|
||||
pub fn toBitmapGlyph(self: *Glyph, render_mode: RenderMode, origin: ?Vector) Error!BitmapGlyph {
|
||||
try intToError(c.FT_Glyph_To_Bitmap(&self.handle, @intFromEnum(render_mode), if (origin) |o| &o else null, 1));
|
||||
return BitmapGlyph{ .handle = @ptrCast(c.FT_BitmapGlyph, self.handle) };
|
||||
return BitmapGlyph{ .handle = @as(c.FT_BitmapGlyph, @ptrCast(self.handle)) };
|
||||
}
|
||||
|
||||
pub fn copyBitmapGlyph(self: *Glyph, render_mode: RenderMode, origin: ?Vector) Error!BitmapGlyph {
|
||||
try intToError(c.FT_Glyph_To_Bitmap(&self.handle, @intFromEnum(render_mode), if (origin) |o| &o else null, 0));
|
||||
return BitmapGlyph{ .handle = @ptrCast(c.FT_BitmapGlyph, self.handle) };
|
||||
return BitmapGlyph{ .handle = @as(c.FT_BitmapGlyph, @ptrCast(self.handle)) };
|
||||
}
|
||||
|
||||
pub fn castBitmapGlyph(self: Glyph) Error!BitmapGlyph {
|
||||
return BitmapGlyph{ .handle = @ptrCast(c.FT_BitmapGlyph, self.handle) };
|
||||
return BitmapGlyph{ .handle = @as(c.FT_BitmapGlyph, @ptrCast(self.handle)) };
|
||||
}
|
||||
|
||||
pub fn castOutlineGlyph(self: Glyph) Error!OutlineGlyph {
|
||||
return OutlineGlyph{ .handle = @ptrCast(c.FT_OutlineGlyph, self.handle) };
|
||||
return OutlineGlyph{ .handle = @as(c.FT_OutlineGlyph, @ptrCast(self.handle)) };
|
||||
}
|
||||
|
||||
pub fn castSvgGlyph(self: Glyph) Error!SvgGlyph {
|
||||
return SvgGlyph{ .handle = @ptrCast(c.FT_SvgGlyph, self.handle) };
|
||||
return SvgGlyph{ .handle = @as(c.FT_SvgGlyph, @ptrCast(self.handle)) };
|
||||
}
|
||||
|
||||
pub fn stroke(self: *Glyph, stroker: Stroker) Error!void {
|
||||
|
|
@ -83,7 +83,7 @@ pub const Glyph = struct {
|
|||
}
|
||||
|
||||
pub fn format(self: Glyph) GlyphFormat {
|
||||
return @enumFromInt(GlyphFormat, self.handle.*.format);
|
||||
return @as(GlyphFormat, @enumFromInt(self.handle.*.format));
|
||||
}
|
||||
|
||||
pub fn advanceX(self: Glyph) isize {
|
||||
|
|
@ -99,7 +99,7 @@ const SvgGlyph = struct {
|
|||
handle: c.FT_SvgGlyph,
|
||||
|
||||
pub fn deinit(self: SvgGlyph) void {
|
||||
c.FT_Done_Glyph(@ptrCast(c.FT_Glyph, self.handle));
|
||||
c.FT_Done_Glyph(@as(c.FT_Glyph, @ptrCast(self.handle)));
|
||||
}
|
||||
|
||||
pub fn svgBuffer(self: SvgGlyph) []const u8 {
|
||||
|
|
@ -143,7 +143,7 @@ pub const BitmapGlyph = struct {
|
|||
handle: c.FT_BitmapGlyph,
|
||||
|
||||
pub fn deinit(self: BitmapGlyph) void {
|
||||
c.FT_Done_Glyph(@ptrCast(c.FT_Glyph, self.handle));
|
||||
c.FT_Done_Glyph(@as(c.FT_Glyph, @ptrCast(self.handle)));
|
||||
}
|
||||
|
||||
pub fn left(self: BitmapGlyph) i32 {
|
||||
|
|
@ -163,7 +163,7 @@ pub const OutlineGlyph = struct {
|
|||
handle: c.FT_OutlineGlyph,
|
||||
|
||||
pub fn deinit(self: OutlineGlyph) void {
|
||||
c.FT_Done_Glyph(@ptrCast(c.FT_Glyph, self.handle));
|
||||
c.FT_Done_Glyph(@as(c.FT_Glyph, @ptrCast(self.handle)));
|
||||
}
|
||||
|
||||
pub fn outline(self: OutlineGlyph) Outline {
|
||||
|
|
|
|||
|
|
@ -13,13 +13,13 @@ pub const Blob = struct {
|
|||
|
||||
pub fn init(data: []u8, mode: MemoryMode) ?Blob {
|
||||
return Blob{
|
||||
.handle = c.hb_blob_create_or_fail(&data[0], @intCast(c_uint, data.len), @intFromEnum(mode), null, null) orelse return null,
|
||||
.handle = c.hb_blob_create_or_fail(&data[0], @as(c_uint, @intCast(data.len)), @intFromEnum(mode), null, null) orelse return null,
|
||||
};
|
||||
}
|
||||
|
||||
pub fn initOrEmpty(data: []u8, mode: MemoryMode) Blob {
|
||||
return .{
|
||||
.handle = c.hb_blob_create(&data[0], @intCast(c_uint, data.len), @intFromEnum(mode), null, null).?,
|
||||
.handle = c.hb_blob_create(&data[0], @as(c_uint, @intCast(data.len)), @intFromEnum(mode), null, null).?,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ pub const GlyphInfo = extern struct {
|
|||
var2: u32,
|
||||
|
||||
pub fn getFlags(self: GlyphInfo) GlyphFlags {
|
||||
return @bitCast(GlyphFlags, hb_glyph_info_get_glyph_flags(&self));
|
||||
return @as(GlyphFlags, @bitCast(hb_glyph_info_get_glyph_flags(&self)));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -56,8 +56,8 @@ pub const SegmentProps = struct {
|
|||
|
||||
pub fn from(c_struct: c.hb_segment_properties_t) SegmentProps {
|
||||
return .{
|
||||
.direction = @enumFromInt(Direction, c_struct.direction),
|
||||
.script = @enumFromInt(Script, c_struct.script),
|
||||
.direction = @as(Direction, @enumFromInt(c_struct.direction)),
|
||||
.script = @as(Script, @enumFromInt(c_struct.script)),
|
||||
.language = Language{ .handle = c_struct.language },
|
||||
};
|
||||
}
|
||||
|
|
@ -173,23 +173,23 @@ pub const Buffer = struct {
|
|||
}
|
||||
|
||||
pub fn addCodepoints(self: Buffer, text: []const u32, item_offset: u32, item_length: ?u31) void {
|
||||
c.hb_buffer_add_codepoints(self.handle, &text[0], @intCast(c_int, text.len), item_offset, if (item_length) |l| l else @intCast(c_int, text.len));
|
||||
c.hb_buffer_add_codepoints(self.handle, &text[0], @as(c_int, @intCast(text.len)), item_offset, if (item_length) |l| l else @as(c_int, @intCast(text.len)));
|
||||
}
|
||||
|
||||
pub fn addUTF32(self: Buffer, text: []const u32, item_offset: u32, item_length: ?u31) void {
|
||||
c.hb_buffer_add_utf32(self.handle, &text[0], @intCast(c_int, text.len), item_offset, if (item_length) |l| l else @intCast(c_int, text.len));
|
||||
c.hb_buffer_add_utf32(self.handle, &text[0], @as(c_int, @intCast(text.len)), item_offset, if (item_length) |l| l else @as(c_int, @intCast(text.len)));
|
||||
}
|
||||
|
||||
pub fn addUTF16(self: Buffer, text: []const u16, item_offset: u32, item_length: ?u31) void {
|
||||
c.hb_buffer_add_utf16(self.handle, &text[0], @intCast(c_int, text.len), item_offset, if (item_length) |l| l else @intCast(c_int, text.len));
|
||||
c.hb_buffer_add_utf16(self.handle, &text[0], @as(c_int, @intCast(text.len)), item_offset, if (item_length) |l| l else @as(c_int, @intCast(text.len)));
|
||||
}
|
||||
|
||||
pub fn addUTF8(self: Buffer, text: []const u8, item_offset: u32, item_length: ?u31) void {
|
||||
c.hb_buffer_add_utf8(self.handle, &text[0], @intCast(c_int, text.len), item_offset, if (item_length) |l| l else @intCast(c_int, text.len));
|
||||
c.hb_buffer_add_utf8(self.handle, &text[0], @as(c_int, @intCast(text.len)), item_offset, if (item_length) |l| l else @as(c_int, @intCast(text.len)));
|
||||
}
|
||||
|
||||
pub fn addLatin1(self: Buffer, text: []const u8, item_offset: u32, item_length: ?u31) void {
|
||||
c.hb_buffer_add_latin1(self.handle, &text[0], @intCast(c_int, text.len), item_offset, if (item_length) |l| l else @intCast(c_int, text.len));
|
||||
c.hb_buffer_add_latin1(self.handle, &text[0], @as(c_int, @intCast(text.len)), item_offset, if (item_length) |l| l else @as(c_int, @intCast(text.len)));
|
||||
}
|
||||
|
||||
pub fn append(self: Buffer, source: Buffer, start: u32, end: u32) void {
|
||||
|
|
@ -197,7 +197,7 @@ pub const Buffer = struct {
|
|||
}
|
||||
|
||||
pub fn getContentType(self: Buffer) ContentType {
|
||||
return @enumFromInt(ContentType, c.hb_buffer_get_content_type(self.handle));
|
||||
return @as(ContentType, @enumFromInt(c.hb_buffer_get_content_type(self.handle)));
|
||||
}
|
||||
|
||||
pub fn setContentType(self: Buffer, content_type: ContentType) void {
|
||||
|
|
@ -205,7 +205,7 @@ pub const Buffer = struct {
|
|||
}
|
||||
|
||||
pub fn getDirection(self: Buffer) Direction {
|
||||
return @enumFromInt(Direction, c.hb_buffer_get_direction(self.handle));
|
||||
return @as(Direction, @enumFromInt(c.hb_buffer_get_direction(self.handle)));
|
||||
}
|
||||
|
||||
pub fn setDirection(self: Buffer, direction: Direction) void {
|
||||
|
|
@ -213,7 +213,7 @@ pub const Buffer = struct {
|
|||
}
|
||||
|
||||
pub fn getScript(self: Buffer) Script {
|
||||
return @enumFromInt(Script, c.hb_buffer_get_script(self.handle));
|
||||
return @as(Script, @enumFromInt(c.hb_buffer_get_script(self.handle)));
|
||||
}
|
||||
|
||||
pub fn setScript(self: Buffer, script: Script) void {
|
||||
|
|
@ -229,15 +229,15 @@ pub const Buffer = struct {
|
|||
}
|
||||
|
||||
pub fn getFlags(self: Buffer) Flags {
|
||||
return @bitCast(Flags, c.hb_buffer_get_flags(self.handle));
|
||||
return @as(Flags, @bitCast(c.hb_buffer_get_flags(self.handle)));
|
||||
}
|
||||
|
||||
pub fn setFlags(self: Buffer, flags: Flags) void {
|
||||
c.hb_buffer_set_flags(self.handle, @bitCast(u32, flags));
|
||||
c.hb_buffer_set_flags(self.handle, @as(u32, @bitCast(flags)));
|
||||
}
|
||||
|
||||
pub fn getClusterLevel(self: Buffer) ClusterLevel {
|
||||
return @enumFromInt(ClusterLevel, c.hb_buffer_get_cluster_level(self.handle));
|
||||
return @as(ClusterLevel, @enumFromInt(c.hb_buffer_get_cluster_level(self.handle)));
|
||||
}
|
||||
|
||||
pub fn setClusterLevel(self: Buffer, level: ClusterLevel) void {
|
||||
|
|
@ -275,7 +275,7 @@ pub const Buffer = struct {
|
|||
pub fn getGlyphPositions(self: Buffer) ?[]Position {
|
||||
var length: u32 = 0;
|
||||
return if (hb_buffer_get_glyph_positions(self.handle, &length)) |positions|
|
||||
@ptrCast([*]Position, positions)[0..length]
|
||||
@as([*]Position, @ptrCast(positions))[0..length]
|
||||
else
|
||||
null;
|
||||
}
|
||||
|
|
@ -325,7 +325,7 @@ pub const Buffer = struct {
|
|||
}
|
||||
|
||||
pub fn diff(self: Buffer, ref: Buffer, dottedcircle_glyph: u32, position_fuzz: u32) DiffFlags {
|
||||
return @bitCast(DiffFlags, c.hb_buffer_diff(self.handle, ref.handle, dottedcircle_glyph, position_fuzz));
|
||||
return @as(DiffFlags, @bitCast(c.hb_buffer_diff(self.handle, ref.handle, dottedcircle_glyph, position_fuzz)));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@ pub const Direction = enum(u3) {
|
|||
bit = c.HB_DIRECTION_BTT,
|
||||
|
||||
pub fn fromString(str: []const u8) Direction {
|
||||
return @enumFromInt(Direction, c.hb_direction_from_string(str.ptr, @intCast(c_int, str.len)));
|
||||
return @as(Direction, @enumFromInt(c.hb_direction_from_string(str.ptr, @as(c_int, @intCast(str.len)))));
|
||||
}
|
||||
|
||||
pub fn toString(self: Direction) [:0]const u8 {
|
||||
return std.mem.span(@ptrCast([*:0]const u8, c.hb_direction_to_string(@intFromEnum(self))));
|
||||
return std.mem.span(@as([*:0]const u8, @ptrCast(c.hb_direction_to_string(@intFromEnum(self)))));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -184,11 +184,11 @@ pub const Script = enum(u31) {
|
|||
invalid = c.HB_SCRIPT_INVALID,
|
||||
|
||||
pub fn fromISO15924Tag(tag: Tag) Script {
|
||||
return @enumFromInt(Script, c.hb_script_from_iso15924_tag(tag.handle));
|
||||
return @as(Script, @enumFromInt(c.hb_script_from_iso15924_tag(tag.handle)));
|
||||
}
|
||||
|
||||
pub fn fromString(str: []const u8) Script {
|
||||
return @enumFromInt(Script, c.hb_script_from_string(str.ptr, @intCast(c_int, str.len)));
|
||||
return @as(Script, @enumFromInt(c.hb_script_from_string(str.ptr, @as(c_int, @intCast(str.len)))));
|
||||
}
|
||||
|
||||
pub fn toISO15924Tag(self: Script) Tag {
|
||||
|
|
@ -196,7 +196,7 @@ pub const Script = enum(u31) {
|
|||
}
|
||||
|
||||
pub fn getHorizontalDirection(self: Script) Direction {
|
||||
return @enumFromInt(Direction, c.hb_script_get_horizontal_direction(@intFromEnum(self)));
|
||||
return @as(Direction, @enumFromInt(c.hb_script_get_horizontal_direction(@intFromEnum(self))));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -205,12 +205,12 @@ pub const Language = struct {
|
|||
|
||||
pub fn fromString(name: []const u8) Language {
|
||||
return .{
|
||||
.handle = c.hb_language_from_string(name.ptr, @intCast(c_int, name.len)),
|
||||
.handle = c.hb_language_from_string(name.ptr, @as(c_int, @intCast(name.len))),
|
||||
};
|
||||
}
|
||||
|
||||
pub fn toString(self: Language) [:0]const u8 {
|
||||
return std.mem.span(@ptrCast([*:0]const u8, c.hb_language_to_string(self.handle)));
|
||||
return std.mem.span(@as([*:0]const u8, @ptrCast(c.hb_language_to_string(self.handle))));
|
||||
}
|
||||
|
||||
pub fn getDefault() Language {
|
||||
|
|
@ -226,14 +226,14 @@ pub const Feature = extern struct {
|
|||
|
||||
pub fn fromString(str: []const u8) ?Feature {
|
||||
var f: Feature = undefined;
|
||||
return if (hb_feature_from_string(str.ptr, @intCast(c_int, str.len), &f) > 1)
|
||||
return if (hb_feature_from_string(str.ptr, @as(c_int, @intCast(str.len)), &f) > 1)
|
||||
f
|
||||
else
|
||||
null;
|
||||
}
|
||||
|
||||
pub fn toString(self: *Feature, buf: []u8) void {
|
||||
hb_feature_to_string(self, buf.ptr, @intCast(c_uint, buf.len));
|
||||
hb_feature_to_string(self, buf.ptr, @as(c_uint, @intCast(buf.len)));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -243,14 +243,14 @@ pub const Variation = extern struct {
|
|||
|
||||
pub fn fromString(str: []const u8) ?Variation {
|
||||
var v: Variation = undefined;
|
||||
return if (hb_variation_from_string(str.ptr, @intCast(c_int, str.len), &v) > 1)
|
||||
return if (hb_variation_from_string(str.ptr, @as(c_int, @intCast(str.len)), &v) > 1)
|
||||
v
|
||||
else
|
||||
null;
|
||||
}
|
||||
|
||||
pub fn toString(self: *Variation, buf: []u8) void {
|
||||
hb_variation_to_string(self, buf.ptr, @intCast(c_uint, buf.len));
|
||||
hb_variation_to_string(self, buf.ptr, @as(c_uint, @intCast(buf.len)));
|
||||
}
|
||||
|
||||
pub fn tag(self: Variation) Tag {
|
||||
|
|
@ -266,7 +266,7 @@ pub const Tag = struct {
|
|||
handle: u32,
|
||||
|
||||
pub fn fromString(str: []const u8) Tag {
|
||||
return .{ .handle = c.hb_tag_from_string(str.ptr, @intCast(c_int, str.len)) };
|
||||
return .{ .handle = c.hb_tag_from_string(str.ptr, @as(c_int, @intCast(str.len))) };
|
||||
}
|
||||
|
||||
pub fn toString(self: Tag) []const u8 {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ pub const Font = struct {
|
|||
}
|
||||
|
||||
pub fn setFreetypeLoadFlags(self: Font, flags: freetype.LoadFlags) void {
|
||||
c.hb_ft_font_set_load_flags(self.handle, @bitCast(i32, flags));
|
||||
c.hb_ft_font_set_load_flags(self.handle, @as(i32, @bitCast(flags)));
|
||||
}
|
||||
|
||||
pub fn getFace(self: Font) Face {
|
||||
|
|
@ -60,7 +60,7 @@ pub const Font = struct {
|
|||
var x: c_uint = 0;
|
||||
var y: c_uint = 0;
|
||||
c.hb_font_get_ppem(self.handle, &x, &y);
|
||||
return @Vector(2, u32){ @intCast(u32, x), @intCast(u32, y) };
|
||||
return @Vector(2, u32){ @as(u32, @intCast(x)), @as(u32, @intCast(y)) };
|
||||
}
|
||||
|
||||
pub fn getPTEM(self: Font) f32 {
|
||||
|
|
@ -71,7 +71,7 @@ pub const Font = struct {
|
|||
var x: c_int = 0;
|
||||
var y: c_int = 0;
|
||||
c.hb_font_get_scale(self.handle, &x, &y);
|
||||
return @Vector(2, i32){ @intCast(i32, x), @intCast(i32, y) };
|
||||
return @Vector(2, i32){ @as(i32, @intCast(x)), @as(i32, @intCast(y)) };
|
||||
}
|
||||
|
||||
pub fn setFace(self: Font, face: Face) void {
|
||||
|
|
@ -83,7 +83,7 @@ pub const Font = struct {
|
|||
self.handle,
|
||||
buf.handle,
|
||||
if (features) |f| f.ptr else null,
|
||||
if (features) |f| @intCast(c_uint, f.len) else 0,
|
||||
if (features) |f| @as(c_uint, @intCast(f.len)) else 0,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ pub const Font = struct {
|
|||
self.handle,
|
||||
buf.handle,
|
||||
if (features) |f| f.ptr else null,
|
||||
if (features) |f| @intCast(c_uint, f.len) else 0,
|
||||
if (features) |f| @as(c_uint, @intCast(f.len)) else 0,
|
||||
shapers,
|
||||
) < 1) return error.ShapingFailed;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ pub const ShapePlan = struct {
|
|||
face.handle,
|
||||
&props.cast(),
|
||||
if (features) |f| f.ptr else null,
|
||||
if (features) |f| @intCast(c_uint, f.len) else 0,
|
||||
if (features) |f| @as(c_uint, @intCast(f.len)) else 0,
|
||||
shapers,
|
||||
).? };
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ pub const ShapePlan = struct {
|
|||
face.handle,
|
||||
&props.cast(),
|
||||
if (features) |f| f.ptr else null,
|
||||
if (features) |f| @intCast(c_uint, f.len) else 0,
|
||||
if (features) |f| @as(c_uint, @intCast(f.len)) else 0,
|
||||
shapers,
|
||||
).? };
|
||||
}
|
||||
|
|
@ -35,9 +35,9 @@ pub const ShapePlan = struct {
|
|||
face.handle,
|
||||
&props.cast(),
|
||||
if (features) |f| f.ptr else null,
|
||||
if (features) |f| @intCast(c_uint, f.len) else 0,
|
||||
if (features) |f| @as(c_uint, @intCast(f.len)) else 0,
|
||||
cords.ptr,
|
||||
@intCast(c_uint, cords.len),
|
||||
@as(c_uint, @intCast(cords.len)),
|
||||
shapers,
|
||||
).? };
|
||||
}
|
||||
|
|
@ -47,9 +47,9 @@ pub const ShapePlan = struct {
|
|||
face.handle,
|
||||
&props.cast(),
|
||||
if (features) |f| f.ptr else null,
|
||||
if (features) |f| @intCast(c_uint, f.len) else 0,
|
||||
if (features) |f| @as(c_uint, @intCast(f.len)) else 0,
|
||||
cords.ptr,
|
||||
@intCast(c_uint, cords.len),
|
||||
@as(c_uint, @intCast(cords.len)),
|
||||
shapers,
|
||||
).? };
|
||||
}
|
||||
|
|
@ -64,12 +64,12 @@ pub const ShapePlan = struct {
|
|||
font.handle,
|
||||
buffer.handle,
|
||||
if (features) |f| f.ptr else null,
|
||||
if (features) |f| @intCast(c_uint, f.len) else 0,
|
||||
if (features) |f| @as(c_uint, @intCast(f.len)) else 0,
|
||||
) < 1) return error.ShapingFailed;
|
||||
}
|
||||
|
||||
pub fn getShaper(self: ShapePlan) [:0]const u8 {
|
||||
return std.mem.span(@ptrCast([*:0]const u8, c.hb_shape_plan_get_shaper(self.handle)));
|
||||
return std.mem.span(@as([*:0]const u8, @ptrCast(c.hb_shape_plan_get_shaper(self.handle))));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ pub const Bitmap = struct {
|
|||
}
|
||||
|
||||
pub fn pixelMode(self: Bitmap) PixelMode {
|
||||
return @enumFromInt(PixelMode, self.handle.pixel_mode);
|
||||
return @as(PixelMode, @enumFromInt(self.handle.pixel_mode));
|
||||
}
|
||||
|
||||
pub fn buffer(self: Bitmap) ?[]const u8 {
|
||||
|
|
@ -122,11 +122,11 @@ pub const Outline = struct {
|
|||
handle: *c.FT_Outline,
|
||||
|
||||
pub fn numPoints(self: Outline) u15 {
|
||||
return @intCast(u15, self.handle.*.n_points);
|
||||
return @as(u15, @intCast(self.handle.*.n_points));
|
||||
}
|
||||
|
||||
pub fn numContours(self: Outline) u15 {
|
||||
return @intCast(u15, self.handle.*.n_contours);
|
||||
return @as(u15, @intCast(self.handle.*.n_contours));
|
||||
}
|
||||
|
||||
pub fn points(self: Outline) []const Vector {
|
||||
|
|
@ -134,7 +134,7 @@ pub const Outline = struct {
|
|||
}
|
||||
|
||||
pub fn tags(self: Outline) []const u8 {
|
||||
return self.handle.tags[0..@intCast(u15, self.handle.n_points)];
|
||||
return self.handle.tags[0..@as(u15, @intCast(self.handle.n_points))];
|
||||
}
|
||||
|
||||
pub fn contours(self: Outline) []const i16 {
|
||||
|
|
@ -142,7 +142,7 @@ pub const Outline = struct {
|
|||
}
|
||||
|
||||
pub fn flags(self: Outline) Flags {
|
||||
return @bitCast(Flags, self.handle.*.flags);
|
||||
return @as(Flags, @bitCast(self.handle.*.flags));
|
||||
}
|
||||
|
||||
pub fn copy(self: Outline) Error!Outline {
|
||||
|
|
@ -188,15 +188,15 @@ pub const Outline = struct {
|
|||
}
|
||||
|
||||
pub fn orientation(self: Outline) Orientation {
|
||||
return @enumFromInt(Orientation, c.FT_Outline_Get_Orientation(self.handle));
|
||||
return @as(Orientation, @enumFromInt(c.FT_Outline_Get_Orientation(self.handle)));
|
||||
}
|
||||
|
||||
pub fn getInsideBorder(self: Outline) Stroker.Border {
|
||||
return @enumFromInt(Stroker.Border, c.FT_Outline_GetInsideBorder(self.handle));
|
||||
return @as(Stroker.Border, @enumFromInt(c.FT_Outline_GetInsideBorder(self.handle)));
|
||||
}
|
||||
|
||||
pub fn getOutsideBorder(self: Outline) Stroker.Border {
|
||||
return @enumFromInt(Stroker.Border, c.FT_Outline_GetOutsideBorder(self.handle));
|
||||
return @as(Stroker.Border, @enumFromInt(c.FT_Outline_GetOutsideBorder(self.handle)));
|
||||
}
|
||||
|
||||
pub fn Funcs(comptime Context: type) type {
|
||||
|
|
@ -217,7 +217,7 @@ pub const Outline = struct {
|
|||
callbacks: Funcs(Context),
|
||||
|
||||
fn getSelf(ptr: ?*anyopaque) *Self {
|
||||
return @ptrCast(*Self, @alignCast(@alignOf(Self), ptr));
|
||||
return @as(*Self, @ptrCast(@alignCast(@alignOf(Self), ptr)));
|
||||
}
|
||||
|
||||
pub fn move_to(to: [*c]const c.FT_Vector, ctx: ?*anyopaque) callconv(.C) c_int {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue