Font
¶
Font
objects can be created from TrueType, OpenType, Type1 or CFF fonts. In PDF there are also special Type3 fonts.
- new Font(ref)¶
Constructor method.
Create a new font, either using a built-in font name or a file 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
.- Arguments:
ref – Font name or file name.
- Returns:
Font
.
EXAMPLE
var font = new mupdf.Font("Times-Roman");
Instance methods
- getName()¶
Get the font name.
- Returns:
String
.
EXAMPLE
var name = font.getName();
- encodeCharacter(unicode)¶
Get the glyph index for a unicode character. Glyph zero (.notdef) is returned if the font does not have a glyph for the character.
- Arguments:
unicode – The unicode character.
- Returns:
Glyph index.
EXAMPLE
var index = font.encodeCharacter(0x42);
- advanceGlyph(glyph, wmode)¶
Return advance width for a glyph in either horizontal or vertical writing mode.
- Arguments:
glyph – The glyph as unicode character.
wmode –
0
for horizontal writing, and1
for vertical writing.
- Returns:
Width for the glyph.
EXAMPLE
var width = font.advanceGlyph(0x42, 0);
- isBold()¶
Returns true if font is bold.
- Returns:
Boolean
.
EXAMPLE
var isBold = font.isBold();
- isItalic()¶
Returns true if font is italic.
- Returns:
Boolean
.
EXAMPLE
var isItalic = font.isItalic();
- isMono()¶
Returns true if font is monospaced.
- Returns:
Boolean
.
EXAMPLE
var isMono = font.isMono();
- isSerif()¶
Returns true if font is serif.
- Returns:
Boolean
.
EXAMPLE
var isSerif = font.isSerif();