Skip to documentation
SLOP

tiny.filigree.describeAtAlloc

Reference tiny.filigree describeAtAlloc

Defined in font.description.

Called byCallsfont.descriptiondescribeAllocfont.binaryreadI16private sourcelib.filigree.src.font.descriptionhasEmojiprivate sourcelib.filigree.src.font.descriptionreadFixedPitchfont.directoryfontDirectoryOffsetfont.directoryoptionalAt+3 morefont.descriptiondescribeAtAlloc
Static calls · unresolved targets: 1 · external targets: 4.

Source

Source: lib/filigree/src/font/description.zig:36

zig
pub fn describeAtAlloc(allocator: std.mem.Allocator, data: []const u8, face_index: u32) (model.FontError || error{OutOfMemory})!Description {    const offset = try directory.fontDirectoryOffset(data, face_index);    const os2 = try directory.tableAt(data, offset, "OS/2");    if (os2.len < 64) return error.InvalidFont;    const head = try directory.tableAt(data, offset, "head");    const hhea = try directory.tableAt(data, offset, "hhea");    if (head.len < 54 or hhea.len < 10) return error.InvalidFont;    const units_per_em = try binary.readU16(data, head.offset + 18);    if (units_per_em == 0) return error.InvalidFont;    const selection = try binary.readU16(data, os2.offset + 62);    const metric_source = if (selection & 0x80 != 0) os2 else hhea;    if (selection & 0x80 != 0 and os2.len < 78) return error.InvalidFont;    const metric_offset: usize = if (selection & 0x80 != 0) 68 else 4;    const scale = @as(f32, @floatFromInt(units_per_em));    const cmap_table = try directory.tableAt(data, offset, "cmap");    const cmap = try cmap_owner.Cmap.init(data, cmap_table);    var coverage: [8]u32 = @splat(0);    inline for (0..4) |word| {        coverage[word] = try binary.readU32(data, os2.offset + 42 + word * 4);    }    if (try hasEmoji(data, cmap)) coverage[extended_emoji_word] |= @as(u32, 1) << extended_emoji_bit;    const post = directory.tableAt(data, offset, "post") catch |err| switch (err) {        error.MissingTable => null,        else => return err,    };    const name_table = try directory.tableAt(data, offset, "name");    const record = (try names.bestNameRecord(data, name_table, 16)) orelse        (try names.bestNameRecord(data, name_table, 1)) orelse return error.InvalidFont;    const family = names.utf16BeToUtf8Alloc(allocator, record.bytes) catch |err| switch (err) {        error.OutOfMemory => return error.OutOfMemory,        else => return error.InvalidFont,    };    errdefer allocator.free(family);    return .{        .family = family,        .weight_class = try binary.readU16(data, os2.offset + 4),        .width_class = try binary.readU16(data, os2.offset + 6),        .selection = selection,        .units_per_em = units_per_em,        .ascent = @as(f32, @floatFromInt(try binary.readI16(data, metric_source.offset + metric_offset))) / scale,        .descent = @as(f32, @floatFromInt(try binary.readI16(data, metric_source.offset + metric_offset + 2))) / scale,        .line_gap = @as(f32, @floatFromInt(try binary.readI16(data, metric_source.offset + metric_offset + 4))) / scale,        .coverage = coverage,        .fixed_pitch = if (post) |table| try readFixedPitch(data, table) else false,        .color = directory.optionalAt(data, offset, "COLR") != null or            directory.optionalAt(data, offset, "CBDT") != null or            directory.optionalAt(data, offset, "sbix") != null or            directory.optionalAt(data, offset, "SVG ") != null,        .face_index = face_index,    };}

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

zig
pub const describeAtAlloc = font.describeAtAlloc;

Also reachable as

font.describeAtAlloc.

Complete call list

8 direct calls.

Audit

Definitions1
Public names3
Members0
Version26.7.0
Revisiondaab053ee433