feat(gui): M3 - TrueType rasterizer with fontconfig font discovery
Replace the M2 stub rasterizer with a real font rasterizer: - build.zig.zon: add TrueType as a lazy path dependency - build.zig: swap stub_rasterizer_mod for truetype_rasterizer_mod; link fontconfig + libc on Linux; TrueType dep is lazy (falls back gracefully) - src/gui/rasterizer/truetype.zig: andrewrk/TrueType rasterizer; loadFont uses fontconfig to locate the font file, derives cell dimensions from vertical metrics (ascent−descent) and 'M' advance width; render blits the A8 glyph bitmap into the caller-provided staging buffer with correct baseline placement (ascent_px + off_y) and double-wide support (+cell_w x-offset for kind=.right); arena allocator per render call - src/gui/rasterizer/font_finder.zig: OS dispatcher (Linux only for now) - src/gui/rasterizer/font_finder/linux.zig: fontconfig C API - FcFontMatch resolves a font name pattern to an absolute file path Requires: libfontconfig-dev (already present alongside libgl-dev etc.) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
39b482b2e0
commit
ae0f62c3bf
5 changed files with 173 additions and 3 deletions
17
build.zig
17
build.zig
|
|
@ -554,18 +554,29 @@ pub fn build_exe(
|
|||
const gui_glyph_cache_mod = b.createModule(.{ .root_source_file = b.path("src/gui/GlyphIndexCache.zig") });
|
||||
const gui_xterm_mod = b.createModule(.{ .root_source_file = b.path("src/gui/xterm.zig") });
|
||||
|
||||
const stub_rasterizer_mod = b.createModule(.{
|
||||
.root_source_file = b.path("src/gui/rasterizer/stub.zig"),
|
||||
const tt_dep = b.lazyDependency("TrueType", .{
|
||||
.target = target,
|
||||
.optimize = optimize_deps,
|
||||
}) orelse break :blk tui_renderer_mod;
|
||||
|
||||
const truetype_rasterizer_mod = b.createModule(.{
|
||||
.root_source_file = b.path("src/gui/rasterizer/truetype.zig"),
|
||||
.target = target,
|
||||
.imports = &.{
|
||||
.{ .name = "TrueType", .module = tt_dep.module("TrueType") },
|
||||
.{ .name = "xy", .module = gui_xy_mod },
|
||||
},
|
||||
});
|
||||
if (target.result.os.tag == .linux) {
|
||||
truetype_rasterizer_mod.linkSystemLibrary("fontconfig", .{});
|
||||
truetype_rasterizer_mod.link_libc = true;
|
||||
}
|
||||
|
||||
const gpu_mod = b.createModule(.{
|
||||
.root_source_file = b.path("src/gui/gpu/gpu.zig"),
|
||||
.imports = &.{
|
||||
.{ .name = "sokol", .module = sokol_mod },
|
||||
.{ .name = "rasterizer", .module = stub_rasterizer_mod },
|
||||
.{ .name = "rasterizer", .module = truetype_rasterizer_mod },
|
||||
.{ .name = "xy", .module = gui_xy_mod },
|
||||
.{ .name = "Cell", .module = gui_cell_mod },
|
||||
.{ .name = "GlyphIndexCache", .module = gui_glyph_cache_mod },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue