freetype: drop c package

This commit is contained in:
Ali Chraghi 2022-08-28 20:22:02 +04:30 committed by Stephen Gutekanst
parent 1e0fa20622
commit 16d4e374a9
27 changed files with 6245 additions and 46 deletions

View file

@ -1,11 +1,6 @@
const std = @import("std");
const freetype = @import("freetype");
// Remove once the stage2 compiler fixes pkg std not found
comptime {
_ = @import("utils");
}
const OutlinePrinter = struct {
library: freetype.Library,
face: freetype.Face,

View file

@ -2,11 +2,6 @@
const std = @import("std");
const freetype = @import("freetype");
// Remove once the stage2 compiler fixes pkg std not found
comptime {
_ = @import("utils");
}
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();

View file

@ -1,6 +1,6 @@
const std = @import("std");
const utils = @import("utils");
const c = @import("c");
const c = @import("c.zig");
const intToError = @import("error.zig").intToError;
const Error = @import("error.zig").Error;
const GlyphSlot = @import("freetype.zig").GlyphSlot;

View file

@ -1,4 +1,4 @@
const c = @import("c");
const c = @import("c.zig");
const intToError = @import("error.zig").intToError;
const Error = @import("error.zig").Error;
const Glyph = @import("glyph.zig").Glyph;

View file

@ -1,5 +1,5 @@
const std = @import("std");
const c = @import("c");
const c = @import("c.zig");
const intToError = @import("error.zig").intToError;
const Error = @import("error.zig").Error;
const Face = @import("freetype.zig").Face;

View file

@ -1,6 +1,5 @@
pub usingnamespace if (@import("builtin").zig_backend == .stage1 or !@import("builtin").target.isDarwin())
@cImport({
@cInclude("hb-ft.h");
@cInclude("freetype/ftadvanc.h");
@cInclude("freetype/ftbbox.h");
@cInclude("freetype/ftbitmap.h");

View file

@ -1,5 +1,5 @@
const utils = @import("utils");
const c = @import("c");
const utils = @import("utils.zig");
const c = @import("c.zig");
const Face = @import("freetype.zig").Face;
pub const Color = c.FT_Color;

View file

@ -1,4 +1,4 @@
const _c = @import("c");
const _c = @import("c.zig");
const intToError = @import("error.zig").intToError;
const Error = @import("error.zig").Error;

View file

@ -1,4 +1,4 @@
const c = @import("c");
const c = @import("c.zig");
pub const Error = error{
CannotOpenResource,

View file

@ -1,6 +1,6 @@
const std = @import("std");
const utils = @import("utils");
const c = @import("c");
const utils = @import("utils.zig");
const c = @import("c.zig");
const intToError = @import("error.zig").intToError;
const Error = @import("error.zig").Error;
const Generic = @import("types.zig").Generic;

View file

@ -1,5 +1,5 @@
const std = @import("std");
const c = @import("c");
const c = @import("c.zig");
const intToError = @import("error.zig").intToError;
const Error = @import("error.zig").Error;
const Stroker = @import("stroke.zig").Stroker;

View file

@ -1,5 +1,5 @@
const std = @import("std");
const c = @import("c");
const c = @import("c.zig");
pub const MemoryMode = enum(u2) {
duplicate = c.HB_MEMORY_MODE_DUPLICATE,

View file

@ -1,6 +1,6 @@
const std = @import("std");
const utils = @import("utils");
const c = @import("c");
const c = @import("c.zig");
const Direction = @import("common.zig").Direction;
const Script = @import("common.zig").Script;
const Language = @import("common.zig").Language;

View file

@ -0,0 +1,8 @@
pub usingnamespace if (@import("builtin").zig_backend == .stage1 or !@import("builtin").target.isDarwin())
@cImport(@cInclude("hb-ft.h"))
else
// TODO(self-hosted): HACK: workaround https://github.com/ziglang/zig/issues/12483
//
// Extracted from a build using stage1 from zig-cache/ (`cimport.zig`)
// Then find+replace `= ?fn` -> `= ?*const fn`
@import("cimport1.zig");

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
const std = @import("std");
const c = @import("c");
const c = @import("c.zig");
pub const Direction = enum(u3) {
invalid = c.HB_DIRECTION_INVALID,

View file

@ -1,5 +1,6 @@
const freetype = @import("freetype");
const c = @import("c");
const c = @import("c.zig");
const private = @import("private.zig");
const Blob = @import("blob.zig").Blob;
pub const UnicodeIterator = struct {
@ -22,8 +23,8 @@ pub const Face = struct {
return .{ .handle = c.hb_face_create(blob.handle, index).? };
}
pub fn fromFtFace(face: freetype.Face) Face {
return .{ .handle = c.hb_ft_face_create_referenced(face.handle).? };
pub fn fromFreetypeFace(face: freetype.Face) Face {
return .{ .handle = private.hb_ft_face_create_referenced(face.handle).? };
}
pub fn initEmpty() Face {

View file

@ -1,5 +1,6 @@
const freetype = @import("freetype");
const c = @import("c");
const c = @import("c.zig");
const private = @import("private.zig");
const Face = @import("face.zig").Face;
const Buffer = @import("buffer.zig").Buffer;
const Feature = @import("common.zig").Feature;
@ -12,8 +13,8 @@ pub const Font = struct {
return .{ .handle = c.hb_font_create(face.handle).? };
}
pub fn fromFtFace(face: freetype.Face) Font {
return .{ .handle = c.hb_ft_font_create_referenced(face.handle).? };
pub fn fromFreetypeFace(face: freetype.Face) Font {
return .{ .handle = private.hb_ft_font_create_referenced(face.handle).? };
}
pub fn createSubFont(self: Font) Font {
@ -39,7 +40,7 @@ pub const Font = struct {
}
pub fn getFreetypeFace(self: Font) freetype.Face {
return .{ .handle = c.hb_ft_font_get_face(self.handle) };
return .{ .handle = private.hb_ft_font_get_face(self.handle) };
}
pub fn getGlyph(self: Font, unicode: u32, variation_selector: u32) ?u32 {

View file

@ -12,3 +12,7 @@ const std = @import("std");
comptime {
_ = @import("utils");
}
test {
std.testing.refAllDeclsRecursive(@This());
}

View file

@ -0,0 +1,5 @@
const freetype = @import("freetype");
const c = @import("c.zig");
pub extern fn hb_ft_face_create_referenced(ft_face: freetype.c.FT_Face) ?*c.hb_face_t;
pub extern fn hb_ft_font_create_referenced(ft_face: freetype.c.FT_Face) ?*c.hb_font_t;
pub extern fn hb_ft_font_get_face(font: ?*c.hb_font_t) freetype.c.FT_Face;

View file

@ -1,5 +1,5 @@
const std = @import("std");
const c = @import("c");
const c = @import("c.zig");
pub const ListShapers = struct {
index: usize,

View file

@ -1,5 +1,5 @@
const std = @import("std");
const c = @import("c");
const c = @import("c.zig");
const Buffer = @import("buffer.zig").Buffer;
const Font = @import("font.zig").Font;
const Face = @import("face.zig").Face;

View file

@ -1,6 +1,6 @@
const builtin = @import("builtin");
const std = @import("std");
const c = @import("c");
const c = @import("c.zig");
const utils = @import("utils.zig");
const intToError = @import("error.zig").intToError;
const errorToInt = @import("error.zig").errorToInt;

View file

@ -1,4 +1,4 @@
const c = @import("c");
const c = @import("c.zig");
pub const LcdFilter = enum(u5) {
none = c.FT_LCD_FILTER_NONE,

View file

@ -8,15 +8,14 @@ pub usingnamespace @import("types.zig");
pub usingnamespace @import("computations.zig");
pub usingnamespace @import("error.zig");
pub const harfbuzz = @import("harfbuzz/main.zig");
pub const c = @import("c");
pub const c = @import("c.zig");
const std = @import("std");
const testing = std.testing;
const ft = @import("freetype.zig");
// Remove once the stage2 compiler fixes pkg std not found
comptime {
_ = @import("utils");
fn thisDir() []const u8 {
return std.fs.path.dirname(@src().file) orelse ".";
}
test {
@ -29,16 +28,11 @@ test {
std.testing.refAllDeclsRecursive(@import("stroke.zig"));
std.testing.refAllDeclsRecursive(@import("types.zig"));
std.testing.refAllDeclsRecursive(@import("computations.zig"));
std.testing.refAllDeclsRecursive(harfbuzz);
}
const firasans_font_path = thisDir() ++ "/../upstream/assets/FiraSans-Regular.ttf";
const firasans_font_data = @embedFile(thisDir() ++ "/../upstream/assets/FiraSans-Regular.ttf");
fn thisDir() []const u8 {
return std.fs.path.dirname(@src().file) orelse ".";
}
test "create face from file" {
const lib = try ft.Library.init();
_ = try lib.createFace(firasans_font_path, 0);

View file

@ -1,4 +1,4 @@
const c = @import("c");
const c = @import("c.zig");
const intToError = @import("error.zig").intToError;
const Error = @import("error.zig").Error;
const Outline = @import("image.zig").Outline;

View file

@ -1,4 +1,4 @@
const c = @import("c");
const c = @import("c.zig");
pub const Matrix = c.FT_Matrix;
pub const Generic = c.FT_Generic;