@@ 1,10 1,10 @@
const pixman = @import("pixman");
-pub const Error = error {
+pub const Error = error{
Generic,
};
-pub const Subpixel = extern enum {
+pub const Subpixel = enum(c_int) {
default,
none,
horizontal_rgb,
@@ 27,20 27,46 @@ pub const Font = extern struct {
subpixel: Subpixel,
- extern fn fcft_from_name(count: usize, names: [*][*:0]const u8, attributes: ?[*:0]u8) ?*Font;
- pub fn fromName(names: [][*:0]const u8, attributes: ?[*:0]u8) !*Font {
+ extern fn fcft_from_name(
+ count: usize,
+ names: [*][*:0]const u8,
+ attributes: ?[*:0]u8,
+ ) ?*Font;
+ pub fn fromName(names: [][*:0]const u8, attributes: ?[*:0]u8) Error!*Font {
const res = fcft_from_name(names.len, names.ptr, attributes);
return if (res) |font| font else error.Generic;
}
extern fn fcft_clone(self: *const Font) ?*Font;
- pub const clone = fcft_clone;
+ pub fn clone(self: *const Font) Error!*Font {
+ const res = fcft_clone(self);
+ return if (res) |font| font else error.Generic;
+ }
extern fn fcft_destroy(self: *Font) void;
pub const destroy = fcft_destroy;
+
+ extern fn fcft_kerning(
+ font: *Font,
+ left: c_int,
+ right: c_int,
+ noalias x: *c_long,
+ noalias y: *c_long,
+ ) bool;
+ pub const kerning = fcft_kerning;
+
+ extern fn fcft_precompose(
+ font: *const Font,
+ base: c_int,
+ comb: c_int,
+ base_is_from_primary: bool,
+ comb_is_from_primary: bool,
+ composed_is_from_primary: bool,
+ ) c_int;
+ pub const precompose = fcft_precompose;
};
-pub const Capabilities = extern enum {
+pub const Capabilities = enum(c_int) {
grapheme_shaping = 0x1,
text_run_shaping = 0x2,
};
@@ 58,8 84,12 @@ pub const Glyph = extern struct {
advance: extern struct { x: c_int, y: c_int },
- extern fn fcft_glyph_rasterize(font: *Font, wc: c_int, subpixel: Subpixel) ?*Glyph;
- pub fn rasterize(font: *Font, wc: c_int, subpixel: Subpixel) !*Glyph {
+ extern fn fcft_glyph_rasterize(
+ font: *Font,
+ wc: c_int,
+ subpixel: Subpixel,
+ ) ?*Glyph;
+ pub fn rasterize(font: *Font, wc: c_int, subpixel: Subpixel) Error!*Glyph {
const res = fcft_glyph_rasterize(font, wc, subpixel);
return if (res) |glyph| glyph else error.Generic;
}
@@ 71,9 101,28 @@ pub const Grapheme = extern struct {
count: usize,
glyphs: [*]const *Glyph,
- extern fn fcft_grapheme_rasterize(font: *Font, len: usize, grapheme_cluster: [*]const c_int, tag_count: usize, tags: [*]const Tag, subpixel: Subpixel) ?*Grapheme;
- pub fn rasterize(font: *Font, grapheme_cluster: []const c_int, tags: []const Tag, subpixel: Subpixel) !*Grapheme {
- const res = fcft_grapheme_rasterize(font, grapheme_cluster.len, grapheme_cluster.ptr, tags.len, tags.ptr, subpixel);
+ extern fn fcft_grapheme_rasterize(
+ font: *Font,
+ len: usize,
+ grapheme_cluster: [*]const c_int,
+ tag_count: usize,
+ tags: [*]const Tag,
+ subpixel: Subpixel,
+ ) ?*Grapheme;
+ pub fn rasterize(
+ font: *Font,
+ grapheme_cluster: []const c_int,
+ tags: []const Tag,
+ subpixel: Subpixel,
+ ) Error!*Grapheme {
+ const res = fcft_grapheme_rasterize(
+ font,
+ grapheme_cluster.len,
+ grapheme_cluster.ptr,
+ tags.len,
+ tags.ptr,
+ subpixel,
+ );
return if (res) |grapheme| grapheme else error.Generic;
}
};
@@ 88,8 137,17 @@ pub const TextRun = extern struct {
cluster: [*]c_int,
count: usize,
- extern fn fcft_text_run_rasterize(font: *Font, len: usize, text: [*]const c_int, subpixel: Subpixel) ?*TextRun;
- pub fn rasterize(font: *Font, text: []const c_int, subpixel: Subpixel) !*TextRun {
+ extern fn fcft_text_run_rasterize(
+ font: *Font,
+ len: usize,
+ text: [*]const c_int,
+ subpixel: Subpixel,
+ ) ?*TextRun;
+ pub fn rasterize(
+ font: *Font,
+ text: []const c_int,
+ subpixel: Subpixel,
+ ) Error!*TextRun {
const res = fcft_text_run_rasterize(font, text.len, text.ptr, subpixel);
return if (res) |run| run else error.Generic;
}
@@ 98,13 156,7 @@ pub const TextRun = extern struct {
pub const destroy = fcft_text_run_destroy;
};
-extern fn fcft_kerning(font: *Font, left: c_int, right: c_int, noalias x: *c_long, noalias y: *c_long) bool;
-pub const kerning = fcft_kerning;
-
-extern fn fcft_precompose(font: *const Font, base: c_int, comb: c_int, base_is_from_primary: bool, comb_is_from_primary: bool, composed_is_from_primary: bool) c_int;
-pub const precompose = fcft_precompose;
-
-pub const ScalingFilter = extern enum {
+pub const ScalingFilter = enum(c_int) {
none,
nearest,
bilinear,
@@ 115,13 167,13 @@ pub const ScalingFilter = extern enum {
extern fn fcft_set_scaling_filter(filter: ScalingFilter) bool;
pub const setScalingFilter = fcft_set_scaling_filter;
-pub const LogColorize = extern enum {
+pub const LogColorize = enum(c_int) {
never,
always,
auto,
};
-pub const LogClass = extern enum {
+pub const LogClass = enum(c_int) {
none,
err,
warning,
@@ 129,5 181,21 @@ pub const LogClass = extern enum {
debug,
};
-extern fn fcft_log_init(colorize: LogColorize, do_syslog: bool, log_level: LogClass) void;
+extern fn fcft_log_init(
+ colorize: LogColorize,
+ do_syslog: bool,
+ log_level: LogClass,
+) void;
pub const logInit = fcft_log_init;
+
+pub const EmojiPresentation = enum(c_int) {
+ default,
+ text,
+ emoji,
+};
+
+extern fn fcft_set_emoji_presentation(
+ font: *Font,
+ presentation: EmojiPresentation,
+) void;
+pub const setEmojiPresentation = fcft_set_emoji_presentation;