skia
    Preparing search index...

    Interface Font

    See SkFont.h for more on this class.

    interface Font {
        _type: "Font";
        delete(): void;
        deleteLater(): void;
        getGlyphBounds(
            glyphs: InputGlyphIDArray,
            paint?: Paint | null,
            output?: Float32Array<ArrayBufferLike>,
        ): Float32Array;
        getGlyphIDs(
            str: string,
            numCodePoints?: number,
            output?: GlyphIDArray,
        ): GlyphIDArray;
        getGlyphIntercepts(
            glyphs: InputGlyphIDArray,
            positions: number[] | Float32Array<ArrayBufferLike>,
            top: number,
            bottom: number,
        ): Float32Array;
        getGlyphPath(glyphID: number): Path;
        getGlyphWidths(
            glyphs: InputGlyphIDArray,
            paint?: Paint | null,
            output?: Float32Array<ArrayBufferLike>,
        ): Float32Array;
        getMetrics(): FontMetrics;
        getScaleX(): number;
        getSize(): number;
        getSkewX(): number;
        getTypeface(): Typeface | null;
        isAliasOf(other: any): boolean;
        isDeleted(): boolean;
        isEmbolden(): boolean;
        setEdging(edging: EmbindEnumEntity): void;
        setEmbeddedBitmaps(embeddedBitmaps: boolean): void;
        setEmbolden(embolden: boolean): void;
        setHinting(hinting: EmbindEnumEntity): void;
        setLinearMetrics(linearMetrics: boolean): void;
        setScaleX(sx: number): void;
        setSize(points: number): void;
        setSkewX(sx: number): void;
        setSubpixel(subpixel: boolean): void;
        setTypeface(face: Typeface | null): void;
    }

    Hierarchy (View Summary)

    Index

    Properties

    _type: "Font"

    Methods

    • Retrieves the bounds for each glyph in glyphs. If paint is not null, its stroking, PathEffect, and MaskFilter fields are respected. These are returned as flattened rectangles. For each glyph, there will be 4 floats for left, top, right, bottom (relative to 0, 0) for that glyph.

      Parameters

      • glyphs: InputGlyphIDArray
      • Optionalpaint: Paint | null
      • Optionaloutput: Float32Array<ArrayBufferLike>

        if provided, the results will be copied into this array.

      Returns Float32Array

    • Retrieves the glyph ids for each code point in the provided string. This call is passed to the typeface of this font. Note that glyph IDs are typeface-dependent; different faces may have different ids for the same code point.

      Parameters

      • str: string
      • OptionalnumCodePoints: number

        the number of code points in the string. Defaults to str.length.

      • Optionaloutput: GlyphIDArray

        if provided, the results will be copied into this array.

      Returns GlyphIDArray

    • Computes any intersections of a thick "line" and a run of positionsed glyphs. The thick line is represented as a top and bottom coordinate (positive for below the baseline, negative for above). If there are no intersections (e.g. if this is intended as an underline, and there are no "collisions") then the returned array will be empty. If there are intersections, the array will contain pairs of X coordinates [start, end] for each segment that intersected with a glyph.

      Parameters

      • glyphs: InputGlyphIDArray

        the glyphs to intersect with

      • positions: number[] | Float32Array<ArrayBufferLike>

        x,y coordinates (2 per glyph) for each glyph

      • top: number

        top of the thick "line" to use for intersection testing

      • bottom: number

        bottom of the thick "line" to use for intersection testing

      Returns Float32Array

      array of [start, end] x-coordinate pairs. Maybe be empty.

    • Returns the outline path for the given glyph ID, or an empty Path if the glyph has no outline (bitmap glyph or invalid ID). Use font.getGlyphIDs(str) to obtain glyph IDs from a string first.

      Parameters

      • glyphID: number

      Returns Path

    • Retrieves the advanceX measurements for each glyph. If paint is not null, its stroking, PathEffect, and MaskFilter fields are respected. One width per glyph is returned in the returned array.

      Parameters

      • glyphs: InputGlyphIDArray
      • Optionalpaint: Paint | null
      • Optionaloutput: Float32Array<ArrayBufferLike>

        if provided, the results will be copied into this array.

      Returns Float32Array

    • Returns text scale on x-axis. Default value is 1.

      Returns number

    • Returns text skew on x-axis. Default value is zero.

      Returns number

    • Returns embolden effect for this font. Default value is false.

      Returns boolean

    • Requests, but does not require, to use bitmaps in fonts instead of outlines.

      Parameters

      • embeddedBitmaps: boolean

      Returns void

    • Set embolden effect for this font.

      Parameters

      • embolden: boolean

      Returns void

    • Requests, but does not require, linearly scalable font and glyph metrics.

      For outline fonts 'true' means font and glyph metrics should ignore hinting and rounding. Note that some bitmap formats may not be able to scale linearly and will ignore this flag.

      Parameters

      • linearMetrics: boolean

      Returns void

    • Sets the text scale on the x-axis.

      Parameters

      • sx: number

      Returns void

    • Sets the text size in points on this font.

      Parameters

      • points: number

      Returns void

    • Sets the text-skew on the x axis for this font.

      Parameters

      • sx: number

      Returns void

    • Requests, but does not require, that glyphs respect sub-pixel positioning.

      Parameters

      • subpixel: boolean

      Returns void

    • Sets the typeface to use with this font. null means to clear the typeface and use the default one.

      Parameters

      Returns void