commit 38a17667ac14bdf375b202a52d116fc5460a087b
parent e3c3a1efe53ca7bde4c21a2763bd03eeaac71cc2
Author: Andrea Feletto <andrea@andreafeletto.com>
Date: Sun, 6 Feb 2022 01:16:19 +0100
update fcft to 3.0.1
Diffstat:
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/src/main.zig b/src/main.zig
@@ -1,5 +1,7 @@
const std = @import("std");
+const fcft = @import("fcft");
+
const Config = @import("config.zig").Config;
const Loop = @import("event.zig").Loop;
const modules = @import("modules.zig");
@@ -20,6 +22,8 @@ pub fn main() anyerror!void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
+ fcft.init(.auto, false, .info);
+
std.log.info("initialization", .{});
var state: State = undefined;
state.allocator = arena.allocator();
diff --git a/src/render.zig b/src/render.zig
@@ -86,7 +86,7 @@ pub fn renderClock(surface: *Surface) !void {
const utf8 = try std.unicode.Utf8View.init(str);
var utf8_iter = utf8.iterator();
- var runes = try state.allocator.alloc(c_int, str.len);
+ var runes = try state.allocator.alloc(u32, str.len);
defer state.allocator.free(runes);
var i: usize = 0;
@@ -95,7 +95,11 @@ pub fn renderClock(surface: *Surface) !void {
}
runes = state.allocator.resize(runes, i).?;
- const run = try fcft.TextRun.rasterize(state.config.font, runes, .default);
+ const run = try fcft.TextRun.rasterizeUtf32(
+ state.config.font,
+ runes,
+ .default,
+ );
defer run.destroy();
i = 0;
@@ -147,7 +151,7 @@ pub fn renderModules(surface: *Surface) !void {
const utf8 = try std.unicode.Utf8View.init(string.items);
var utf8_iter = utf8.iterator();
- var runes = try state.allocator.alloc(c_int, string.items.len);
+ var runes = try state.allocator.alloc(u32, string.items.len);
defer state.allocator.free(runes);
var i: usize = 0;
@@ -164,7 +168,11 @@ pub fn renderModules(surface: *Surface) !void {
_ = pixman.Image.fillRectangles(.src, buffer.pix.?, &bg_color, 1, &bg_area);
// compute offsets
- const run = try fcft.TextRun.rasterize(state.config.font, runes, .default);
+ const run = try fcft.TextRun.rasterizeUtf32(
+ state.config.font,
+ runes,
+ .default,
+ );
defer run.destroy();
i = 0;
@@ -233,7 +241,7 @@ fn renderTag(
};
const font = state.config.font;
var char = pixman.Image.createSolidFill(glyph_color).?;
- const glyph = try fcft.Glyph.rasterize(font, tag.label, .default);
+ const glyph = try fcft.Glyph.rasterizeUtf32(font, tag.label, .default);
const x = offset + @divFloor(size - glyph.width, 2);
const y = @divFloor(size - glyph.height, 2);
pixman.Image.composite32(.over, char, glyph.pix, pix, 0, 0, 0, 0, x, y, glyph.width, glyph.height);