tiny.pdf.font
Defined in tiny.pdf.
API (5)
Actions
Public operations.
Types and contracts
Public types and contracts.
Source
Source: lib/pdf/src/font.zig
zig
const std = @import("std");const cmap = @import("cmap.zig");pub const Font = struct { map: ?cmap.Map = null,};pub const Entry = struct { name: []const u8, font: *const Font,};pub const Set = struct { entries: []const Entry = &.{}, pub fn get(self: Set, name: []const u8) ?*const Font { for (self.entries) |entry| { if (std.mem.eql(u8, entry.name, name)) return entry.font; } return null; }};pub fn appendText(current: ?*const Font, allocator: std.mem.Allocator, out: *std.ArrayList(u8), bytes: []const u8) error{OutOfMemory}!void { if (current) |selected| { if (selected.map) |map| return map.appendDecoded(allocator, out, bytes); } out.appendSlice(allocator, bytes) catch return error.OutOfMemory;}test "font set resolves names and unmapped fonts pass bytes through" { const plain = Font{}; const set = Set{ .entries = &.{.{ .name = "F1", .font = &plain }} }; try std.testing.expect(set.get("F1") != null); try std.testing.expect(set.get("F2") == null); var out = std.ArrayList(u8).empty; defer out.deinit(std.testing.allocator); try appendText(set.get("F1"), std.testing.allocator, &out, "raw bytes"); try appendText(null, std.testing.allocator, &out, "!"); try std.testing.expectEqualStrings("raw bytes!", out.items);}Source: lib/pdf/src/root.zig:14
zig
pub const font = @import("font.zig");Audit
| Definitions | 6 |
|---|---|
| Public names | 6 |
| Members | 4 |
| Version | 26.7.0 |
| Revision | daab053ee433 |