tiny.ui.asset.Embedded
Defined in asset.
API (7)
Actions
Public operations.
Capacity.derivedefaultLimitsopen: Returns a ready registry with both embedded faces already registered.register: Registers the two regular faces before a UI session begins publishing.
Types and contracts
Public types and contracts.
Values and defaults
Public values and defaults.
Source
Source: lib/ui/src/asset/embedded.zig:47
zig
pub const Embedded = struct { pub const Limits = struct { font_bytes: usize, descriptor_bytes: usize, family_bytes: usize, }; pub const Capacity = struct { retained_bytes: usize, pub fn derive(limits: Limits) error{CapacityOverflow}!Capacity { const fonts = std.math.add(usize, limits.font_bytes, limits.descriptor_bytes) catch return error.CapacityOverflow; return .{ .retained_bytes = std.math.add(usize, fonts, limits.family_bytes) catch return error.CapacityOverflow }; } }; pub fn defaultLimits() Limits { return .{ .font_bytes = noto_bytes.len + iosevka_bytes.len + faces.len, .descriptor_bytes = @sizeOf(@TypeOf(faces)), .family_bytes = faces[0].family.len + faces[1].family.len + faces.len, }; } pub const claim: alloc_phase.capacity.Declaration = .{ .source = .{ .id = "ui.asset_registry", .kind = .startup_static, .limit_source = .application_default, .storage = .{ .covered = &.{ .{ .id = "embedded_font_bytes", .lifetime = .steady, .detail = "the two pinned TrueType subsets in executable read-only storage" }, .{ .id = "embedded_descriptors", .lifetime = .steady, .detail = "the constant font traits and family names registered before UI readiness" }, }, .excluded = &.{ "caller-owned registry table slots and owned payload pool", "registered system faces" }, }, .capacity = .{ .inputs = &.{ alloc_phase.capacity.bindInput(Limits, "font_bytes", "font_bytes"), alloc_phase.capacity.bindInput(Limits, "descriptor_bytes", "descriptor_bytes"), alloc_phase.capacity.bindInput(Limits, "family_bytes", "family_bytes"), }, .type_selectors = &.{}, .nodes = &.{ .{ .input = 0 }, .{ .input = 1 }, .{ .input = 2 }, .{ .add = .{ .left = 0, .right = 1 } }, .{ .add = .{ .left = 3, .right = 2 } }, }, .assertions = &.{.{ .scope = .closure_total, .measure = .retained, .relation = .upper_bound, .expression = 4, }}, }, .overload = .{ .kind = .not_applicable, .detail = "the two read-only faces have a fixed executable image size" }, .risks = .{ .transitive = .{ .status = .excluded, .detail = "the embedded font bytes and descriptors require no allocator" }, .foreign = .{ .status = .excluded, .detail = "the startup corpus reads no host font service" }, }, .obligations = &.{ .{ .key = "ui_registry_startup", .role = .acquisition }, .{ .key = "ui_registry_descriptors", .role = .integration }, .{ .key = "ui_registry_teardown", .role = .teardown }, }, }, .bindings = .{ .owner = @This(), .default_limits = alloc_phase.capacity.selector(@This().defaultLimits), }, }; /// Registers the two regular faces before a UI session begins publishing. /// A bold request matches the regular face until a bold face is registered. pub fn register(table: *registry.Registry) model.Error![faces.len]model.AssetHandle { std.debug.assert(table.phase == .steady); if (table.limits.fonts - table.font_used < faces.len) return error.FontCapacityExceeded; var handles: [faces.len]model.AssetHandle = undefined; for (faces, 0..) |face, index| { handles[index] = try table.registerFont(face.family, face.descriptor, .{ .borrowed = face.bytes }); } return handles; } /// Returns a ready registry with both embedded faces already registered. pub fn open(allocator: std.mem.Allocator, limits: registry.Registry.Limits) (registry.Registry.InitError || model.Error)!registry.Registry { if (limits.fonts < faces.len) return error.FontCapacityExceeded; var table = try registry.Registry.init(allocator, limits); errdefer table.deinit(allocator); table.activate(); _ = try register(&table); return table; }};Source: lib/ui/src/asset/root.zig:32
zig
pub const Embedded = embedded.Embedded;Audit
| Definitions | 8 |
|---|---|
| Public names | 9 |
| Members | 4 |
| Version | 26.7.0 |
| Revision | daab053ee433 |