Penpot plugins API
    Preparing search index...

    Interface FontsContext

    Represents the context for managing fonts in Penpot. This interface provides methods to interact with fonts, such as retrieving fonts by ID or name.

    interface FontsContext {
        all: Font[];
        findById(id: string): Font | null;
        findByName(name: string): Font | null;
        findAllById(id: string): Font[];
        findAllByName(name: string): Font[];
    }
    Index

    Properties

    all: Font[]

    An array containing all available fonts.

    Methods

    • Finds a font by its unique identifier.

      Parameters

      • id: string

        The ID of the font to find.

      Returns Font | null

      Returns the Font object if found, otherwise null.

      const font = fontsContext.findById('font-id');
      if (font) {
      console.log(font.name);
      }
    • Finds a font by its name.

      Parameters

      • name: string

        The name of the font to find.

      Returns Font | null

      Returns the Font object if found, otherwise null.

      const font = fontsContext.findByName('font-name');
      if (font) {
      console.log(font.name);
      }
    • Finds all fonts matching a specific ID.

      Parameters

      • id: string

        The ID to match against.

      Returns Font[]

      Returns an array of Font objects matching the provided ID.

      const fonts = fontsContext.findAllById('font-id');
      console.log(fonts);
    • Finds all fonts matching a specific name.

      Parameters

      • name: string

        The name to match against.

      Returns Font[]

      Returns an array of Font objects matching the provided name.

      const fonts = fontsContext.findAllByName('font-name');
      console.log(fonts);