|
1 | 1 | const std = @import("std"); |
2 | 2 | const metap = @import("meta+"); |
3 | 3 | const Font = @import("font.zig"); |
| 4 | +const vizops = @import("vizops"); |
4 | 5 | const Self = @This(); |
5 | 6 |
|
| 7 | +pub const LoadOptions = struct { |
| 8 | + foregroundColor: vizops.color.Any, |
| 9 | + backgroundColor: vizops.color.Any, |
| 10 | + colorspace: std.meta.DeclEnum(vizops.color.types), |
| 11 | + colorFormat: vizops.color.fourcc.Value, |
| 12 | +}; |
| 13 | + |
6 | 14 | const BaseVTable = struct { |
7 | | - loadBuffer: *const fn (*anyopaque, []const u8) anyerror!*Font, |
| 15 | + loadBuffer: *const fn (*anyopaque, []const u8, LoadOptions) anyerror!*Font, |
8 | 16 | deinit: ?*const fn (*anyopaque) void = null, |
9 | 17 | }; |
10 | 18 |
|
11 | 19 | const FsVTable = struct { |
12 | | - loadFile: ?*const fn (*anyopaque, std.fs.File) anyerror!*Font = null, |
| 20 | + loadFile: ?*const fn (*anyopaque, std.fs.File, LoadOptions) anyerror!*Font = null, |
13 | 21 | }; |
14 | 22 |
|
15 | 23 | pub const VTable = metap.structs.fields.mix(BaseVTable, if (@hasDecl(std.os.system, "fd_t")) FsVTable else struct {}); |
16 | 24 |
|
17 | 25 | ptr: *anyopaque, |
18 | 26 | vtable: *const VTable, |
19 | 27 |
|
20 | | -pub inline fn loadBuffer(self: *Self, buff: []const u8) !*Font { |
21 | | - return self.vtable.loadBuffer(self.ptr, buff); |
| 28 | +pub inline fn loadBuffer(self: *Self, buff: []const u8, options: LoadOptions) !*Font { |
| 29 | + return self.vtable.loadBuffer(self.ptr, buff, options); |
22 | 30 | } |
23 | 31 |
|
24 | | -pub inline fn loadFile(self: *Self, file: std.fs.File) !*Font { |
| 32 | +pub inline fn loadFile(self: *Self, file: std.fs.File, options: LoadOptions) !*Font { |
25 | 33 | if (@hasDecl(std.os.system, "fd_t")) { |
26 | | - if (self.vtable.loadFile) |f| return f(self.ptr, file); |
| 34 | + if (self.vtable.loadFile) |f| return f(self.ptr, file, options); |
27 | 35 | return error.NotImplemented; |
28 | 36 | } |
29 | 37 | return error.NotSupported; |
|
0 commit comments