Phase 1 - Refactoring: - Modular architecture: fonts/, graphics/, objects/, output/ - Fixed Zig 0.15 API changes (ArrayListUnmanaged) - Fixed memory issues in render() Phase 2 - Text System: - cell() with borders, fill, alignment - cellAdvanced() with position control - multiCell() with automatic word wrap - ln() for line breaks - getStringWidth() for text width calculation - Page margins (setMargins, setCellMargin) - Align enum (left, center, right) - Border packed struct New features: - New Pdf API (cleaner than legacy Document) - Document metadata (setTitle, setAuthor, setSubject) - Color: RGB, CMYK, Grayscale support - 52 unit tests passing - New example: text_demo.zig 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
83 lines
2.6 KiB
Zig
83 lines
2.6 KiB
Zig
const std = @import("std");
|
|
|
|
pub fn build(b: *std.Build) void {
|
|
const target = b.standardTargetOptions(.{});
|
|
const optimize = b.standardOptimizeOption(.{});
|
|
|
|
// zpdf module
|
|
const zpdf_mod = b.createModule(.{
|
|
.root_source_file = b.path("src/root.zig"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
});
|
|
|
|
// Tests
|
|
const unit_tests = b.addTest(.{
|
|
.root_module = b.createModule(.{
|
|
.root_source_file = b.path("src/root.zig"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
}),
|
|
});
|
|
|
|
const run_unit_tests = b.addRunArtifact(unit_tests);
|
|
const test_step = b.step("test", "Run unit tests");
|
|
test_step.dependOn(&run_unit_tests.step);
|
|
|
|
// Example: hello
|
|
const hello_exe = b.addExecutable(.{
|
|
.name = "hello",
|
|
.root_module = b.createModule(.{
|
|
.root_source_file = b.path("examples/hello.zig"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.imports = &.{
|
|
.{ .name = "zpdf", .module = zpdf_mod },
|
|
},
|
|
}),
|
|
});
|
|
b.installArtifact(hello_exe);
|
|
|
|
const run_hello = b.addRunArtifact(hello_exe);
|
|
run_hello.step.dependOn(b.getInstallStep());
|
|
const hello_step = b.step("hello", "Run hello example");
|
|
hello_step.dependOn(&run_hello.step);
|
|
|
|
// Example: invoice
|
|
const invoice_exe = b.addExecutable(.{
|
|
.name = "invoice",
|
|
.root_module = b.createModule(.{
|
|
.root_source_file = b.path("examples/invoice.zig"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.imports = &.{
|
|
.{ .name = "zpdf", .module = zpdf_mod },
|
|
},
|
|
}),
|
|
});
|
|
b.installArtifact(invoice_exe);
|
|
|
|
const run_invoice = b.addRunArtifact(invoice_exe);
|
|
run_invoice.step.dependOn(b.getInstallStep());
|
|
const invoice_step = b.step("invoice", "Run invoice example");
|
|
invoice_step.dependOn(&run_invoice.step);
|
|
|
|
// Example: text_demo
|
|
const text_demo_exe = b.addExecutable(.{
|
|
.name = "text_demo",
|
|
.root_module = b.createModule(.{
|
|
.root_source_file = b.path("examples/text_demo.zig"),
|
|
.target = target,
|
|
.optimize = optimize,
|
|
.imports = &.{
|
|
.{ .name = "zpdf", .module = zpdf_mod },
|
|
},
|
|
}),
|
|
});
|
|
b.installArtifact(text_demo_exe);
|
|
|
|
const run_text_demo = b.addRunArtifact(text_demo_exe);
|
|
run_text_demo.step.dependOn(b.getInstallStep());
|
|
const text_demo_step = b.step("text_demo", "Run text demo example");
|
|
text_demo_step.dependOn(&run_text_demo.step);
|
|
}
|