freetype: drop c package
This commit is contained in:
parent
1e0fa20622
commit
16d4e374a9
27 changed files with 6245 additions and 46 deletions
|
|
@ -1,11 +1,6 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const freetype = @import("freetype");
|
const freetype = @import("freetype");
|
||||||
|
|
||||||
// Remove once the stage2 compiler fixes pkg std not found
|
|
||||||
comptime {
|
|
||||||
_ = @import("utils");
|
|
||||||
}
|
|
||||||
|
|
||||||
const OutlinePrinter = struct {
|
const OutlinePrinter = struct {
|
||||||
library: freetype.Library,
|
library: freetype.Library,
|
||||||
face: freetype.Face,
|
face: freetype.Face,
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,6 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const freetype = @import("freetype");
|
const freetype = @import("freetype");
|
||||||
|
|
||||||
// Remove once the stage2 compiler fixes pkg std not found
|
|
||||||
comptime {
|
|
||||||
_ = @import("utils");
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn main() !void {
|
pub fn main() !void {
|
||||||
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||||
defer _ = gpa.deinit();
|
defer _ = gpa.deinit();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const utils = @import("utils");
|
const utils = @import("utils");
|
||||||
const c = @import("c");
|
const c = @import("c.zig");
|
||||||
const intToError = @import("error.zig").intToError;
|
const intToError = @import("error.zig").intToError;
|
||||||
const Error = @import("error.zig").Error;
|
const Error = @import("error.zig").Error;
|
||||||
const GlyphSlot = @import("freetype.zig").GlyphSlot;
|
const GlyphSlot = @import("freetype.zig").GlyphSlot;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
const c = @import("c");
|
const c = @import("c.zig");
|
||||||
const intToError = @import("error.zig").intToError;
|
const intToError = @import("error.zig").intToError;
|
||||||
const Error = @import("error.zig").Error;
|
const Error = @import("error.zig").Error;
|
||||||
const Glyph = @import("glyph.zig").Glyph;
|
const Glyph = @import("glyph.zig").Glyph;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const c = @import("c");
|
const c = @import("c.zig");
|
||||||
const intToError = @import("error.zig").intToError;
|
const intToError = @import("error.zig").intToError;
|
||||||
const Error = @import("error.zig").Error;
|
const Error = @import("error.zig").Error;
|
||||||
const Face = @import("freetype.zig").Face;
|
const Face = @import("freetype.zig").Face;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
pub usingnamespace if (@import("builtin").zig_backend == .stage1 or !@import("builtin").target.isDarwin())
|
pub usingnamespace if (@import("builtin").zig_backend == .stage1 or !@import("builtin").target.isDarwin())
|
||||||
@cImport({
|
@cImport({
|
||||||
@cInclude("hb-ft.h");
|
|
||||||
@cInclude("freetype/ftadvanc.h");
|
@cInclude("freetype/ftadvanc.h");
|
||||||
@cInclude("freetype/ftbbox.h");
|
@cInclude("freetype/ftbbox.h");
|
||||||
@cInclude("freetype/ftbitmap.h");
|
@cInclude("freetype/ftbitmap.h");
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
const utils = @import("utils");
|
const utils = @import("utils.zig");
|
||||||
const c = @import("c");
|
const c = @import("c.zig");
|
||||||
const Face = @import("freetype.zig").Face;
|
const Face = @import("freetype.zig").Face;
|
||||||
|
|
||||||
pub const Color = c.FT_Color;
|
pub const Color = c.FT_Color;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
const _c = @import("c");
|
const _c = @import("c.zig");
|
||||||
const intToError = @import("error.zig").intToError;
|
const intToError = @import("error.zig").intToError;
|
||||||
const Error = @import("error.zig").Error;
|
const Error = @import("error.zig").Error;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
const c = @import("c");
|
const c = @import("c.zig");
|
||||||
|
|
||||||
pub const Error = error{
|
pub const Error = error{
|
||||||
CannotOpenResource,
|
CannotOpenResource,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const utils = @import("utils");
|
const utils = @import("utils.zig");
|
||||||
const c = @import("c");
|
const c = @import("c.zig");
|
||||||
const intToError = @import("error.zig").intToError;
|
const intToError = @import("error.zig").intToError;
|
||||||
const Error = @import("error.zig").Error;
|
const Error = @import("error.zig").Error;
|
||||||
const Generic = @import("types.zig").Generic;
|
const Generic = @import("types.zig").Generic;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const c = @import("c");
|
const c = @import("c.zig");
|
||||||
const intToError = @import("error.zig").intToError;
|
const intToError = @import("error.zig").intToError;
|
||||||
const Error = @import("error.zig").Error;
|
const Error = @import("error.zig").Error;
|
||||||
const Stroker = @import("stroke.zig").Stroker;
|
const Stroker = @import("stroke.zig").Stroker;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const c = @import("c");
|
const c = @import("c.zig");
|
||||||
|
|
||||||
pub const MemoryMode = enum(u2) {
|
pub const MemoryMode = enum(u2) {
|
||||||
duplicate = c.HB_MEMORY_MODE_DUPLICATE,
|
duplicate = c.HB_MEMORY_MODE_DUPLICATE,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const utils = @import("utils");
|
const utils = @import("utils");
|
||||||
const c = @import("c");
|
const c = @import("c.zig");
|
||||||
const Direction = @import("common.zig").Direction;
|
const Direction = @import("common.zig").Direction;
|
||||||
const Script = @import("common.zig").Script;
|
const Script = @import("common.zig").Script;
|
||||||
const Language = @import("common.zig").Language;
|
const Language = @import("common.zig").Language;
|
||||||
|
|
|
||||||
8
libs/freetype/src/harfbuzz/c.zig
Normal file
8
libs/freetype/src/harfbuzz/c.zig
Normal 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");
|
||||||
6197
libs/freetype/src/harfbuzz/cimport1.zig
Normal file
6197
libs/freetype/src/harfbuzz/cimport1.zig
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1,5 +1,5 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const c = @import("c");
|
const c = @import("c.zig");
|
||||||
|
|
||||||
pub const Direction = enum(u3) {
|
pub const Direction = enum(u3) {
|
||||||
invalid = c.HB_DIRECTION_INVALID,
|
invalid = c.HB_DIRECTION_INVALID,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
const freetype = @import("freetype");
|
const freetype = @import("freetype");
|
||||||
const c = @import("c");
|
const c = @import("c.zig");
|
||||||
|
const private = @import("private.zig");
|
||||||
const Blob = @import("blob.zig").Blob;
|
const Blob = @import("blob.zig").Blob;
|
||||||
|
|
||||||
pub const UnicodeIterator = struct {
|
pub const UnicodeIterator = struct {
|
||||||
|
|
@ -22,8 +23,8 @@ pub const Face = struct {
|
||||||
return .{ .handle = c.hb_face_create(blob.handle, index).? };
|
return .{ .handle = c.hb_face_create(blob.handle, index).? };
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fromFtFace(face: freetype.Face) Face {
|
pub fn fromFreetypeFace(face: freetype.Face) Face {
|
||||||
return .{ .handle = c.hb_ft_face_create_referenced(face.handle).? };
|
return .{ .handle = private.hb_ft_face_create_referenced(face.handle).? };
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn initEmpty() Face {
|
pub fn initEmpty() Face {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
const freetype = @import("freetype");
|
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 Face = @import("face.zig").Face;
|
||||||
const Buffer = @import("buffer.zig").Buffer;
|
const Buffer = @import("buffer.zig").Buffer;
|
||||||
const Feature = @import("common.zig").Feature;
|
const Feature = @import("common.zig").Feature;
|
||||||
|
|
@ -12,8 +13,8 @@ pub const Font = struct {
|
||||||
return .{ .handle = c.hb_font_create(face.handle).? };
|
return .{ .handle = c.hb_font_create(face.handle).? };
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn fromFtFace(face: freetype.Face) Font {
|
pub fn fromFreetypeFace(face: freetype.Face) Font {
|
||||||
return .{ .handle = c.hb_ft_font_create_referenced(face.handle).? };
|
return .{ .handle = private.hb_ft_font_create_referenced(face.handle).? };
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn createSubFont(self: Font) Font {
|
pub fn createSubFont(self: Font) Font {
|
||||||
|
|
@ -39,7 +40,7 @@ pub const Font = struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn getFreetypeFace(self: Font) freetype.Face {
|
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 {
|
pub fn getGlyph(self: Font, unicode: u32, variation_selector: u32) ?u32 {
|
||||||
|
|
|
||||||
|
|
@ -12,3 +12,7 @@ const std = @import("std");
|
||||||
comptime {
|
comptime {
|
||||||
_ = @import("utils");
|
_ = @import("utils");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test {
|
||||||
|
std.testing.refAllDeclsRecursive(@This());
|
||||||
|
}
|
||||||
|
|
|
||||||
5
libs/freetype/src/harfbuzz/private.zig
Normal file
5
libs/freetype/src/harfbuzz/private.zig
Normal 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;
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const c = @import("c");
|
const c = @import("c.zig");
|
||||||
|
|
||||||
pub const ListShapers = struct {
|
pub const ListShapers = struct {
|
||||||
index: usize,
|
index: usize,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const c = @import("c");
|
const c = @import("c.zig");
|
||||||
const Buffer = @import("buffer.zig").Buffer;
|
const Buffer = @import("buffer.zig").Buffer;
|
||||||
const Font = @import("font.zig").Font;
|
const Font = @import("font.zig").Font;
|
||||||
const Face = @import("face.zig").Face;
|
const Face = @import("face.zig").Face;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const c = @import("c");
|
const c = @import("c.zig");
|
||||||
const utils = @import("utils.zig");
|
const utils = @import("utils.zig");
|
||||||
const intToError = @import("error.zig").intToError;
|
const intToError = @import("error.zig").intToError;
|
||||||
const errorToInt = @import("error.zig").errorToInt;
|
const errorToInt = @import("error.zig").errorToInt;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
const c = @import("c");
|
const c = @import("c.zig");
|
||||||
|
|
||||||
pub const LcdFilter = enum(u5) {
|
pub const LcdFilter = enum(u5) {
|
||||||
none = c.FT_LCD_FILTER_NONE,
|
none = c.FT_LCD_FILTER_NONE,
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,14 @@ pub usingnamespace @import("types.zig");
|
||||||
pub usingnamespace @import("computations.zig");
|
pub usingnamespace @import("computations.zig");
|
||||||
pub usingnamespace @import("error.zig");
|
pub usingnamespace @import("error.zig");
|
||||||
pub const harfbuzz = @import("harfbuzz/main.zig");
|
pub const harfbuzz = @import("harfbuzz/main.zig");
|
||||||
pub const c = @import("c");
|
pub const c = @import("c.zig");
|
||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
const ft = @import("freetype.zig");
|
const ft = @import("freetype.zig");
|
||||||
|
|
||||||
// Remove once the stage2 compiler fixes pkg std not found
|
fn thisDir() []const u8 {
|
||||||
comptime {
|
return std.fs.path.dirname(@src().file) orelse ".";
|
||||||
_ = @import("utils");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
|
|
@ -29,16 +28,11 @@ test {
|
||||||
std.testing.refAllDeclsRecursive(@import("stroke.zig"));
|
std.testing.refAllDeclsRecursive(@import("stroke.zig"));
|
||||||
std.testing.refAllDeclsRecursive(@import("types.zig"));
|
std.testing.refAllDeclsRecursive(@import("types.zig"));
|
||||||
std.testing.refAllDeclsRecursive(@import("computations.zig"));
|
std.testing.refAllDeclsRecursive(@import("computations.zig"));
|
||||||
std.testing.refAllDeclsRecursive(harfbuzz);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const firasans_font_path = thisDir() ++ "/../upstream/assets/FiraSans-Regular.ttf";
|
const firasans_font_path = thisDir() ++ "/../upstream/assets/FiraSans-Regular.ttf";
|
||||||
const firasans_font_data = @embedFile(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" {
|
test "create face from file" {
|
||||||
const lib = try ft.Library.init();
|
const lib = try ft.Library.init();
|
||||||
_ = try lib.createFace(firasans_font_path, 0);
|
_ = try lib.createFace(firasans_font_path, 0);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
const c = @import("c");
|
const c = @import("c.zig");
|
||||||
const intToError = @import("error.zig").intToError;
|
const intToError = @import("error.zig").intToError;
|
||||||
const Error = @import("error.zig").Error;
|
const Error = @import("error.zig").Error;
|
||||||
const Outline = @import("image.zig").Outline;
|
const Outline = @import("image.zig").Outline;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
const c = @import("c");
|
const c = @import("c.zig");
|
||||||
|
|
||||||
pub const Matrix = c.FT_Matrix;
|
pub const Matrix = c.FT_Matrix;
|
||||||
pub const Generic = c.FT_Generic;
|
pub const Generic = c.FT_Generic;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue