Skip to documentation
SLOP

tiny.filigree.fixtures.binary

Reference tiny.filigree fixtures binary

Defined in fixtures.

API (16)

Actions

Public operations.

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

Source

Called byCallsNo direct callsfixtures.binaryassembleCollectionprivate sourcelib.filigree.src.fixture.fontassemblefixtures.binaryalign4
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callersfixtures.binaryappendI16fixtures.binaryappendF2Dot14
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callersfixtures.binaryappendU32fixtures.binaryappendFixed16
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsfixtures.binaryappendF2Dot14private sourcelib.filigree.src.fixture.fontappendCompositeGlyphprivate sourcelib.filigree.src.fixture.fontappendF2Dot14private sourcelib.filigree.src.fixture.fontappendGdefprivate sourcelib.filigree.src.fixture.fontappendGdefItemVariationStore+30 morefixtures.binarywriteI16fixtures.binaryappendI16
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsNo direct callsprivate sourcelib.filigree.src.fixture.fontappendFvarprivate sourcelib.filigree.src.fixture.fontappendMvarprivate sourcelib.filigree.src.fixture.layoutappendLayoutFeatureListFourprivate sourcelib.filigree.src.fixture.layoutappendLayoutFeatureListPairprivate sourcelib.filigree.src.fixture.layoutappendLayoutFeatureListWithLookups+32 morefixtures.binaryappendTag
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsprivate sourcelib.filigree.src.fixture.fontappendAvarprivate sourcelib.filigree.src.fixture.fontappendCffprivate sourcelib.filigree.src.fixture.fontappendCffCharStringsIndexprivate sourcelib.filigree.src.fixture.fontappendCffNameIndexprivate sourcelib.filigree.src.fixture.fontappendCffSingleIndex+72 morefixtures.binarywriteU16fixtures.binaryappendU16
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsNo direct callsprivate sourcelib.filigree.src.fixture.fontappendCmapFormat14VariationSequencesfixtures.binaryappendU24
Static calls · unresolved targets: 1 · external targets: 0.
Called byCallsfixtures.binaryappendFixed16fixtures.binarywriteU32fixtures.binaryappendU32
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsNo direct callersfixtures.binaryalign4private sourcelib.filigree.src.fixture.binarycopyFontAtprivate sourcelib.filigree.src.fixture.binarytagfixtures.binarywriteU32fixtures.binaryassembleCollection
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsNo direct callersprivate sourcelib.filigree.src.fixture.binaryreadU16fixtures.binarytableOffsetfixtures.binaryreplaceLayoutScript
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callersprivate sourcelib.filigree.src.fixture.binaryreadU16fixtures.binarytableOffsetfixtures.binarywriteU16fixtures.binarysetLayoutLookupFlag
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsfixtures.binaryreplaceLayoutScriptfixtures.binarysetLayoutLookupFlagprivate sourcelib.filigree.src.fixture.binaryreadU16private sourcelib.filigree.src.fixture.binaryreadU32private sourcelib.filigree.src.fixture.binarytagfixtures.binarytableOffset
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsfixtures.binaryappendI16fixtures.binarywriteI16
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsfixtures.binaryappendU16fixtures.binarysetLayoutLookupFlagfixtures.binarywriteU16
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsfixtures.binaryappendU32fixtures.binaryassembleCollectionprivate sourcelib.filigree.src.fixture.binarycopyFontAtfixtures.binarywriteU32
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/filigree/src/fixture/binary.zig

zig
const std = @import("std");pub fn appendTag(allocator: std.mem.Allocator, out: *std.ArrayListUnmanaged(u8), comptime value: []const u8) !void {    if (value.len != 4) @compileError("OpenType tags are four bytes");    try out.appendSlice(allocator, value);}pub fn appendU16(allocator: std.mem.Allocator, out: *std.ArrayListUnmanaged(u8), value: u16) !void {    const start = out.items.len;    try out.appendNTimes(allocator, 0, 2);    writeU16(out.items, start, value);}pub fn appendU24(allocator: std.mem.Allocator, out: *std.ArrayListUnmanaged(u8), value: u32) !void {    try out.append(allocator, @intCast((value >> 16) & 0xff));    try out.append(allocator, @intCast((value >> 8) & 0xff));    try out.append(allocator, @intCast(value & 0xff));}pub fn appendI16(allocator: std.mem.Allocator, out: *std.ArrayListUnmanaged(u8), value: i16) !void {    const start = out.items.len;    try out.appendNTimes(allocator, 0, 2);    writeI16(out.items, start, value);}pub fn appendU32(allocator: std.mem.Allocator, out: *std.ArrayListUnmanaged(u8), value: u32) !void {    const start = out.items.len;    try out.appendNTimes(allocator, 0, 4);    writeU32(out.items, start, value);}pub fn appendFixed16(allocator: std.mem.Allocator, out: *std.ArrayListUnmanaged(u8), value: i32) !void {    try appendU32(allocator, out, @intCast(value << 16));}pub fn appendF2Dot14(allocator: std.mem.Allocator, out: *std.ArrayListUnmanaged(u8), value: i16) !void {    try appendI16(allocator, out, value);}pub fn writeU16(bytes: []u8, offset: usize, value: u16) void {    std.mem.writeInt(u16, bytes[offset..][0..2], value, .big);}pub fn writeI16(bytes: []u8, offset: usize, value: i16) void {    std.mem.writeInt(i16, bytes[offset..][0..2], value, .big);}pub fn writeU32(bytes: []u8, offset: usize, value: u32) void {    std.mem.writeInt(u32, bytes[offset..][0..4], value, .big);}pub fn align4(value: usize) usize {    return (value + 3) & ~@as(usize, 3);}pub fn checksum(bytes: []const u8) u32 {    var sum: u32 = 0;    var offset: usize = 0;    while (offset < bytes.len) : (offset += 4) {        var word = [_]u8{ 0, 0, 0, 0 };        const n = @min(4, bytes.len - offset);        @memcpy(word[0..n], bytes[offset..][0..n]);        sum +%= std.mem.readInt(u32, &word, .big);    }    return sum;}pub fn tableOffset(bytes: []const u8, comptime name: []const u8) !usize {    if (bytes.len < 12) return error.InvalidFont;    const wanted = tag(name);    const table_count = try readU16(bytes, 4);    if (@as(usize, table_count) > (bytes.len - 12) / 16) return error.InvalidFont;    for (0..table_count) |i| {        const record = 12 + i * 16;        if (try readU32(bytes, record) != wanted) continue;        const offset = try readU32(bytes, record + 8);        const start: usize = @intCast(offset);        if (start >= bytes.len) return error.InvalidFont;        return start;    }    return error.MissingTable;}pub fn replaceLayoutScript(bytes: []u8, comptime table_name: []const u8, comptime script_name: []const u8) !void {    if (script_name.len != 4) @compileError("OpenType tags are four bytes");    const table_start = try tableOffset(bytes, table_name);    if (table_start > bytes.len or bytes.len - table_start < 12) return error.InvalidFont;    const script_list_relative = try readU16(bytes, table_start + 4);    const script_list_offset = table_start + @as(usize, script_list_relative);    if (script_list_offset > bytes.len or bytes.len - script_list_offset < 8) return error.InvalidFont;    @memcpy(bytes[script_list_offset + 2 ..][0..4], script_name);}pub fn setLayoutLookupFlag(bytes: []u8, comptime table_name: []const u8, lookup_index: u16, lookup_flag: u16) !void {    const table_start = try tableOffset(bytes, table_name);    if (table_start > bytes.len or bytes.len - table_start < 10) return error.InvalidFont;    const lookup_list_relative = try readU16(bytes, table_start + 8);    const lookup_list_offset = table_start + @as(usize, lookup_list_relative);    if (lookup_list_offset > bytes.len or bytes.len - lookup_list_offset < 2) return error.InvalidFont;    const lookup_count = try readU16(bytes, lookup_list_offset);    if (lookup_index >= lookup_count) return error.InvalidFont;    const lookup_record = lookup_list_offset + 2 + @as(usize, lookup_index) * 2;    if (lookup_record > bytes.len or bytes.len - lookup_record < 2) return error.InvalidFont;    const lookup_relative = try readU16(bytes, lookup_record);    const lookup_offset = lookup_list_offset + @as(usize, lookup_relative);    if (lookup_offset > bytes.len or bytes.len - lookup_offset < 4) return error.InvalidFont;    writeU16(bytes, lookup_offset + 2, lookup_flag);}pub fn assembleCollection(allocator: std.mem.Allocator, fonts: []const []const u8) ![]u8 {    if (fonts.len == 0) return error.EmptyCollection;    if (fonts.len > std.math.maxInt(u32)) return error.CollectionTooLarge;    if (fonts.len > (std.math.maxInt(usize) - 12) / 4) return error.CollectionTooLarge;    var total_len = align4(12 + fonts.len * 4);    for (fonts) |font| {        total_len = align4(total_len);        if (font.len > std.math.maxInt(usize) - total_len) return error.CollectionTooLarge;        total_len += font.len;    }    if (total_len > std.math.maxInt(u32)) return error.CollectionTooLarge;    const bytes = try allocator.alloc(u8, total_len);    @memset(bytes, 0);    writeU32(bytes, 0, tag("ttcf"));    writeU32(bytes, 4, 0x00010000);    writeU32(bytes, 8, @intCast(fonts.len));    var offset = align4(12 + fonts.len * 4);    for (fonts, 0..) |font, font_index| {        offset = align4(offset);        if (offset > std.math.maxInt(u32)) return error.CollectionTooLarge;        try copyFontAt(bytes, offset, font);        writeU32(bytes, 12 + font_index * 4, @intCast(offset));        offset += font.len;    }    return bytes;}fn copyFontAt(bytes: []u8, offset: usize, font: []const u8) !void {    if (font.len < 12 or offset > bytes.len or font.len > bytes.len - offset) return error.InvalidCollectionFont;    @memcpy(bytes[offset..][0..font.len], font);    const version = readU32(font, 0) catch return error.InvalidCollectionFont;    if (version != 0x00010000 and version != tag("true") and version != tag("OTTO")) return error.InvalidCollectionFont;    const table_count = readU16(font, 4) catch return error.InvalidCollectionFont;    if (@as(usize, table_count) > (font.len - 12) / 16) return error.InvalidCollectionFont;    for (0..table_count) |table_index| {        const record = 12 + table_index * 16;        const table_offset = readU32(font, record + 8) catch return error.InvalidCollectionFont;        const table_offset_usize: usize = @intCast(table_offset);        if (offset > std.math.maxInt(u32) - table_offset_usize) return error.CollectionTooLarge;        writeU32(bytes, offset + record + 8, @intCast(offset + table_offset_usize));    }}fn readU16(bytes: []const u8, offset: usize) !u16 {    if (offset > bytes.len or bytes.len - offset < 2) return error.EndOfStream;    return std.mem.readInt(u16, bytes[offset..][0..2], .big);}fn readU32(bytes: []const u8, offset: usize) !u32 {    if (offset > bytes.len or bytes.len - offset < 4) return error.EndOfStream;    return std.mem.readInt(u32, bytes[offset..][0..4], .big);}fn tag(comptime name: []const u8) u32 {    if (name.len != 4) @compileError("OpenType tags are four bytes");    return (@as(u32, name[0]) << 24) |        (@as(u32, name[1]) << 16) |        (@as(u32, name[2]) << 8) |        @as(u32, name[3]);}

Source: lib/filigree/src/fixture/root.zig:1

zig
pub const binary = @import("binary.zig");

Complete caller list for fixtures.binary.appendI16

35 direct callers.

Complete caller list for fixtures.binary.appendTag

37 direct callers.

Complete caller list for fixtures.binary.appendU16

77 direct callers.

Audit

Definitions17
Public names17
Members0
Version26.7.0
Revisiondaab053ee433