Skip to documentation
SLOP

tiny.filigree.Font

Reference tiny.filigree Font

Defined in tiny.filigree.

API (8)

Actions

Public operations.

Fields and members

Public fields and members.

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

Source

Source: lib/filigree/src/shape/engine.zig:1719

zig
pub const Font = struct {    face: font.Face,    scale_26dot6: i32,    /// Borrows `data[0..len]` for the entire lifetime of the returned font.    /// Returns null when the bytes do not contain a supported face at index zero.    pub fn initFromBytes(data: [*]const u8, len: usize) ?Font {        const slice = data[0..len];        return initFromSliceAt(slice, 0);    }    pub fn initFromBytesAt(data: [*]const u8, len: usize, face_index: u32) ?Font {        return initFromSliceAt(data[0..len], face_index);    }    fn initFromSliceAt(data: []const u8, face_index: u32) ?Font {        const face = font.Face.initAt(data, face_index) catch return null;        return .{            .face = face,            .scale_26dot6 = @as(i32, face.units_per_em) * 64,        };    }    pub fn deinit(self: *Font) void {        self.* = undefined;    }    pub fn setScale(self: *Font, point_size: f64, dpi: u32) void {        self.scale_26dot6 = fontScale26Dot6(point_size, dpi);    }    pub fn setPixelHeightScale(self: *Font, pixel_height: f64) void {        self.scale_26dot6 = pixelHeightScale26Dot6ForMetrics(            pixel_height,            self.face.units_per_em,            self.face.heightUnits(),        );    }    pub fn setPixelHeightScaleForVariations(self: *Font, pixel_height: f64, variations: []const font.VariationSetting) void {        self.scale_26dot6 = pixelHeightScale26Dot6ForMetricUnits(            pixel_height,            self.face.units_per_em,            self.face.heightUnitsForVariations(variations),        );    }    fn scaleDesign(self: *const Font, value: u16) i32 {        const numerator = @as(i64, value) * @as(i64, self.scale_26dot6);        const denominator: i64 = self.face.units_per_em;        const rounded = numerator + @divTrunc(denominator, 2);        const scaled = @divTrunc(rounded, denominator);        if (scaled > std.math.maxInt(i32)) return std.math.maxInt(i32);        if (scaled < std.math.minInt(i32)) return std.math.minInt(i32);        return @intCast(scaled);    }    fn scaleDesignSigned(self: *const Font, value: i32) i32 {        const numerator = @as(i64, value) * @as(i64, self.scale_26dot6);        const denominator: i64 = self.face.units_per_em;        const rounded = if (numerator >= 0)            numerator + @divTrunc(denominator, 2)        else            numerator - @divTrunc(denominator, 2);        const scaled = @divTrunc(rounded, denominator);        if (scaled > std.math.maxInt(i32)) return std.math.maxInt(i32);        if (scaled < std.math.minInt(i32)) return std.math.minInt(i32);        return @intCast(scaled);    }};

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

zig
pub const Font = shape.Font;
Called byCallstest sourcelib.filigree.src.shape.enginetest: Font opens indexed OpenType col...test sourcelib.filigree.src.shape.enginetest: pixel-height scale can use vari...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...+105 moreprivate sourcelib.filigree.src.shape.engine.FontinitFromSliceAtFontinitFromBytes
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallstest sourcelib.filigree.src.shape.enginetest: Font opens indexed OpenType col...private sourcelib.filigree.src.shape.engine.FontinitFromSliceAtFontinitFromBytesAt
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callersprivate sourcelib.filigree.src.shape.enginepixelHeightScale26Dot6ForMetricsFontsetPixelHeightScale
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsNo direct callersprivate sourcelib.filigree.src.shape.enginepixelHeightScale26Dot6ForMetricUnitsFontsetPixelHeightScaleForVariations
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsNo direct callersprivate sourcelib.filigree.src.shape.enginefontScale26Dot6FontsetScale
Static calls · unresolved targets: 0 · external targets: 0.

Also reachable as

shape.Font.

Complete caller list for Font.initFromBytes

110 direct callers.

Audit

Definitions7
Public names14
Members2
Version26.7.0
Revisiondaab053ee433