freetype: support compiling with stage2 (-fno-stage1)
This commit is contained in:
parent
d3b03901fb
commit
b4ac18ec57
10 changed files with 61 additions and 29 deletions
|
|
@ -1,17 +1,23 @@
|
|||
const testing = @import("std").testing;
|
||||
const freetype = @import("freetype");
|
||||
|
||||
const firasnas_font_path = "upstream/assets/FiraSans-Regular.ttf";
|
||||
const firasnas_font_data = @embedFile("../upstream/assets/FiraSans-Regular.ttf");
|
||||
const test_option = @import("test_option");
|
||||
const firasans_font_path = "upstream/assets/FiraSans-Regular.ttf";
|
||||
const firasans_font_data = test_option.font;
|
||||
|
||||
// Remove once the stage2 compiler fixes pkg std not found
|
||||
comptime {
|
||||
_ = @import("utils");
|
||||
}
|
||||
|
||||
test "new face from file" {
|
||||
const lib = try freetype.Library.init();
|
||||
_ = try lib.newFace(firasnas_font_path, 0);
|
||||
_ = try lib.newFace(firasans_font_path, 0);
|
||||
}
|
||||
|
||||
test "new face from memory" {
|
||||
const lib = try freetype.Library.init();
|
||||
_ = try lib.newFaceMemory(firasnas_font_data, 0);
|
||||
_ = try lib.newFaceMemory(firasans_font_data, 0);
|
||||
}
|
||||
|
||||
test "new stroker" {
|
||||
|
|
@ -30,7 +36,7 @@ test "set lcd filter" {
|
|||
|
||||
test "load glyph" {
|
||||
const lib = try freetype.Library.init();
|
||||
const face = try lib.newFace(firasnas_font_path, 0);
|
||||
const face = try lib.newFace(firasans_font_path, 0);
|
||||
|
||||
try face.setPixelSizes(100, 100);
|
||||
try face.setCharSize(10 * 10, 0, 72, 0);
|
||||
|
|
@ -50,13 +56,13 @@ test "attach file" {
|
|||
test "attach from memory" {
|
||||
const lib = try freetype.Library.init();
|
||||
const face = try lib.newFace("upstream/assets/DejaVuSans.pfb", 0);
|
||||
const file = @embedFile("../upstream/assets/DejaVuSans.pfm");
|
||||
const file = test_option.file;
|
||||
try face.attachMemory(file);
|
||||
}
|
||||
|
||||
test "charmap iterator" {
|
||||
const lib = try freetype.Library.init();
|
||||
const face = try lib.newFace(firasnas_font_path, 0);
|
||||
const face = try lib.newFace(firasans_font_path, 0);
|
||||
var iterator = face.getCharmapIterator();
|
||||
var old_char: usize = 0;
|
||||
while (iterator.next()) |c| {
|
||||
|
|
@ -67,13 +73,13 @@ test "charmap iterator" {
|
|||
|
||||
test "get name index" {
|
||||
const lib = try freetype.Library.init();
|
||||
const face = try lib.newFace(firasnas_font_path, 0);
|
||||
const face = try lib.newFace(firasans_font_path, 0);
|
||||
try testing.expectEqual(@as(u32, 1120), face.getNameIndex("summation").?);
|
||||
}
|
||||
|
||||
test "get index name" {
|
||||
const lib = try freetype.Library.init();
|
||||
const face = try lib.newFace(firasnas_font_path, 0);
|
||||
const face = try lib.newFace(firasans_font_path, 0);
|
||||
var name_buf: [30]u8 = undefined;
|
||||
try testing.expectEqualStrings("summation", try face.getGlyphName(1120, &name_buf));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue