Class: Font

PDFNet. Font


new Font()

A font that is used to draw text on a page. It corresponds to a Font Resource in a PDF file. More than one page may reference the same Font object. A Font has a number of attributes, including an array of widths, the character encoding, and the font's resource name. PDF document can contain several different types of fonts and Font class represents a single, flat interface around all PDF font types. There are two main classes of fonts in PDF: simple and composite fonts. Simple fonts are Type1, TrueType, and Type3 fonts. All simple fonts have the following properties:

- Glyphs in the font are selected by single-byte character codes obtained from a string that is shown by the text-showing operators. Logically, these codes index into a table of 256 glyphs; the mapping from codes to glyphs is called the font's encoding. Each font program has a built-in encoding. Under some circumstances, the encoding can be altered by means described in Section 5.5.5 "Character Encoding" in PDF Reference Manual.

- Each glyph has a single set of metrics. Therefore simple fonts support only horizontal writing mode.

A composite font is one whose glyphs are obtained from a font like object called a CIDFont (e.g. CIDType0Font and CIDType0Font). A composite font is represented by a font dictionary whose Subtype value is Type0. The Type 0 font is known as the root font, while its associated CIDFont is called its descendant. CID-keyed fonts provide a convenient and efficient method for defining multiple-byte character encodings and fonts with a large number of glyphs. These capabilities provide great flexibility for representing text in writing systems for languages with large character sets, such as Chinese, Japanese, and Korean (CJK).

Extends

Members


<static> Encoding

Properties:
Name Type Description
e_IdentityH number
e_Indices number

<static> StandardType1Font

Properties:
Name Type Description
e_times_roman number
e_times_bold number
e_times_italic number
e_times_bold_italic number
e_helvetica number
e_helvetica_bold number
e_helvetica_oblique number
e_helvetica_bold_oblique number
e_courier number
e_courier_bold number
e_courier_oblique number
e_courier_bold_oblique number
e_symbol number
e_zapf_dingbats number
e_null number

<static> Type

Properties:
Name Type Description
e_Type1 number
e_TrueType number
e_MMType1 number
e_Type3 number
e_Type0 number
e_CIDType0 number
e_CIDType2 number

Methods


<static> create(doc, type)

Constructor
Parameters:
Name Type Description
doc PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc Document on which to create the font on.
type number
PDFNet.Font.StandardType1Font = {
	e_times_roman : 0
	e_times_bold : 1
	e_times_italic : 2
	e_times_bold_italic : 3
	e_helvetica : 4
	e_helvetica_bold : 5
	e_helvetica_oblique : 6
	e_helvetica_bold_oblique : 7
	e_courier : 8
	e_courier_bold : 9
	e_courier_oblique : 10
	e_courier_bold_oblique : 11
	e_symbol : 12
	e_zapf_dingbats : 13
	e_null : 14
}
The type of font to create.
PDFNet.Font.StandardType1Font = {
	e_times_roman : 0
	e_times_bold : 1
	e_times_italic : 2
	e_times_bold_italic : 3
	e_helvetica : 4
	e_helvetica_bold : 5
	e_helvetica_oblique : 6
	e_helvetica_bold_oblique : 7
	e_courier : 8
	e_courier_bold : 9
	e_courier_oblique : 10
	e_courier_bold_oblique : 11
	e_symbol : 12
	e_zapf_dingbats : 13
	e_null : 14
}
Returns:
A promise that resolves to an object of type: "Font" (generated documentation)
Type
Promise.<PDFNet.Font>

<static> createAndEmbed(doc, type)

Parameters:
Name Type Description
doc PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc
type number
PDFNet.Font.StandardType1Font = {
	e_times_roman : 0
	e_times_bold : 1
	e_times_italic : 2
	e_times_bold_italic : 3
	e_helvetica : 4
	e_helvetica_bold : 5
	e_helvetica_oblique : 6
	e_helvetica_bold_oblique : 7
	e_courier : 8
	e_courier_bold : 9
	e_courier_oblique : 10
	e_courier_bold_oblique : 11
	e_symbol : 12
	e_zapf_dingbats : 13
	e_null : 14
}
Returns:
A promise that resolves to an object of type: "PDFNet.Font"
Type
Promise.<PDFNet.Font>

<static> createFromFontDescriptor(doc, from, char_set)

Parameters:
Name Type Description
doc PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc
from PDFNet.Font
char_set string
Returns:
A promise that resolves to an object of type: "PDFNet.Font"
Type
Promise.<PDFNet.Font>

<static> createFromName(doc, name, char_set)

Parameters:
Name Type Description
doc PDFNet.PDFDoc | PDFNet.SDFDoc | PDFNet.FDFDoc
name string
char_set string
Returns:
A promise that resolves to an object of type: "PDFNet.Font"
Type
Promise.<PDFNet.Font>

<static> createFromObj( [font_dict])

create a PDF::Font object from an existing SDF font object that is embedded in the document. If font_dict is null, a non valid font is created.
Parameters:
Name Type Argument Description
font_dict PDFNet.Obj <optional>
The Cos/SDF object to create the Font object with.
Returns:
A promise that resolves to an object of type: "PDFNet.Font"
Type
Promise.<PDFNet.Font>

<static> getTypeFromObj(font_dict)

Parameters:
Name Type Description
font_dict PDFNet.Obj
Returns:
A promise that resolves to an object of type: "number"
PDFNet.Font.Type = {
	e_Type1 : 0
	e_TrueType : 1
	e_MMType1 : 2
	e_Type3 : 3
	e_Type0 : 4
	e_CIDType0 : 5
	e_CIDType2 : 6
}
Type
Promise.<number>

destroy()

Destructor
Inherited From:
Returns:
Type
Promise.<void>

getAscent()

The face's ascender is the vertical distance from the baseline to the topmost point of any glyph in the face. This field's value is a positive number, expressed in the glyph coordinate system. For all font types except Type 3, the units of glyph space are one-thousandth of a unit of text space. Some font designs use a value different from 'bbox.yMax'.
Returns:
A promise that resolves to an object of type: "number"
Type
Promise.<number>

getBBox()

Returns:
A promise that resolves to a rectangle expressed in the glyph coordinate system, specifying the font bounding box. This is the smallest rectangle enclosing the shape that would result if all of the glyphs of the font were placed with their origins coincident and then filled.
Type
Promise.<PDFNet.Rect>

getCharCodeIterator()

GetCharCodeIterator represents an iterator interface used to traverse a list of char codes for which there is a glyph outline in the embedded font.
Returns:
A promise that resolves to an object of type: "PDFNet.Iterator"
Type
Promise.<PDFNet.Iterator.<number>>

getDescendant()

Returns:
A promise that resolves to descendant CIDFont.
Type
Promise.<PDFNet.Font>

getDescent()

The face's descender is the vertical distance from the baseline to the bottommost point of any glyph in the face. This field's value is a negative number expressed in the glyph coordinate system. For all font types except Type 3, the units of glyph space are one-thousandth of a unit of text space. Some font designs use a value different from 'bbox.yMin'.
Returns:
A promise that resolves to an object of type: "number"
Type
Promise.<number>

getDescriptor()

Returns:
A promise that resolves to a SDF/Cos object representing FontDescriptor or NULL is FontDescriptor is not present.
Type
Promise.<PDFNet.Obj>

getEmbeddedFont()

Returns:
A promise that resolves to the stream object of the embedded font or NULL if there if the font is not embedded.
Type
Promise.<PDFNet.Obj>

getEmbeddedFontBufSize()

Returns:
A promise that resolves to the size of decoded buffer containing embedded font data or 0 if this information is not known in advance.
Type
Promise.<number>

getEmbeddedFontName()

Returns:
A promise that resolves to the PostScript font name for the embedded font. If the embedded font name is not available the function returns the empty string .
Type
Promise.<string>

getEncoding()

Returns:
A promise that resolves to the font's encoding array (the mapping of character codes to glyphs). The array contains 256 pointers. If a pointer is not NULL, it points to a C string containing the name of the glyph for the code point corresponding to the index. If it is NULL, then the name of the glyph is unchanged from that specified by the font's built-in encoding. For a Type 3 font, all glyph names will be present in the encoding array, and NULL entries correspond to un-encoded code points.
Type
Promise.<string>

getFamilyName()

Returns:
A promise that resolves to the face's family name. This is an ASCII string, usually in English, which describes the typeface's family (like 'Times New Roman', 'Bodoni', 'Garamond', etc). This is a least common denominator used to list fonts.
Type
Promise.<string>

getMaxWidth()

Returns:
A promise that resolves to the maximal advance width, in font units, for all glyphs in this face.
Type
Promise.<number>

getMissingWidth()

Returns:
A promise that resolves to the default width to use for character codes whose widths are not specified in a font dictionary's Widths array.
Type
Promise.<number>

getName()

Returns:
A promise that resolves to the name of a font. The behavior depends on the font type; for a Type 3 font it gets the value of the Name key in a PDF Font resource. For other types it gets the value of the BaseFont key in a PDF font resource.
Type
Promise.<string>

getSDFObj()

Returns:
A promise that resolves to a SDF/Cos object of this Font.
Type
Promise.<PDFNet.Obj>

getShapedText(text_to_shape)

Creates a set of positioned glyphs corresponding to the visual representation of the provided text string. The shaped text will take into account any advanced positioning and substitution features provided by an underylying embedded font file. For example, these features could include kerning, ligatures, and diacritic positioning. Typically the resulting shaped text would be fed into ElementBuilder.CreateShapedTextRun()
Parameters:
Name Type Description
text_to_shape string the string to be shaped.
Returns:
A promise that resolves to a ShapedText object representing the result of the shaping operation.
Type
Promise.<PDFNet.ShapedText>

getStandardType1FontType()

Returns:
A promise that resolves to font::e_null if the font is not a standard Type1 font or some other StandardType1Font value for a standard Type1 font.
Type
Promise.<number>

getType()

Returns:
A promise that resolves to font Type
Type
Promise.<number>
Example
Return value enum:
<pre>
PDFNet.Font.Type = {
	e_Type1 : 0
	e_TrueType : 1
	e_MMType1 : 2
	e_Type3 : 3
	e_Type0 : 4
	e_CIDType0 : 5
	e_CIDType2 : 6
}
</pre>

getType3FontMatrix()

Returns:
A promise that resolves to type3 font matrix, mapping glyph space to text space A common practice is to define glyphs in terms of a 1000-unit glyph coordinate system, in which case the font matrix is [0.001 0 0 0.001 0 0].
Type
Promise.<PDFNet.Matrix2D>

getType3GlyphStream(char_code)

Parameters:
Name Type Description
char_code number
Returns:
A promise that resolves to an object of type: "PDFNet.Obj"
Type
Promise.<PDFNet.Obj>

getUnitsPerEm()

Returns:
A promise that resolves to the number of font units per EM square for this face. This is typically 2048 for TrueType fonts, 1000 for Type1 fonts
Type
Promise.<number>

getVerticalAdvance(char_code)

Parameters:
Name Type Description
char_code number character to query for vertical advance
Returns:
A promise that resolves to vertical advance. vertical advance is a displacement vector for vertical writing mode (i.e. writing mode 1); its horizontal component is always 0.
Type
Promise.<Object>

getWidth(char_code)

Parameters:
Name Type Description
char_code number
Returns:
A promise that resolves to an object of type: "number"
Type
Promise.<number>

isAllCap()

Returns:
A promise that resolves to true if font contains no lowercase letters
Type
Promise.<boolean>

isCFF()

Returns:
A promise that resolves to true if the embedded font is represented as CFF (Compact Font Format).
Type
Promise.<boolean>

isEmbedded()

Tests whether or not the specified font is stored as a font file in a stream embedded in the PDF file.
Returns:
A promise that resolves to true if the font is embedded in the file, false otherwise.
Type
Promise.<boolean>

isFixedWidth()

Returns:
A promise that resolves to true if all glyphs have the same width
Type
Promise.<boolean>

isForceBold()

Returns:
A promise that resolves to true if bold glyphs should be painted with extra pixels at very small text sizes.
Type
Promise.<boolean>

isHorizontalMode()

Returns:
A promise that resolves to true if the font uses horizontal writing mode, false for vertical writing mode.
Type
Promise.<boolean>

isItalic()

Returns:
A promise that resolves to true if glyphs have dominant vertical strokes that are slanted.
Type
Promise.<boolean>

isSerif()

Returns:
A promise that resolves to true if glyphs have serifs
Type
Promise.<boolean>

isSimple()

Returns:
A promise that resolves to true for non-CID based fonts such as Type1, TrueType, and Type3 All simple fonts have the following properties:

Glyphs in the font are selected by single-byte character codes obtained from a string that is shown by the text-showing operators. Logically, these codes index into a table of 256 glyphs; the mapping from codes to glyphs is called the font's encoding. Each font program has a built-in encoding. Under some circumstances, the encoding can be altered by means described in Section 5.5.5 "Character Encoding" in PDF Reference Manual.

Each glyph has a single set of metrics. Therefore simple fonts support only horizontal writing mode.

Type
Promise.<boolean>

isSymbolic()

Returns:
A promise that resolves to true if font contains characters outside the Adobe standard Latin character set.
Type
Promise.<boolean>

mapToCID(char_code)

Parameters:
Name Type Description
char_code number
Returns:
A promise that resolves to an object of type: "number"
Type
Promise.<number>

takeOwnership()

Take the ownership of this object, so that PDFNet.runWithCleanup won't destroy this object.
Inherited From:
Returns:
Type
void