Skip to content

Commit

Permalink
Implement upstream changes to hb_glyph_position_t and add testing to …
Browse files Browse the repository at this point in the history
…avoid this in the future.
  • Loading branch information
IntegratedQuantum authored and slimsag committed Aug 23, 2023
1 parent 54fb681 commit de94b3a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/harfbuzz.zig
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ pub const Position = extern struct {
y_advance: i32,
x_offset: i32,
y_offset: i32,
@"var": i32,
};

pub const Blob = struct {
Expand Down Expand Up @@ -990,3 +991,19 @@ test "flags" {
try expect(@as(c_int, @bitCast(Buffer.Flags{ .produce_unsafe_to_concat = true })) == c.HB_BUFFER_FLAG_PRODUCE_UNSAFE_TO_CONCAT);
try expect(@as(c_int, @bitCast(Buffer.Flags{ .produce_safe_to_insert_tatweel = true })) == c.HB_BUFFER_FLAG_PRODUCE_SAFE_TO_INSERT_TATWEEL);
}

fn matchStructs(comptime A: type, comptime B: type) !void {
const fieldsA = std.meta.fields(A);
const fieldsB = std.meta.fields(B);
try expect(fieldsA.len == fieldsB.len);
inline for (fieldsA, fieldsB) |fieldA, fieldB| {
try expect(@sizeOf(fieldA.type) == @sizeOf(fieldB.type));
try expect(@alignOf(fieldA.type) == @alignOf(fieldB.type));
try expect(std.mem.eql(u8, fieldA.name, fieldB.name));
}
}

test "structs" {
try matchStructs(Position, c.hb_glyph_position_t);
try matchStructs(GlyphInfo, c.hb_glyph_info_t);
}

0 comments on commit de94b3a

Please sign in to comment.