fontconfig: charset and langset apis

This commit is contained in:
Mitchell Hashimoto
2022-09-16 15:12:02 -07:00
parent d69f8397f3
commit 0d80225977
2 changed files with 16 additions and 0 deletions

View File

@ -11,6 +11,10 @@ pub const CharSet = opaque {
c.FcCharSetDestroy(self.cval());
}
pub fn hasChar(self: *CharSet, cp: u32) bool {
return c.FcCharSetHasChar(self.cval(), cp) == c.FcTrue;
}
pub inline fn cval(self: *CharSet) *c.struct__FcCharSet {
return @ptrCast(
*c.struct__FcCharSet,
@ -20,6 +24,10 @@ pub const CharSet = opaque {
};
test "create" {
const testing = std.testing;
var fs = CharSet.create();
defer fs.destroy();
try testing.expect(!fs.hasChar(0x20));
}

View File

@ -11,6 +11,10 @@ pub const LangSet = opaque {
c.FcLangSetDestroy(self.cval());
}
pub fn hasLang(self: *LangSet, lang: [:0]const u8) bool {
return c.FcLangSetHasLang(self.cval(), lang.ptr) == c.FcTrue;
}
pub inline fn cval(self: *LangSet) *c.struct__FcLangSet {
return @ptrCast(
*c.struct__FcLangSet,
@ -20,6 +24,10 @@ pub const LangSet = opaque {
};
test "create" {
const testing = std.testing;
var fs = LangSet.create();
defer fs.destroy();
try testing.expect(!fs.hasLang("und-zsye"));
}