pdf-lite - v1.3.0
    Preparing search index...

    Represents an embedded font in a PDF document. Extends PdfDictionary to provide both font metadata and PDF dictionary structure.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    auxiliaryObjects: PdfIndirectObject<PdfObject>[] = []

    Auxiliary objects that must be committed along with the font dict. Includes FontDescriptor, FontFile2, CIDFont, ToUnicode, etc.

    Reference to the container indirect object that wraps this font dict. Set by FontManager.write() when the font is committed to the PDF.

    innerTokens: PdfToken[] = []
    modified: boolean = true

    Indicates whether the object has been modified. By default, assume it has been modified because it's a new object

    postTokens?: PdfToken[]

    Optional tokens to prepend or append during serialization

    preTokens?: PdfToken[]

    Optional tokens to prepend or append during serialization

    resourceName: string

    The PDF resource name used in content streams (e.g., 'F1', 'F2'). This is the identifier used in PDF operators like /F1 12 Tf.

    Accessors

    • get fontType(): "Type1" | "TrueType" | "Type0" | "MMType1" | "Type3" | undefined

      Gets the font type (Subtype in PDF).

      Returns "Type1" | "TrueType" | "Type0" | "MMType1" | "Type3" | undefined

    • set fontType(
          type: "Type1" | "TrueType" | "Type0" | "MMType1" | "Type3" | undefined,
      ): void

      Sets the font type (Subtype in PDF).

      Parameters

      • type: "Type1" | "TrueType" | "Type0" | "MMType1" | "Type3" | undefined

      Returns void

    Methods

    • Type Parameters

      • K extends
            | "Type"
            | "Subtype"
            | "BaseFont"
            | "FontDescriptor"
            | "Encoding"
            | "FirstChar"
            | "LastChar"
            | "Widths"
            | "DescendantFonts"
            | "ToUnicode"

      Parameters

      Returns void

    • Type Parameters

      • K extends
            | "Type"
            | "Subtype"
            | "BaseFont"
            | "FontDescriptor"
            | "Encoding"
            | "FirstChar"
            | "LastChar"
            | "Widths"
            | "DescendantFonts"
            | "ToUnicode"

      Parameters

      Returns
          | {
              BaseFont: PdfName;
              DescendantFonts?: PdfArray<PdfObjectReference>;
              Encoding?: PdfName<string>;
              FirstChar?: PdfNumber;
              FontDescriptor?: PdfObjectReference;
              LastChar?: PdfNumber;
              Subtype: PdfName<"Type1" | "TrueType" | "Type0">;
              ToUnicode?: PdfObjectReference;
              Type: PdfName<"Font">;
              Widths?: PdfArray<PdfNumber>;
          }[K]
          | undefined

    • Type Parameters

      • K extends
            | "Type"
            | "Subtype"
            | "BaseFont"
            | "FontDescriptor"
            | "Encoding"
            | "FirstChar"
            | "LastChar"
            | "Widths"
            | "DescendantFonts"
            | "ToUnicode"

      Parameters

      Returns boolean

    • Creates a PdfFont from a FontParser instance. Extracts all necessary information from the parser including font name, descriptor, and font data.

      Parameters

      • parser: FontParser

        A FontParser instance (TtfParser, OtfParser, or WoffParser)

      Returns PdfFont

      A PdfFont instance ready to be written to the PDF

    • Creates a standard PDF Type1 font (one of the 14 built-in fonts). These fonts don't require font data as they're built into PDF viewers.

      Parameters

      • fontName:
            | "Helvetica"
            | "Helvetica-Bold"
            | "Helvetica-Oblique"
            | "Helvetica-BoldOblique"
            | "Times-Roman"
            | "Times-Bold"
            | "Times-Italic"
            | "Times-BoldItalic"
            | "Courier"
            | "Courier-Bold"
            | "Courier-Oblique"
            | "Courier-BoldOblique"
            | "Symbol"
            | "ZapfDingbats"

        One of the 14 standard PDF fonts

      Returns PdfFont

      A PdfFont instance ready to be written to the PDF

    • Creates a Type0 (composite) font with Unicode support. Use this for fonts that need to display non-ASCII characters.

      Parameters

      • fontData: ByteArray

        The TrueType font file bytes

      • fontName: string

        The name to use for this font in the PDF

      • descriptor: UnicodeFontDescriptor

        Unicode font descriptor with CID metrics

      • OptionalunicodeMappings: Map<number, number>

        Optional map of CID to Unicode code point for ToUnicode CMap

      Returns PdfFont

      A PdfFont instance ready to be written to the PDF