Class: Font

Core.Annotations. Font


new Font( [params])

A class representing a PDF font
Parameters:
Name Type Argument Description
params Core.Annotations.Font.FontOptions <optional>
Parameters to initialize the font
Properties:
Name Type Description
name string The font's name
size number The font's size
type 'CIDType0' | 'CIDType2' | 'MMType1' | 'TrueType' | 'Type0' | 'Type1' | 'Type3' The font's type
strokeColor Core.Annotations.Color The font's stroke color
fillColor Core.Annotations.Color The font's fill color
calculatedSize number The calculated size of the font if size is 0

Methods


isBlack()

Checks if the font is solid black
Returns:
Whether the font is solid black
Type
boolean

set(options)

Sets all properties on the Font using a Font instance, a font name string, or a FontOptions object
Parameters:
Name Type Description
options Core.Annotations.Font | string | Core.Annotations.Font.FontOptions The options to set on the Font

toCSS(zoom)

Converts the font to a CSS style object with properties like font-family, font-size, and color
Parameters:
Name Type Description
zoom number The zoom level to apply to the font size
Returns:
An object containing CSS style properties
Type
Partial.<CSSStyleDeclaration>

Type Definitions


FontOptions

Type:
  • object
Properties:
Name Type Argument Description
name string <optional>
The font's name
size number <optional>
The font's size (default: 0)
type 'CIDType0' | 'CIDType2' | 'MMType1' | 'TrueType' | 'Type0' | 'Type1' | 'Type3' <optional>
The font's type (default: 'Type1')
strokeColor Core.Annotations.Color | Array.<number> <optional>
The font's stroke color (default: black)
fillColor Core.Annotations.Color | Array.<number> <optional>
The font's fill color (default: black)