Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
.minimum_zig_version = "0.15.2",
.dependencies = .{
.TrueType = .{
.url = "git+https://codeberg.org/andrewrk/TrueType#b0f9867671a14ce4ed75a05a7e52c927623095e5",
.hash = "TrueType-0.0.0-Ne-mWMxxAQDit1oHfxlK2lkZAX8P7Wsa2SBPaR_xSpc8",
.url = "git+https://codeberg.org/marler/TrueType#1d2012f9b7af8c6bb224017a459b0124fcf004ed",
.hash = "TrueType-0.0.0-Ne-mWNVzAQBpo-7-locnCb9lfth2lCeCa2WT6Og7Kbzs",
},
// Used by examples
.inter = .{
Expand Down
35 changes: 2 additions & 33 deletions xtt/GlyphSet.zig
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,13 @@ pub fn uploadIfNeeded(

var r8: std.ArrayListUnmanaged(u8) = .empty;
defer r8.deinit(scratch);
const dims = self.ttf.glyphBitmap(
const dims = try self.ttf.glyphBitmap(
scratch,
&r8,
glyph_index,
self.scale,
self.scale,
) catch |err| switch (err) {
error.GlyphNotFound => return self.uploadEmpty(lazy, sink, glyph_index),
else => |e| return e,
};
);

const w: u32 = dims.width;
const h: u32 = dims.height;
Expand Down Expand Up @@ -137,34 +134,6 @@ pub fn uploadIfNeeded(
self.uploaded.set(glyph_index);
}

/// Upload a zero-size glyph so the server knows the ID exists.
fn uploadEmpty(
self: *GlyphSet,
lazy: *xtt.Lazy,
sink: *x11.RequestSink,
glyph_index: TrueType.GlyphIndex,
) error{WriteFailed}!void {
const advance: i16 = @intFromFloat(@round(self.scaled(lazy.hMetrics(self.ttf, glyph_index).advance_width)));
const info: x11.render.GlyphInfo = .{
.width = 0,
.height = 0,
.x = 0,
.y = 0,
.x_off = advance,
.y_off = 0,
};
const pad_len = try x11.render.AddGlyphsStart(
sink,
self.render_ext_opcode,
self.glyphset,
@intFromEnum(glyph_index),
info,
0,
);
try x11.render.AddGlyphsFinish(sink, pad_len);
self.uploaded.set(glyph_index);
}

const std = @import("std");
const x11 = @import("x11");
const TrueType = @import("TrueType");
Expand Down
Loading