mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
pkg/fontconfig: add some error handling
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
const std = @import("std");
|
||||
const c = @import("c.zig");
|
||||
const Error = @import("main.zig").Error;
|
||||
const CharSet = @import("char_set.zig").CharSet;
|
||||
const FontSet = @import("font_set.zig").FontSet;
|
||||
const ObjectSet = @import("object_set.zig").ObjectSet;
|
||||
@ -34,8 +35,11 @@ pub const Config = opaque {
|
||||
return result;
|
||||
}
|
||||
|
||||
pub fn fontRenderPrepare(self: *Config, pat: *Pattern, font: *Pattern) *Pattern {
|
||||
return @ptrCast(*Pattern, c.FcFontRenderPrepare(self.cval(), pat.cval(), font.cval()));
|
||||
pub fn fontRenderPrepare(self: *Config, pat: *Pattern, font: *Pattern) Error!*Pattern {
|
||||
return @ptrCast(
|
||||
?*Pattern,
|
||||
c.FcFontRenderPrepare(self.cval(), pat.cval(), font.cval()),
|
||||
) orelse Error.FontconfigFailed;
|
||||
}
|
||||
|
||||
pub fn substituteWithPat(self: *Config, pat: *Pattern, kind: MatchKind) bool {
|
||||
|
3
pkg/fontconfig/error.zig
Normal file
3
pkg/fontconfig/error.zig
Normal file
@ -0,0 +1,3 @@
|
||||
pub const Error = error{
|
||||
FontconfigFailed,
|
||||
};
|
@ -3,6 +3,7 @@ pub usingnamespace @import("init.zig");
|
||||
pub usingnamespace @import("char_set.zig");
|
||||
pub usingnamespace @import("common.zig");
|
||||
pub usingnamespace @import("config.zig");
|
||||
pub usingnamespace @import("error.zig");
|
||||
pub usingnamespace @import("font_set.zig");
|
||||
pub usingnamespace @import("lang_set.zig");
|
||||
pub usingnamespace @import("matrix.zig");
|
||||
|
@ -43,7 +43,7 @@ test "fc-match" {
|
||||
const fonts = result.fs.fonts();
|
||||
try testing.expect(fonts.len > 0);
|
||||
for (fonts) |font| {
|
||||
var pat_prep = cfg.fontRenderPrepare(pat, font);
|
||||
var pat_prep = try cfg.fontRenderPrepare(pat, font);
|
||||
try testing.expect(fs.add(pat_prep));
|
||||
}
|
||||
result.fs.destroy();
|
||||
|
Reference in New Issue
Block a user