public class

Font

extends Object
java.lang.Object
   ↳ com.pdftron.pdf.Font

Class Overview

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).

Summary

Constants
int e_CIDType0 The Constant e_CIDType0.
int e_CIDType2 The Constant e_CIDType2.
int e_IdentityH The Constant e_IdentityH.
int e_Indices The Constant e_Indices.
int e_MMType1 The Constant e_MMType1.
int e_TrueType The Constant e_TrueType.
int e_Type0 The Constant e_Type0.
int e_Type1 The Constant e_Type1.
int e_Type3 The Constant e_Type3.
int e_courier The Constant e_courier.
int e_courier_bold The Constant e_courier_bold.
int e_courier_bold_oblique The Constant e_courier_bold_oblique.
int e_courier_oblique The Constant e_courier_oblique.
int e_helvetica The Constant e_helvetica.
int e_helvetica_bold The Constant e_helvetica_bold.
int e_helvetica_bold_oblique The Constant e_helvetica_bold_oblique.
int e_helvetica_oblique The Constant e_helvetica_oblique.
int e_null The Constant e_null.
int e_symbol The Constant e_symbol.
int e_times_bold The Constant e_times_bold.
int e_times_bold_italic The Constant e_times_bold_italic.
int e_times_italic The Constant e_times_italic.
int e_times_roman The Constant e_times_roman.
int e_zapf_dingbats The Constant e_zapf_dingbats.
Public Constructors
Font()
Instantiates a new font.
Font(Obj font_dict)
Create a PDF.Font object from an existing SDF font object that is embedded in the document.
Public Methods
Obj GetDescriptor()
Get the descriptor.
Obj GetSDFObj()
Get the SDFObj.
static Font __Create(long impl, Object ref)
long __GetHandle()
Object __GetRefHandle()
static Font create(Doc doc, int type)
Create a PDF.Font object for the given standard (also known as base 14 font).
static Font create(Doc doc, int type, boolean embed)
Create a PDF.Font object for the given standard (also known as base 14 font).
static Font create(Doc doc, String name, String char_set)
Create a PDF.Font object for the given standard (also known as base 14 font).
static Font create(Doc doc, Font from, String char_set)
Create a PDF.Font object for the given standard (also known as base 14 font).
static Font createCIDTrueTypeFont(Doc doc, String font_path, boolean embed, boolean subset)
Embed an external TrueType font in the document as a CID font.
static Font createCIDTrueTypeFont(Doc doc, InputStream font_stream, boolean embed, boolean subset)
Embed an external TrueType font in the document as a CID font.
static Font createCIDTrueTypeFont(Doc doc, String font_path, boolean embed, boolean subset, int encoding)
Creates the cid true type font.
static Font createCIDTrueTypeFont(Doc doc, String font_path, boolean embed, boolean subset, int encoding, long ttc_font_index)
Creates the cid true type font.
static Font createCIDTrueTypeFont(Doc doc, InputStream font_stream)
Embed an external TrueType font in the document as a CID font.
static Font createCIDTrueTypeFont(Doc doc, InputStream font_stream, boolean embed, boolean subset, int encoding)
Creates the cid true type font.
static Font createCIDTrueTypeFont(Doc doc, InputStream font_stream, boolean embed, boolean subset, int encoding, long ttc_font_index)
Creates the cid true type font.
static Font createCIDTrueTypeFont(Doc doc, String font_path)
Embed an external TrueType font in the document as a CID font.
static Font createTrueTypeFont(Doc doc, String font_path)
Embed an external TrueType font in the document as a Simple font.
static Font createTrueTypeFont(Doc doc, String font_path, boolean embed, boolean subset)
Creates the true type font.
static Font createTrueTypeFont(Doc doc, InputStream font_stream, boolean embed)
Creates the true type font.
static Font createTrueTypeFont(Doc doc, String font_path, boolean embed)
Creates the true type font.
static Font createTrueTypeFont(Doc doc, InputStream font_stream)
Embed an external TrueType font in the document as a Simple font.
static Font createTrueTypeFont(Doc doc, InputStream font_stream, boolean embed, boolean subset)
Creates the true type font.
static Font createType1Font(Doc doc, String font_path, boolean embed)
Creates the type1 font.
static Font createType1Font(Doc doc, String font_path)
Embed an external Type1 font in the document.
double getAscent()
The face's ascender is the vertical distance from the baseline to the topmost point of any glyph in the face.
Rect getBBox()
Get the bounding box.
FontCharCodeIterator getCharCodeIterator()
CharCodeGetIterator represents an iterator interface used to traverse a list of char codes for which there is a glyph outline in the embedded font.
double getDescent()
The face's descender is the vertical distance from the baseline to the bottommost point of any glyph in the face.
Obj getEmbeddedFont()
Get the embedded font.
int getEmbeddedFontBufSize()
Get the embedded font buf size.
String getEmbeddedFontName()
Get the embedded font name.
String[] getEncoding()
Get the encoding array
String getFamilyName()
Get the family name.
PathData getGlyphPath(long char_code, boolean conics2cubics)
The function retrieves the glyph outline for a given character code.
PathData getGlyphPath(long char_code, boolean conics2cubics, Matrix2D transform)
Get the glyph outline for a given character code.
double getMaxWidth()
Get the max width of the current font
double getMissingWidth()
Get the missing width.
String getName()
Get the font name.
ShapedText getShapedText(String text_to_shape)
Creates a set of positioned glyphs corresponding to the visual representation of the provided text string.
int getStandardType1FontType()
Get the standard type1 font type.
static int getType(Obj font_dict)
Get the font type from specified font dictionary.
int getType()
Get the current font type.
Matrix2D getType3FontMatrix()
Get the type3 font matrix.
Obj getType3GlyphStream(long char_code)
Get the type3 glyph stream.
short getUnitsPerEm()
Get the units per EM square for the current font.
double getWidth(long char_code)
Get the current font width.
boolean isAllCap()
Checks if font is all cap.
boolean isCFF()
Checks if current font is CFF.
boolean isEmbedded()
Tests whether or not the specified font is stored as a font file in a stream embedded in the PDF file.
boolean isFixedWidth()
Checks if current font is fixed width.
boolean isForceBold()
Checks if font is force bold.
boolean isHorizontalMode()
Checks if font is in horizontal mode.
boolean isItalic()
Checks if font is italic.
boolean isSerif()
Checks if font is serif.
boolean isSimple()
Checks if font is simple.
boolean isSymbolic()
Checks if font is symbolic.
char[] mapToUnicode(long char_code)
Maps the encoding specific 'charcode' to Unicode.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int e_CIDType0

The Constant e_CIDType0.

Constant Value: 5 (0x00000005)

public static final int e_CIDType2

The Constant e_CIDType2.

Constant Value: 6 (0x00000006)

public static final int e_IdentityH

The Constant e_IdentityH.

Constant Value: 0 (0x00000000)

public static final int e_Indices

The Constant e_Indices.

Constant Value: 1 (0x00000001)

public static final int e_MMType1

The Constant e_MMType1.

Constant Value: 2 (0x00000002)

public static final int e_TrueType

The Constant e_TrueType.

Constant Value: 1 (0x00000001)

public static final int e_Type0

The Constant e_Type0.

Constant Value: 4 (0x00000004)

public static final int e_Type1

The Constant e_Type1.

Constant Value: 0 (0x00000000)

public static final int e_Type3

The Constant e_Type3.

Constant Value: 3 (0x00000003)

public static final int e_courier

The Constant e_courier.

Constant Value: 8 (0x00000008)

public static final int e_courier_bold

The Constant e_courier_bold.

Constant Value: 9 (0x00000009)

public static final int e_courier_bold_oblique

The Constant e_courier_bold_oblique.

Constant Value: 11 (0x0000000b)

public static final int e_courier_oblique

The Constant e_courier_oblique.

Constant Value: 10 (0x0000000a)

public static final int e_helvetica

The Constant e_helvetica.

Constant Value: 4 (0x00000004)

public static final int e_helvetica_bold

The Constant e_helvetica_bold.

Constant Value: 5 (0x00000005)

public static final int e_helvetica_bold_oblique

The Constant e_helvetica_bold_oblique.

Constant Value: 7 (0x00000007)

public static final int e_helvetica_oblique

The Constant e_helvetica_oblique.

Constant Value: 6 (0x00000006)

public static final int e_null

The Constant e_null.

Constant Value: 14 (0x0000000e)

public static final int e_symbol

The Constant e_symbol.

Constant Value: 12 (0x0000000c)

public static final int e_times_bold

The Constant e_times_bold.

Constant Value: 1 (0x00000001)

public static final int e_times_bold_italic

The Constant e_times_bold_italic.

Constant Value: 3 (0x00000003)

public static final int e_times_italic

The Constant e_times_italic.

Constant Value: 2 (0x00000002)

public static final int e_times_roman

The Constant e_times_roman.

Constant Value: 0 (0x00000000)

public static final int e_zapf_dingbats

The Constant e_zapf_dingbats.

Constant Value: 13 (0x0000000d)

Public Constructors

public Font ()

Instantiates a new font.

public Font (Obj font_dict)

Create a PDF.Font object from an existing SDF font object that is embedded in the document.

Parameters
font_dict the embedded font dictionary

Public Methods

public Obj GetDescriptor ()

Get the descriptor.

Returns
  • a SDF/Cos object representing FontDescriptor or NULL is FontDescriptor is not present.

public Obj GetSDFObj ()

Get the SDFObj.

Returns
  • a SDF/Cos object of this Font.

public static Font __Create (long impl, Object ref)

public long __GetHandle ()

public Object __GetRefHandle ()

public static Font create (Doc doc, int type)

Create a PDF.Font object for the given standard (also known as base 14 font).

Parameters
doc Document in which the external font should be embedded.
type the font type
Returns
  • the created font

public static Font create (Doc doc, int type, boolean embed)

Create a PDF.Font object for the given standard (also known as base 14 font).

Parameters
doc Document in which the external font should be embedded.
type the font type
embed a boolean indicating whether the font should be embedded or not. For accurate font reproduction set the embed flag to 'true'.
Returns
  • the created font

public static Font create (Doc doc, String name, String char_set)

Create a PDF.Font object for the given standard (also known as base 14 font).

Parameters
doc Document in which the external font should be embedded.
name the name of the font
char_set the char set of the font
Returns
  • the created font

public static Font create (Doc doc, Font from, String char_set)

Create a PDF.Font object for the given standard (also known as base 14 font).

Parameters
doc Document in which the external font should be embedded.
from the font to copy from
char_set the char set of the font
Returns
  • the created font

public static Font createCIDTrueTypeFont (Doc doc, String font_path, boolean embed, boolean subset)

Embed an external TrueType font in the document as a CID font.

Parameters
doc document in which the external font should be embedded.
font_path path to the external font file.
embed a boolean indicating whether the font should be embedded or not. For accurate font reproduction set the embed flag to 'true'.
subset a boolean indicating whether the embedded font should be subsetted
Returns
  • the created TrueType font

public static Font createCIDTrueTypeFont (Doc doc, InputStream font_stream, boolean embed, boolean subset)

Embed an external TrueType font in the document as a CID font.

Parameters
doc document in which the external font should be embedded.
font_stream Stream of external font file.
embed a boolean indicating whether the font should be embedded or not. For accurate font reproduction set the embed flag to 'true'.
subset a boolean indicating whether the embedded font should be subsetted
Returns
  • the created TrueType font

public static Font createCIDTrueTypeFont (Doc doc, String font_path, boolean embed, boolean subset, int encoding)

Creates the cid true type font.

Parameters
doc document in which the external font should be embedded.
font_path the path to the external font file.
embed a boolean indicating whether the font should be embedded or not. For accurate font reproduction set the embed flag to 'true'.
subset a boolean indicating whether the embedded font should be subsetted
encoding the encoding type either e_IdentityH (default) or e_Indices (to write glyph indices rather than unicode)
Returns
  • the font

public static Font createCIDTrueTypeFont (Doc doc, String font_path, boolean embed, boolean subset, int encoding, long ttc_font_index)

Creates the cid true type font.

Parameters
doc document in which the external font should be embedded.
font_path the path to the external font file.
embed a boolean indicating whether the font should be embedded or not. For accurate font reproduction set the embed flag to 'true'.
subset a boolean indicating whether the embedded font should be subsetted
encoding the encoding type either e_IdentityH (default) or e_Indices (to write glyph indices rather than unicode)
ttc_font_index - if a TrueTypeCollection (TTC) font is loaded this parameter controls which font is actually picked
Returns
  • the font

public static Font createCIDTrueTypeFont (Doc doc, InputStream font_stream)

Embed an external TrueType font in the document as a CID font. By default the function selects "Identity-H" encoding that maps 2-byte character codes ranging from 0 to 65,535 to the same Unicode value. Other predefined encodings are listed in Table 5.15 'Predefined CMap names' in PDF Reference Manual.

Parameters
doc document in which the external font should be embedded.
font_stream Stream of external font file.
Returns
  • the created true type font

public static Font createCIDTrueTypeFont (Doc doc, InputStream font_stream, boolean embed, boolean subset, int encoding)

Creates the cid true type font.

Parameters
doc document in which the external font should be embedded.
font_stream Stream of external font file.
embed a boolean indicating whether the font should be embedded or not. For accurate font reproduction set the embed flag to 'true'.
subset a boolean indicating whether the embedded font should be subsetted
encoding the encoding type either e_IdentityH (default) or e_Indices (to write glyph indices rather than unicode)
Returns
  • the font

public static Font createCIDTrueTypeFont (Doc doc, InputStream font_stream, boolean embed, boolean subset, int encoding, long ttc_font_index)

Creates the cid true type font.

Parameters
doc document in which the external font should be embedded.
font_stream Stream of external font file.
embed a boolean indicating whether the font should be embedded or not. For accurate font reproduction set the embed flag to 'true'.
subset a boolean indicating whether the embedded font should be subsetted
encoding the encoding type either e_IdentityH (default) or e_Indices (to write glyph indices rather than unicode)
ttc_font_index - if a TrueTypeCollection (TTC) font is loaded this parameter controls which font is actually picked
Returns
  • the font

public static Font createCIDTrueTypeFont (Doc doc, String font_path)

Embed an external TrueType font in the document as a CID font. By default the function selects "Identity-H" encoding that maps 2-byte character codes ranging from 0 to 65,535 to the same Unicode value. Other predefined encodings are listed in Table 5.15 'Predefined CMap names' in PDF Reference Manual.

Parameters
doc document in which the external font should be embedded.
font_path path to the external font file.
Returns
  • the created true type font

public static Font createTrueTypeFont (Doc doc, String font_path)

Embed an external TrueType font in the document as a Simple font.

Note: glyphs in the Simple font are selected by single-byte character codes. If you want to work with multi-byte character codes (e.g. UTF16) you need to create a CID font.

Parameters
doc Document in which the external font should be embedded.
font_path Path to the external font file.
Returns
  • the created font

public static Font createTrueTypeFont (Doc doc, String font_path, boolean embed, boolean subset)

Creates the true type font.

Parameters
doc Document in which the external font should be embedded.
font_path Path to the external font file.
embed embed A boolean indicating whether the font should be embedded or not. For accurate font reproduction set the embed flag to 'true'.
subset A boolean indicating whether the embedded font should be subsetted.
Returns
  • the created true type font

public static Font createTrueTypeFont (Doc doc, InputStream font_stream, boolean embed)

Creates the true type font.

Parameters
doc Document in which the external font should be embedded.
font_stream Stream of external font file.
embed A boolean indicating whether the font should be embedded or not. For accurate font reproduction set the embed flag to 'true'.
Returns
  • the created true type font

public static Font createTrueTypeFont (Doc doc, String font_path, boolean embed)

Creates the true type font.

Parameters
doc Document in which the external font should be embedded.
font_path Path to the external font file.
embed A boolean indicating whether the font should be embedded or not. For accurate font reproduction set the embed flag to 'true'.
Returns
  • the created true type font

public static Font createTrueTypeFont (Doc doc, InputStream font_stream)

Embed an external TrueType font in the document as a Simple font.

Note: glyphs in the Simple font are selected by single-byte character codes. If you want to work with multi-byte character codes (e.g. UTF16) you need to create a CID font.

Parameters
doc Document in which the external font should be embedded.
font_stream Stream of external font file.
Returns
  • the created font

public static Font createTrueTypeFont (Doc doc, InputStream font_stream, boolean embed, boolean subset)

Creates the true type font.

Parameters
doc Document in which the external font should be embedded.
font_stream Stream of external font file.
embed embed A boolean indicating whether the font should be embedded or not. For accurate font reproduction set the embed flag to 'true'.
subset A boolean indicating whether the embedded font should be subsetted.
Returns
  • the created true type font

public static Font createType1Font (Doc doc, String font_path, boolean embed)

Creates the type1 font.

Parameters
doc document in which the external font should be embedded.
font_path path to the external font file.
embed a boolean indicating whether the font should be embedded or not. For accurate font reproduction set the embed flag to 'true'.
Returns
  • the created font

public static Font createType1Font (Doc doc, String font_path)

Embed an external Type1 font in the document.

Parameters
doc document in which the external font should be embedded.
font_path path to the external font file.
Returns
  • the created font

public double 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'.

Note: Only relevant for scalable formats.

Returns
  • the vertical distance from the baseline to the topmost point of any glyph in the face.

public Rect getBBox ()

Get the bounding box.

Returns
  • 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.

public FontCharCodeIterator getCharCodeIterator ()

CharCodeGetIterator represents an iterator interface used to traverse a list of char codes for which there is a glyph outline in the embedded font.

Note: this function is in the process of being tested and shouldn't be used in production applications.

Returns
  • the char code iterator

public double 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'.

Note: Only relevant for scalable formats.

Returns
  • vertical distance from the baseline to the bottommost point of any glyph in the face.

public Obj getEmbeddedFont ()

Get the embedded font.

Note: This function is not applicable to Type3 font and will throw an exception.

Returns
  • the stream object of the embedded font or NULL if there if the font is not embedded.

public int getEmbeddedFontBufSize ()

Get the embedded font buf size.

Note: The size of decoded buffer may not be known in advance for all fonts and may not be correct.

Note: This function is not applicable to Type3 font and will throw an exception.

Returns
  • the size of decoded buffer containing embedded font data or 0 if this information is not known in advance.

public String getEmbeddedFontName ()

Get the embedded font name.

Returns
  • the PostScript font name for the embedded font. If the embedded font name is not available the function returns the empty string .

public String[] getEncoding ()

Get the encoding array

Returns
  • the font's encoding array (the mapping of character codes to glyphs). The array contains 256 Strings. If a String is not NULL, it 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 builtin 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.

    Note: The Font object is the owner of the array.

    Note: This function is not applicable to composite fonts (e_type0, e_CIDType0, and e_CIDType2) and will throw an exception.

public String getFamilyName ()

Get the family name.

Returns
  • 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.

public PathData getGlyphPath (long char_code, boolean conics2cubics)

The function retrieves the glyph outline for a given character code.

Note: the function can return only the following operators (Element::e_moveto, Element::e_lineto, Element::e_cubicto and optionaly Element::e_conicto if conics2cubics parameter is set to true.

Note: This function is not applicable to Type3 font and will throw an exception. Use GetType3GlyphStream instead.

Note: Check PathData.isDefined to see if the char_code was mapped to 'undefined character code'.

Parameters
char_code character to query
conics2cubics if set to true converts all quadratic Bezier curves to cubic Beziers, otherwise no coversion is performed.
Returns
  • A PathData object containing the path information..

public PathData getGlyphPath (long char_code, boolean conics2cubics, Matrix2D transform)

Get the glyph outline for a given character code.

Note: Check PathData.isDefined to see if the char_code was mapped to 'undefined character code'.

Parameters
char_code character to query
conics2cubics if set to true converts all quadratic Bezier curves to cubic Beziers, otherwise no conversion is performed.
transform a matrix used to transform glyph data coordinates. If null/unspecified, glyph data points will not be transformed.
Returns
  • the glyph path of the given character code

public double getMaxWidth ()

Get the max width of the current font

Returns
  • the maximal advance width, in font units, for all glyphs in this face.

public double getMissingWidth ()

Get the missing width.

Returns
  • the default width to use for character codes whose widths are not specified in a font dictionary's Widths array.

public String getName ()

Get the font name.

Returns
  • 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.

public ShapedText getShapedText (String 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()

Note: Shaping requires a Type0 font with an embedded font file which covers all the unicode codepoints in the source text. For best results, this font should use the e_Indices encoding scheme, as shaping features that combine multiple codepoints into one glyph (ligatures, for example) will not work well in non-index encoded fonts.

Parameters
text_to_shape the string to be shaped.
Returns
  • A ShapedText object representing the result of the shaping operation.

public int getStandardType1FontType ()

Get the standard type1 font type.

Returns
  • Font::e_null if the font is not a standard Type1 font or some other StandardType1Font value for a standard Type1 font.

public static int getType (Obj font_dict)

Get the font type from specified font dictionary.

Parameters
font_dict the given font dictionary
Returns
  • The type of a given SDF/Cos font dictionary

public int getType ()

Get the current font type.

Returns
  • current font Type

public Matrix2D getType3FontMatrix ()

Get the type3 font matrix.

Note: Relevant only for a Type3 font.

Returns
  • 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].

public Obj getType3GlyphStream (long char_code)

Get the type3 glyph stream.

Note: Relevant only for a Type3 font.

Parameters
char_code the char_code
Returns
  • a SDF/Cos glyph stream for the given char_code. If specified char_code is not found in CharPorcs dictionary the function returns NULL.

public short getUnitsPerEm ()

Get the units per EM square for the current font.

Note: Only relevant for scalable formats (such as TrueType and Type1).

Note: This function is not applicable to Type3 font and will throw an exception. Use GetType3FontMatrix instead.

Returns
  • the number of font units per EM square for this face. This is typically 2048 for TrueType fonts, 1000 for Type1 fonts

public double getWidth (long char_code)

Get the current font width.

Parameters
char_code the given character code
Returns
  • advance width, measured in character space units for the glyph matching given character code. The function gets the advance width of the font glyph. The advance width is the amount by which the current point advances when the glyph is drawn. The advance width may not correspond to the visible width of the glyph and for this reason, the advance width cannot be used to determine the glyphs bounding boxes.

public boolean isAllCap ()

Checks if font is all cap.

Returns
  • true if font contains no lowercase letters

public boolean isCFF ()

Checks if current font is CFF.

Note: Only Type1 and Type1C fonts can be represented in CFF format

Returns
  • true if the embedded font is represented as CFF (Compact Font Format).

public boolean isEmbedded ()

Tests whether or not the specified font is stored as a font file in a stream embedded in the PDF file.

Returns
  • true if the font is embedded in the file, false otherwise.

public boolean isFixedWidth ()

Checks if current font is fixed width.

Returns
  • true if all glyphs have the same width

public boolean isForceBold ()

Checks if font is force bold.

Returns
  • true if bold glyphs should be painted with extra pixels at very small text sizes.

public boolean isHorizontalMode ()

Checks if font is in horizontal mode.

Returns
  • true if the font uses horizontal writing mode, false for vertical writing mode.

public boolean isItalic ()

Checks if font is italic.

Returns
  • true if glyphs have dominant vertical strokes that are slanted.

public boolean isSerif ()

Checks if font is serif.

Returns
  • true if glyphs have serifs

public boolean isSimple ()

Checks if font is simple.

Returns
  • 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.

public boolean isSymbolic ()

Checks if font is symbolic.

Returns
  • true if font contains characters outside the Adobe standard Latin character set.

public char[] mapToUnicode (long char_code)

Maps the encoding specific 'charcode' to Unicode. Conversion of 'charcode' to Unicode can result in upto four Unicode characters.

Note: This function is not applicable to CIDFonts (e_CIDType0 and e_CIDType2) and will throw an exception if called.

Parameters
char_code encoding specific 'charcode' that needs to be converted to Unicode.
Returns
  • true if char_code was mapped to Unicode public area or false if the char_code was mapped to Unicode private area. A char_code is mapped to Unicode private area when the information required for proper mapping is missing in PDF document (e.g. a predefined encoding or ToUnicode CMap).