freetype: Use @embedFile()
This commit is contained in:
parent
b4ac18ec57
commit
4107b1d5fe
2 changed files with 3 additions and 8 deletions
|
|
@ -76,11 +76,7 @@ pub fn build(b: *std.build.Builder) !void {
|
||||||
.ft_config_path = "./test/ft",
|
.ft_config_path = "./test/ft",
|
||||||
.brotli = true,
|
.brotli = true,
|
||||||
} });
|
} });
|
||||||
var font_option = b.addOptions();
|
main_tests.main_pkg_path = thisDir();
|
||||||
|
|
||||||
font_option.addOption([]const u8, "font", try std.fs.cwd().readFileAlloc(b.allocator, "upstream/assets/FiraSans-Regular.ttf", std.math.maxInt(u32)));
|
|
||||||
font_option.addOption([]const u8, "file", try std.fs.cwd().readFileAlloc(b.allocator, "upstream/assets/DejaVuSans.pfm", std.math.maxInt(u32)));
|
|
||||||
main_tests.addOptions("test_option", font_option);
|
|
||||||
|
|
||||||
const test_step = b.step("test", "Run library tests");
|
const test_step = b.step("test", "Run library tests");
|
||||||
test_step.dependOn(&freetype_tests.step);
|
test_step.dependOn(&freetype_tests.step);
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
const testing = @import("std").testing;
|
const testing = @import("std").testing;
|
||||||
const freetype = @import("freetype");
|
const freetype = @import("freetype");
|
||||||
|
|
||||||
const test_option = @import("test_option");
|
|
||||||
const firasans_font_path = "upstream/assets/FiraSans-Regular.ttf";
|
const firasans_font_path = "upstream/assets/FiraSans-Regular.ttf";
|
||||||
const firasans_font_data = test_option.font;
|
const firasans_font_data = @embedFile("../upstream/assets/FiraSans-Regular.ttf");
|
||||||
|
|
||||||
// Remove once the stage2 compiler fixes pkg std not found
|
// Remove once the stage2 compiler fixes pkg std not found
|
||||||
comptime {
|
comptime {
|
||||||
|
|
@ -56,7 +55,7 @@ test "attach file" {
|
||||||
test "attach from memory" {
|
test "attach from memory" {
|
||||||
const lib = try freetype.Library.init();
|
const lib = try freetype.Library.init();
|
||||||
const face = try lib.newFace("upstream/assets/DejaVuSans.pfb", 0);
|
const face = try lib.newFace("upstream/assets/DejaVuSans.pfb", 0);
|
||||||
const file = test_option.file;
|
const file = @embedFile("../upstream/assets/DejaVuSans.pfm");
|
||||||
try face.attachMemory(file);
|
try face.attachMemory(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue