java.lang.Object | |
↳ | com.pdftron.pdf.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).
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
|
The Constant e_CIDType0.
The Constant e_CIDType2.
The Constant e_IdentityH.
The Constant e_Indices.
The Constant e_MMType1.
The Constant e_TrueType.
The Constant e_Type0.
The Constant e_Type1.
The Constant e_Type3.
The Constant e_courier.
The Constant e_courier_bold.
The Constant e_courier_bold_oblique.
The Constant e_courier_oblique.
The Constant e_helvetica.
The Constant e_helvetica_bold.
The Constant e_helvetica_bold_oblique.
The Constant e_helvetica_oblique.
The Constant e_null.
The Constant e_symbol.
The Constant e_times_bold.
The Constant e_times_bold_italic.
The Constant e_times_italic.
The Constant e_times_roman.
The Constant e_zapf_dingbats.
Instantiates a new font.
Create a PDF.Font object from an existing SDF font object that is embedded in the document.
font_dict | the embedded font dictionary |
---|
Get the descriptor.
PDFNetException |
---|
Create a PDF.Font object for the given standard (also known as base 14 font).
doc | Document in which the external font should be embedded. |
---|---|
type | the font type |
PDFNetException |
---|
Create a PDF.Font object for the given standard (also known as base 14 font).
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'. |
PDFNetException |
---|
Create a PDF.Font object for the given standard (also known as base 14 font).
doc | Document in which the external font should be embedded. |
---|---|
name | the name of the font |
char_set | the char set of the font |
PDFNetException |
---|
Create a PDF.Font object for the given standard (also known as base 14 font).
doc | Document in which the external font should be embedded. |
---|---|
from | the font to copy from |
char_set | the char set of the font |
PDFNetException |
---|
Embed an external TrueType font in the document as a CID font.
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 |
PDFNetException |
---|
Embed an external TrueType font in the document as a CID font.
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 |
PDFNetException |
---|
Creates the cid true type font.
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) |
PDFNetException |
---|
Creates the cid true type font.
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 |
PDFNetException |
---|
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.
doc | document in which the external font should be embedded. |
---|---|
font_stream | Stream of external font file. |
PDFNetException |
---|
Creates the cid true type font.
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) |
PDFNetException |
---|
Creates the cid true type font.
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 |
PDFNetException |
---|
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.
doc | document in which the external font should be embedded. |
---|---|
font_path | path to the external font file. |
PDFNetException |
---|
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.
doc | Document in which the external font should be embedded. |
---|---|
font_path | Path to the external font file. |
PDFNetException |
---|
Creates the true type font.
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. |
PDFNetException |
---|
Creates the true type font.
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'. |
PDFNetException |
---|
Creates the true type font.
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'. |
PDFNetException |
---|
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.
doc | Document in which the external font should be embedded. |
---|---|
font_stream | Stream of external font file. |
PDFNetException |
---|
Creates the true type font.
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. |
PDFNetException |
---|
Creates the type1 font.
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'. |
PDFNetException |
---|
Embed an external Type1 font in the document.
doc | document in which the external font should be embedded. |
---|---|
font_path | path to the external font file. |
PDFNetException |
---|
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.
PDFNetException |
---|
Get the bounding box.
PDFNetException |
---|
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.
PDFNetException |
---|
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.
PDFNetException |
---|
Get the embedded font.
Note: This function is not applicable to Type3 font and will throw an exception.
PDFNetException |
---|
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.
PDFNetException |
---|
Get the embedded font name.
PDFNetException |
---|
Get the encoding array
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.
PDFNetException |
---|
Get the family name.
PDFNetException |
---|
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'.
char_code | character to query |
---|---|
conics2cubics | if set to true converts all quadratic Bezier curves to cubic Beziers, otherwise no coversion is performed. |
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'.
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. |
Get the max width of the current font
PDFNetException |
---|
Get the missing width.
PDFNetException |
---|
Get the font name.
PDFNetException |
---|
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.
text_to_shape | the string to be shaped. |
---|
Get the standard type1 font type.
PDFNetException |
---|
Get the font type from specified font dictionary.
font_dict | the given font dictionary |
---|
PDFNetException |
---|
Get the type3 font matrix.
Note: Relevant only for a Type3 font.
PDFNetException |
---|
Get the type3 glyph stream.
Note: Relevant only for a Type3 font.
char_code | the char_code |
---|
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.
PDFNetException |
---|
Get the current font width.
char_code | the given character code |
---|
PDFNetException |
---|
Checks if font is all cap.
PDFNetException |
---|
Checks if current font is CFF.
Note: Only Type1 and Type1C fonts can be represented in CFF format
PDFNetException |
---|
Tests whether or not the specified font is stored as a font file in a stream embedded in the PDF file.
PDFNetException |
---|
Checks if current font is fixed width.
PDFNetException |
---|
Checks if font is force bold.
PDFNetException |
---|
Checks if font is in horizontal mode.
PDFNetException |
---|
Checks if font is italic.
PDFNetException |
---|
Checks if font is simple.
PDFNetException |
---|
Checks if font is symbolic.
PDFNetException |
---|
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.
char_code | encoding specific 'charcode' that needs to be converted to Unicode. |
---|
PDFNetException |
---|