Skip to documentation
SLOP

tiny.filigree.Output

Reference tiny.filigree Output

Defined in tiny.filigree.

API (28)

Actions

Public operations.

Types and contracts

Public types and contracts.

Fields and members

Public fields and members.

No direct callersNo direct callstiny.filigreeOutput
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/filigree/src/shape/output.zig:64

zig
pub const Output = struct {    phase: alloc_phase.capacity.Phase,    capacity: Capacity,    bytes: []align(storage_alignment) u8,    glyphs: std.ArrayList(ShapedGlyph),    clusters: std.ArrayList(Cluster),    ligature_carets: std.ArrayList(LigatureCaret),    total_x_advance: i32 = 0,    total_y_advance: i32 = 0,    direction: Direction = .ltr,    writing_mode: WritingMode = .horizontal,    output_order: OutputOrder = .visual,    pub const Limits: type = OutputLimits;    pub const Capacity: type = OutputCapacity;    pub const Exhaustion = error{OutputCapacityExceeded};    pub const InitError = std.mem.Allocator.Error || error{CapacityOverflow};    pub const storage_alignment: usize = @max(        @alignOf(ShapedGlyph),        @alignOf(Cluster),        @alignOf(LigatureCaret),    );    pub const claim: alloc_phase.capacity.Declaration = .{        .source = .{            .id = "filigree.shape_output",            .kind = .phase_static,            .limit_source = .caller,            .storage = .{                .covered = &.{                    .{                        .id = "shaped_glyphs",                        .lifetime = .steady,                        .detail = "glyph positions and source associations",                    },                    .{                        .id = "shaped_clusters",                        .lifetime = .steady,                        .detail = "at most one cluster per glyph slot",                    },                    .{                        .id = "ligature_carets",                        .lifetime = .steady,                        .detail = "caller-budgeted font caret records",                    },                },                .excluded = &.{                    "source text and font bytes",                    "shape context scratch and fallback segmentation",                },            },            .capacity = .{                .inputs = &.{                    alloc_phase.capacity.bindInput(Limits, "max_glyphs", "max_glyphs"),                    alloc_phase.capacity.bindInput(                        Limits,                        "max_ligature_carets",                        "max_ligature_carets",                    ),                },                .type_selectors = &.{                    alloc_phase.capacity.bindType(ShapedGlyph, "shapedglyph"),                    alloc_phase.capacity.bindType(Cluster, "cluster"),                    alloc_phase.capacity.bindType(LigatureCaret, "ligaturecaret"),                },                .nodes = &.{                    .{ .input = 0 },                    .{ .input = 1 },                    .{ .scale = .{                        .node = 0,                        .coefficient = .{ .size_of_concrete_type = 0 },                    } },                    .{ .alignment = .{ .node = 2, .alignment = .{ .concrete_type = 1 } } },                    .{ .scale = .{                        .node = 0,                        .coefficient = .{ .size_of_concrete_type = 1 },                    } },                    .{ .add = .{ .left = 3, .right = 4 } },                    .{ .alignment = .{ .node = 5, .alignment = .{ .concrete_type = 2 } } },                    .{ .scale = .{                        .node = 1,                        .coefficient = .{ .size_of_concrete_type = 2 },                    } },                    .{ .add = .{ .left = 6, .right = 7 } },                },                .assertions = &.{.{                    .scope = .closure_total,                    .measure = .retained,                    .relation = .exact,                    .expression = 8,                }},            },            .overload = .{                .kind = .reject_before_mutation,                .detail = "appends reject before mutation; shape calls clear failed runs",            },            .risks = .{                .transitive = .{                    .status = .witnessed,                    .detail = "operations use the slab without allocator capability",                },                .foreign = .{                    .status = .excluded,                    .detail = "output storage crosses no foreign boundary",                },            },            .obligations = &.{                .{ .key = "filigree_shape_output_capacity", .role = .capacity_model },                .{ .key = "filigree_shape_output_oom", .role = .custom },                .{ .key = "filigree_shape_output_boundaries", .role = .overload },                .{ .key = "filigree_shape_output_sealed", .role = .transitive_risk },                .{ .key = "filigree_shape_output_root", .role = .custom },            },        },        .bindings = .{            .owner = @This(),            .seal = .{                .family = alloc_phase.capacity.selector(@This().activate),                .premise = .{ .class = .checked_semantic_fact, .authority = .checker },            },            .teardown = .{                .family = alloc_phase.capacity.selector(@This().deinit),                .premise = .{ .class = .checked_semantic_fact, .authority = .checker },            },        },    };    /// Acquires and activates exact output storage. Font substitutions can expand    /// glyphs and carets, so callers select both limits independently of source length.    pub fn init(allocator: std.mem.Allocator, limits: Limits) InitError!Output {        const capacity = try Capacity.derive(limits);        const bytes = try allocator.alignedAlloc(            u8,            .fromByteUnits(storage_alignment),            capacity.storage_bytes,        );        var output: Output = .{            .phase = .initialization,            .capacity = capacity,            .bytes = bytes,            .glyphs = .initBuffer(typedSlice(ShapedGlyph, bytes, 0, limits.max_glyphs)),            .clusters = .initBuffer(typedSlice(                Cluster,                bytes,                capacity.cluster_offset,                limits.max_glyphs,            )),            .ligature_carets = .initBuffer(typedSlice(                LigatureCaret,                bytes,                capacity.caret_offset,                limits.max_ligature_carets,            )),        };        output.activate();        return output;    }    pub fn activate(self: *Output) void {        std.debug.assert(self.phase == .initialization);        self.assertStorage();        self.phase = .steady;    }    /// Releases the initialization slab through the same allocator used by init.    pub fn deinit(self: *Output, allocator: std.mem.Allocator) void {        self.assertStorage();        allocator.free(self.bytes);        self.* = undefined;    }    pub fn ensureUnused(        self: *const Output,        glyphs: usize,        clusters: usize,        carets: usize,    ) Exhaustion!void {        std.debug.assert(self.phase == .steady);        std.debug.assert(self.glyphs.items.len <= self.glyphs.capacity);        std.debug.assert(self.clusters.items.len <= self.clusters.capacity);        std.debug.assert(self.ligature_carets.items.len <= self.ligature_carets.capacity);        if (glyphs > self.glyphs.capacity - self.glyphs.items.len or            clusters > self.clusters.capacity - self.clusters.items.len or            carets > self.ligature_carets.capacity - self.ligature_carets.items.len)        {            return error.OutputCapacityExceeded;        }    }    pub fn appendGlyph(self: *Output, glyph: ShapedGlyph) Exhaustion!void {        try self.ensureUnused(1, 0, 0);        self.glyphs.appendAssumeCapacity(glyph);    }    pub fn appendCluster(self: *Output, cluster: Cluster) Exhaustion!void {        try self.ensureUnused(0, 1, 0);        self.clusters.appendAssumeCapacity(cluster);    }    fn assertStorage(self: *const Output) void {        std.debug.assert(self.bytes.len == self.capacity.storage_bytes);        std.debug.assert(self.glyphs.capacity == self.capacity.limits.max_glyphs);        std.debug.assert(self.clusters.capacity == self.capacity.limits.max_glyphs);        std.debug.assert(self.ligature_carets.capacity == self.capacity.limits.max_ligature_carets);        std.debug.assert(self.glyphs.items.len <= self.glyphs.capacity);        std.debug.assert(self.clusters.items.len <= self.clusters.capacity);        std.debug.assert(self.ligature_carets.items.len <= self.ligature_carets.capacity);    }    pub fn clearRetainingCapacity(self: *Output) void {        std.debug.assert(self.phase == .steady);        self.glyphs.clearRetainingCapacity();        self.clusters.clearRetainingCapacity();        self.ligature_carets.clearRetainingCapacity();        self.total_x_advance = 0;        self.total_y_advance = 0;        self.direction = .ltr;        self.writing_mode = .horizontal;        self.output_order = .visual;    }    /// Returns a borrowed glyph run invalidated by mutation, `clearRetainingCapacity`, or deinit.    pub fn run(self: *const Output) GlyphRun {        return .{            .glyphs = self.glyphs.items,            .clusters = self.clusters.items,            .ligature_carets = self.ligature_carets.items,            .total_x_advance = self.total_x_advance,            .total_y_advance = self.total_y_advance,            .direction = self.direction,            .writing_mode = self.writing_mode,            .output_order = self.output_order,        };    }    pub fn glyphCapacity(self: *const Output) usize {        return self.glyphs.capacity;    }    pub fn clusterCapacity(self: *const Output) usize {        return self.clusters.capacity;    }    pub fn ligatureCaretCapacity(self: *const Output) usize {        return self.ligature_carets.capacity;    }};

Source: lib/filigree/src/root.zig:81

zig
pub const Output = shape.Output;
Called byCallsOutputinitprivate sourcelib.filigree.src.shape.output.OutputassertStorageOutputactivate
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallstest sourcelib.filigree.src.shape.outputtest: shaping output cold sealed use ...test sourcelib.filigree.src.shape.outputtest: shaping output rejects exact pl...OutputensureUnusedOutputappendCluster
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallstest sourcelib.filigree.src.shape.outputtest: shaping output cold sealed use ...test sourcelib.filigree.src.shape.outputtest: shaping output rejects exact pl...OutputensureUnusedOutputappendGlyph
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsNo direct callstest sourcelib.filigree.src.shape.outputtest: shaping output cold sealed use ...test sourcelib.filigree.src.shape.outputtest: shaping output rejects exact pl...OutputclearRetainingCapacity
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsNo direct callstest sourcelib.filigree.src.shape.enginetest: shapeRun reuses output capacity...OutputclusterCapacity
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallstest sourcelib.filigree.src.shape.enginetest: Font opens indexed OpenType col...test sourcelib.filigree.src.shape.enginetest: shapeRun applies GPOS ValueReco...test sourcelib.filigree.src.shape.enginetest: shapeRun applies GPOS above and...test sourcelib.filigree.src.shape.enginetest: shapeRun applies GPOS chained c...test sourcelib.filigree.src.shape.enginetest: shapeRun applies GPOS chained c...+107 moreprivate sourcelib.filigree.src.shape.output.OutputassertStorageOutputdeinit
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsNo direct callsOutputappendClusterOutputappendGlyphprivate sourcelib.filigree.src.shape.outputcheckInitFailuretest sourcelib.filigree.src.shape.outputtest: shaping output cold sealed use ...test sourcelib.filigree.src.shape.outputtest: shaping output rejects exact pl...OutputensureUnused
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callstest sourcelib.filigree.src.shape.enginetest: shapeRun reuses output capacity...OutputglyphCapacity
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallstest sourcelib.filigree.src.shape.enginetest: Font opens indexed OpenType col...test sourcelib.filigree.src.shape.enginetest: shapeRun applies GPOS ValueReco...test sourcelib.filigree.src.shape.enginetest: shapeRun applies GPOS above and...test sourcelib.filigree.src.shape.enginetest: shapeRun applies GPOS chained c...test sourcelib.filigree.src.shape.enginetest: shapeRun applies GPOS chained c...+107 moreOutputactivateprivate sourcelib.filigree.src.shape.outputtypedSliceOutputinit
Static calls · unresolved targets: 1 · external targets: 1.
Called byCallsNo direct callstest sourcelib.filigree.src.shape.enginetest: Font opens indexed OpenType col...test sourcelib.filigree.src.shape.enginetest: shapeRun applies GPOS ValueReco...test sourcelib.filigree.src.shape.enginetest: shapeRun applies GPOS above and...test sourcelib.filigree.src.shape.enginetest: shapeRun applies GPOS chained c...test sourcelib.filigree.src.shape.enginetest: shapeRun applies GPOS chained c...+106 moreOutputrun
Static calls · unresolved targets: 0 · external targets: 0.

Also reachable as

shape.Output.

Complete caller list for Output.deinit

112 direct callers.

Complete caller list for Output.init

112 direct callers.

Complete caller list for Output.run

111 direct callers.

Audit

Definitions18
Public names36
Members12
Version26.7.0
Revisiondaab053ee433