feat: Integrar zcatttf para renderizado TTF
- build.zig.zon: Añadir zcatttf como dependencia local - build.zig: Importar módulo zcatttf en todos los targets - ttf.zig: Reescribir como wrapper de zcatttf (991→561 LOC) Cambios en ttf.zig: - Usa zcatttf.Font para parsing y rasterización - Mantiene API pública compatible (TtfFont, drawText, etc.) - Añade soporte UTF-8 completo en drawText - Elimina código de rasterización propio (buggy) Eliminado: - cmap_debug.zig del build (herramienta de diagnóstico obsoleta) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
7a67a3b1ea
commit
8b90a1b285
3 changed files with 263 additions and 820 deletions
90
build.zig
90
build.zig
|
|
@ -7,6 +7,15 @@ pub fn build(b: *std.Build) void {
|
||||||
// Check if building for WASM
|
// Check if building for WASM
|
||||||
const is_wasm = target.result.cpu.arch == .wasm32 or target.result.cpu.arch == .wasm64;
|
const is_wasm = target.result.cpu.arch == .wasm32 or target.result.cpu.arch == .wasm64;
|
||||||
|
|
||||||
|
// ===========================================
|
||||||
|
// Dependencies
|
||||||
|
// ===========================================
|
||||||
|
const zcatttf_dep = b.dependency("zcatttf", .{
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
});
|
||||||
|
const zcatttf_mod = zcatttf_dep.module("zcatttf");
|
||||||
|
|
||||||
// ===========================================
|
// ===========================================
|
||||||
// Main library module
|
// Main library module
|
||||||
// ===========================================
|
// ===========================================
|
||||||
|
|
@ -15,6 +24,9 @@ pub fn build(b: *std.Build) void {
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
.link_libc = !is_wasm,
|
.link_libc = !is_wasm,
|
||||||
|
.imports = &.{
|
||||||
|
.{ .name = "zcatttf", .module = zcatttf_mod },
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Link SDL2 to the module (only for native builds)
|
// Link SDL2 to the module (only for native builds)
|
||||||
|
|
@ -31,6 +43,9 @@ pub fn build(b: *std.Build) void {
|
||||||
.target = target,
|
.target = target,
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
.link_libc = true,
|
.link_libc = true,
|
||||||
|
.imports = &.{
|
||||||
|
.{ .name = "zcatttf", .module = zcatttf_mod },
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
lib_unit_tests.root_module.linkSystemLibrary("SDL2", .{});
|
lib_unit_tests.root_module.linkSystemLibrary("SDL2", .{});
|
||||||
|
|
@ -127,31 +142,6 @@ pub fn build(b: *std.Build) void {
|
||||||
const table_step = b.step("table-demo", "Run table demo with split panels");
|
const table_step = b.step("table-demo", "Run table demo with split panels");
|
||||||
table_step.dependOn(&run_table.step);
|
table_step.dependOn(&run_table.step);
|
||||||
|
|
||||||
// ===========================================
|
|
||||||
// Debug tools
|
|
||||||
// ===========================================
|
|
||||||
|
|
||||||
// cmap debug - TTF font table diagnostics
|
|
||||||
const cmap_debug_exe = b.addExecutable(.{
|
|
||||||
.name = "cmap-debug",
|
|
||||||
.root_module = b.createModule(.{
|
|
||||||
.root_source_file = b.path("src/render/cmap_debug.zig"),
|
|
||||||
.target = target,
|
|
||||||
.optimize = optimize,
|
|
||||||
.link_libc = true,
|
|
||||||
.imports = &.{
|
|
||||||
.{ .name = "zcatgui", .module = zcatgui_mod },
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
cmap_debug_exe.root_module.linkSystemLibrary("SDL2", .{});
|
|
||||||
b.installArtifact(cmap_debug_exe);
|
|
||||||
|
|
||||||
const run_cmap_debug = b.addRunArtifact(cmap_debug_exe);
|
|
||||||
run_cmap_debug.step.dependOn(b.getInstallStep());
|
|
||||||
const cmap_debug_step = b.step("cmap-debug", "Run TTF cmap diagnostics");
|
|
||||||
cmap_debug_step.dependOn(&run_cmap_debug.step);
|
|
||||||
|
|
||||||
// ===========================================
|
// ===========================================
|
||||||
// WASM Build
|
// WASM Build
|
||||||
// ===========================================
|
// ===========================================
|
||||||
|
|
@ -162,10 +152,20 @@ pub fn build(b: *std.Build) void {
|
||||||
.os_tag = .freestanding,
|
.os_tag = .freestanding,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// zcatttf for WASM
|
||||||
|
const zcatttf_wasm_dep = b.dependency("zcatttf", .{
|
||||||
|
.target = wasm_target,
|
||||||
|
.optimize = .ReleaseSmall,
|
||||||
|
});
|
||||||
|
const zcatttf_wasm_mod = zcatttf_wasm_dep.module("zcatttf");
|
||||||
|
|
||||||
const zcatgui_wasm_mod = b.createModule(.{
|
const zcatgui_wasm_mod = b.createModule(.{
|
||||||
.root_source_file = b.path("src/zcatgui.zig"),
|
.root_source_file = b.path("src/zcatgui.zig"),
|
||||||
.target = wasm_target,
|
.target = wasm_target,
|
||||||
.optimize = .ReleaseSmall,
|
.optimize = .ReleaseSmall,
|
||||||
|
.imports = &.{
|
||||||
|
.{ .name = "zcatttf", .module = zcatttf_wasm_mod },
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// WASM demo executable
|
// WASM demo executable
|
||||||
|
|
@ -205,11 +205,21 @@ pub fn build(b: *std.Build) void {
|
||||||
.abi = .android,
|
.abi = .android,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// zcatttf for Android ARM64
|
||||||
|
const zcatttf_android_dep = b.dependency("zcatttf", .{
|
||||||
|
.target = android_target,
|
||||||
|
.optimize = .ReleaseSafe,
|
||||||
|
});
|
||||||
|
const zcatttf_android_mod = zcatttf_android_dep.module("zcatttf");
|
||||||
|
|
||||||
const zcatgui_android_mod = b.createModule(.{
|
const zcatgui_android_mod = b.createModule(.{
|
||||||
.root_source_file = b.path("src/zcatgui.zig"),
|
.root_source_file = b.path("src/zcatgui.zig"),
|
||||||
.target = android_target,
|
.target = android_target,
|
||||||
.optimize = .ReleaseSafe,
|
.optimize = .ReleaseSafe,
|
||||||
.link_libc = true,
|
.link_libc = true,
|
||||||
|
.imports = &.{
|
||||||
|
.{ .name = "zcatttf", .module = zcatttf_android_mod },
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Android demo shared library
|
// Android demo shared library
|
||||||
|
|
@ -249,11 +259,21 @@ pub fn build(b: *std.Build) void {
|
||||||
.abi = .android,
|
.abi = .android,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// zcatttf for Android x86_64
|
||||||
|
const zcatttf_android_x86_dep = b.dependency("zcatttf", .{
|
||||||
|
.target = android_x86_target,
|
||||||
|
.optimize = .ReleaseSafe,
|
||||||
|
});
|
||||||
|
const zcatttf_android_x86_mod = zcatttf_android_x86_dep.module("zcatttf");
|
||||||
|
|
||||||
const zcatgui_android_x86_mod = b.createModule(.{
|
const zcatgui_android_x86_mod = b.createModule(.{
|
||||||
.root_source_file = b.path("src/zcatgui.zig"),
|
.root_source_file = b.path("src/zcatgui.zig"),
|
||||||
.target = android_x86_target,
|
.target = android_x86_target,
|
||||||
.optimize = .ReleaseSafe,
|
.optimize = .ReleaseSafe,
|
||||||
.link_libc = true,
|
.link_libc = true,
|
||||||
|
.imports = &.{
|
||||||
|
.{ .name = "zcatttf", .module = zcatttf_android_x86_mod },
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const android_demo_x86_mod = b.createModule(.{
|
const android_demo_x86_mod = b.createModule(.{
|
||||||
|
|
@ -293,11 +313,21 @@ pub fn build(b: *std.Build) void {
|
||||||
.os_tag = .ios,
|
.os_tag = .ios,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// zcatttf for iOS
|
||||||
|
const zcatttf_ios_dep = b.dependency("zcatttf", .{
|
||||||
|
.target = ios_target,
|
||||||
|
.optimize = .ReleaseSafe,
|
||||||
|
});
|
||||||
|
const zcatttf_ios_mod = zcatttf_ios_dep.module("zcatttf");
|
||||||
|
|
||||||
const zcatgui_ios_mod = b.createModule(.{
|
const zcatgui_ios_mod = b.createModule(.{
|
||||||
.root_source_file = b.path("src/zcatgui.zig"),
|
.root_source_file = b.path("src/zcatgui.zig"),
|
||||||
.target = ios_target,
|
.target = ios_target,
|
||||||
.optimize = .ReleaseSafe,
|
.optimize = .ReleaseSafe,
|
||||||
.link_libc = true,
|
.link_libc = true,
|
||||||
|
.imports = &.{
|
||||||
|
.{ .name = "zcatttf", .module = zcatttf_ios_mod },
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// iOS static library (object file that can be linked into iOS app)
|
// iOS static library (object file that can be linked into iOS app)
|
||||||
|
|
@ -323,11 +353,21 @@ pub fn build(b: *std.Build) void {
|
||||||
.abi = .simulator,
|
.abi = .simulator,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// zcatttf for iOS Simulator
|
||||||
|
const zcatttf_ios_sim_dep = b.dependency("zcatttf", .{
|
||||||
|
.target = ios_sim_target,
|
||||||
|
.optimize = .ReleaseSafe,
|
||||||
|
});
|
||||||
|
const zcatttf_ios_sim_mod = zcatttf_ios_sim_dep.module("zcatttf");
|
||||||
|
|
||||||
const zcatgui_ios_sim_mod = b.createModule(.{
|
const zcatgui_ios_sim_mod = b.createModule(.{
|
||||||
.root_source_file = b.path("src/zcatgui.zig"),
|
.root_source_file = b.path("src/zcatgui.zig"),
|
||||||
.target = ios_sim_target,
|
.target = ios_sim_target,
|
||||||
.optimize = .ReleaseSafe,
|
.optimize = .ReleaseSafe,
|
||||||
.link_libc = true,
|
.link_libc = true,
|
||||||
|
.imports = &.{
|
||||||
|
.{ .name = "zcatttf", .module = zcatttf_ios_sim_mod },
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const ios_sim_lib = b.addExecutable(.{
|
const ios_sim_lib = b.addExecutable(.{
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,11 @@
|
||||||
.version = "0.1.0",
|
.version = "0.1.0",
|
||||||
.minimum_zig_version = "0.15.0",
|
.minimum_zig_version = "0.15.0",
|
||||||
|
|
||||||
.dependencies = .{},
|
.dependencies = .{
|
||||||
|
.zcatttf = .{
|
||||||
|
.path = "../zcatttf",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
.paths = .{
|
.paths = .{
|
||||||
"build.zig",
|
"build.zig",
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue