Penpot plugins API
    Preparing search index...

    Interface Font

    Represents a font in Penpot, which includes details about the font family, variants, and styling options. This interface provides properties and methods for describing and applying fonts within Penpot.

    interface Font {
        name: string;
        fontId: string;
        fontFamily: string;
        fontStyle?: "normal" | "italic" | null;
        fontVariantId: string;
        fontWeight: string;
        variants: FontVariant[];
        applyToText(text: Text, variant?: FontVariant): void;
        applyToRange(range: TextRange, variant?: FontVariant): void;
    }
    Index

    Properties

    name: string

    This property holds the human-readable name of the font.

    fontId: string

    The unique identifier of the font.

    fontFamily: string

    The font family of the font.

    fontStyle?: "normal" | "italic" | null

    The default font style of the font.

    fontVariantId: string

    The default font variant ID of the font.

    fontWeight: string

    The default font weight of the font.

    variants: FontVariant[]

    An array of font variants available for the font.

    Methods

    • Applies the font styles to a text shape.

      Parameters

      • text: Text

        The text shape to apply the font styles to.

      • Optionalvariant: FontVariant

        Optional. The specific font variant to apply. If not provided, applies the default variant.

      Returns void

      font.applyToText(textShape, fontVariant);
      
    • Applies the font styles to a text range within a text shape.

      Parameters

      • range: TextRange

        The text range to apply the font styles to.

      • Optionalvariant: FontVariant

        Optional. The specific font variant to apply. If not provided, applies the default variant.

      Returns void

      font.applyToRange(textRange, fontVariant);