freetype: fix tests for stage2 and Face.getGlyphName()

This commit is contained in:
PiergiorgioZagaria 2022-07-18 10:15:48 +02:00 committed by Stephen Gutekanst
parent 6a5bb2566e
commit 2f1a9f4364
3 changed files with 12 additions and 6 deletions

View file

@ -137,10 +137,8 @@ pub fn getTrackKerning(self: Face, point_size: i32, degree: i32) Error!i32 {
return kerning; return kerning;
} }
pub fn getGlyphName(self: Face, index: u32) Error![]const u8 { pub fn getGlyphName(self: Face, index: u32, buf: []u8) Error!void {
var buf: [32]u8 = undefined; 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, buf.len));
return std.mem.sliceTo(&buf, 0);
} }
pub fn getPostscriptName(self: Face) ?[:0]const u8 { pub fn getPostscriptName(self: Face) ?[:0]const u8 {

View file

@ -9,6 +9,11 @@ pub const c = @import("c");
const std = @import("std"); const std = @import("std");
// Remove once the stage2 compiler fixes pkg std not found
comptime {
_ = @import("utils");
}
test { test {
std.testing.refAllDeclsRecursive(@import("blob.zig")); std.testing.refAllDeclsRecursive(@import("blob.zig"));
std.testing.refAllDeclsRecursive(@import("buffer.zig")); std.testing.refAllDeclsRecursive(@import("buffer.zig"));

View file

@ -1,4 +1,5 @@
const testing = @import("std").testing; const std = @import("std");
const testing = std.testing;
const freetype = @import("freetype"); const freetype = @import("freetype");
const firasans_font_path = "upstream/assets/FiraSans-Regular.ttf"; const firasans_font_path = "upstream/assets/FiraSans-Regular.ttf";
@ -79,5 +80,7 @@ test "get name index" {
test "get index name" { test "get index name" {
const lib = try freetype.Library.init(); const lib = try freetype.Library.init();
const face = try lib.newFace(firasans_font_path, 0); const face = try lib.newFace(firasans_font_path, 0);
try testing.expectEqualStrings(try face.getGlyphName(1120), "summation"); var buf: [32]u8 = undefined;
try face.getGlyphName(1120, &buf);
try testing.expectEqualStrings(std.mem.sliceTo(&buf, 0), "summation");
} }