modern-pdf-lib / FontRef
Interface: FontRef
Defined in: src/core/pdfPage.ts:438
Opaque handle for a font that has been embedded in the document.
Properties
name
readonlyname:string
Defined in: src/core/pdfPage.ts:440
Resource name used in content-stream operators (e.g. F1).
ref
readonlyref:PdfRef
Defined in: src/core/pdfPage.ts:442
Indirect reference to the font dictionary.
Methods
getCharacterSet()?
optionalgetCharacterSet():number[]
Defined in: src/core/pdfPage.ts:481
Return the set of Unicode codepoints supported by this font.
For standard fonts, returns the WinAnsi character set. For embedded fonts, returns all codepoints in the cmap table.
Returns
number[]
Array of Unicode codepoint numbers.
heightAtSize()
heightAtSize(
size):number
Defined in: src/core/pdfPage.ts:452
Compute the height of the font at the given size (ascender - descender). Available for both standard and TrueType fonts.
Parameters
size
number
Returns
number
sizeAtHeight()?
optionalsizeAtHeight(height):number
Defined in: src/core/pdfPage.ts:472
Compute the font size needed to achieve a given height (ascender - descender). This is the inverse of heightAtSize().
Parameters
height
number
Desired height in points.
Returns
number
Font size in points.
widthOfTextAtSize()
widthOfTextAtSize(
text,size):number
Defined in: src/core/pdfPage.ts:447
Compute the width of a text string at the given font size (in points). Available for both standard and TrueType fonts.
Parameters
text
string
size
number
Returns
number