Font objects can be created from TrueType, OpenType, Type1 or CFF fonts. In PDF there are also special Type3 fonts.
Create a new font. Either from a buffer, a file name, or a built-in font name.
The built-in standard PDF fonts are:
"Times-Roman""Times-Italic""Times-Bold""Times-BoldItalic""Helvetica""Helvetica-Oblique""Helvetica-Bold""Helvetica-BoldOblique""Courier""Courier-Oblique""Courier-Bold""Courier-BoldOblique""Symbol""ZapfDingbats"The built-in CJK fonts are referenced by language code:
"zh-Hant", "zh-Hans", "ja",
"ko".
string) – Font name.Buffer | ArrayBuffer | Uint8Array) – The font data if
loaded from a buffer.string) – The name of the
font file to load.number) – Subfont index (only
used for TTC fonts).var font1 = new mupdf.Font("Times-Roman")
var font2 = new mupdf.Font("ko")
var font3 = new mupdf.Font("Comic Sans", "/usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS.ttf")
var font4 = new mupdf.Font("Comic Sans", "/usr/share/fonts/truetype/msttcorefonts/Comic_Sans_MS.ttf", 1)
var font5 = new mupdf.Font("Freight Sans", fs.readFileSync("DroidSansFallbackFull.ttf"))Encoding constants for PDFDocument.prototype.addSimpleFont:
WinAnsiEncoding (a.k.a. CP-1252)
ISO-8859-7
KOI8-U
Get the font name.
var name = font.getName()Get the glyph index for a unicode character. Glyph 0 is
returned if the font does not have a glyph for the character.
number | string) – The
unicode character, or the first unicode character of a string.var index = font.encodeCharacter(0x42)Return advance width for a glyph in either horizontal or vertical writing mode.
number) – The glyph as unicode
character.number) – 0 for
horizontal writing, and 1 for vertical writing, defaults to
horizontal.var width = font.advanceGlyph(0x42)Returns true if font is bold.
var isBold = font.isBold()Returns true if font is italic.
var isItalic = font.isItalic()Returns true if font is monospaced.
var isMono = font.isMono()Returns true if font is serif.
var isSerif = font.isSerif()