public class Font
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
e_CIDType0
The Constant e_CIDType0.
|
static int |
e_CIDType2
The Constant e_CIDType2.
|
static int |
e_courier
The Constant e_courier.
|
static int |
e_courier_bold
The Constant e_courier_bold.
|
static int |
e_courier_bold_oblique
The Constant e_courier_bold_oblique.
|
static int |
e_courier_oblique
The Constant e_courier_oblique.
|
static int |
e_helvetica
The Constant e_helvetica.
|
static int |
e_helvetica_bold
The Constant e_helvetica_bold.
|
static int |
e_helvetica_bold_oblique
The Constant e_helvetica_bold_oblique.
|
static int |
e_helvetica_oblique
The Constant e_helvetica_oblique.
|
static int |
e_IdentityH
The Constant e_IdentityH.
|
static int |
e_Indices
The Constant e_Indices.
|
static int |
e_MMType1
The Constant e_MMType1.
|
static int |
e_null
The Constant e_null.
|
static int |
e_symbol
The Constant e_symbol.
|
static int |
e_times_bold
The Constant e_times_bold.
|
static int |
e_times_bold_italic
The Constant e_times_bold_italic.
|
static int |
e_times_italic
The Constant e_times_italic.
|
static int |
e_times_roman
The Constant e_times_roman.
|
static int |
e_TrueType
The Constant e_TrueType.
|
static int |
e_Type0
The Constant e_Type0.
|
static int |
e_Type1
The Constant e_Type1.
|
static int |
e_Type3
The Constant e_Type3.
|
static int |
e_zapf_dingbats
The Constant e_zapf_dingbats.
|
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
static Font |
create(Doc doc,
Font from,
java.lang.String char_set)
Create a PDF.Font object for the given standard (also known as base 14 font).
|
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,
java.lang.String name,
java.lang.String char_set)
Create a PDF.Font object for the given standard (also known as base 14 font).
|
static Font |
createCIDTrueTypeFont(Doc doc,
java.io.InputStream font_stream)
Embed an external TrueType font in the document as a CID font.
|
static Font |
createCIDTrueTypeFont(Doc doc,
java.io.InputStream font_stream,
boolean embed,
boolean subset)
Embed an external TrueType font in the document as a CID font.
|
static Font |
createCIDTrueTypeFont(Doc doc,
java.io.InputStream font_stream,
boolean embed,
boolean subset,
int encoding)
Creates the cid true type font.
|
static Font |
createCIDTrueTypeFont(Doc doc,
java.io.InputStream font_stream,
boolean embed,
boolean subset,
int encoding,
long ttc_font_index)
Creates the cid true type font.
|
static Font |
createCIDTrueTypeFont(Doc doc,
java.lang.String font_path)
Embed an external TrueType font in the document as a CID font.
|
static Font |
createCIDTrueTypeFont(Doc doc,
java.lang.String font_path,
boolean embed,
boolean subset)
Embed an external TrueType font in the document as a CID font.
|
static Font |
createCIDTrueTypeFont(Doc doc,
java.lang.String font_path,
boolean embed,
boolean subset,
int encoding)
Creates the cid true type font.
|
static Font |
createCIDTrueTypeFont(Doc doc,
java.lang.String font_path,
boolean embed,
boolean subset,
int encoding,
long ttc_font_index)
Creates the cid true type font.
|
static Font |
createTrueTypeFont(Doc doc,
java.io.InputStream font_stream)
Embed an external TrueType font in the document as a Simple font.
|
static Font |
createTrueTypeFont(Doc doc,
java.io.InputStream font_stream,
boolean embed)
Creates the true type font.
|
static Font |
createTrueTypeFont(Doc doc,
java.io.InputStream font_stream,
boolean embed,
boolean subset)
Creates the true type font.
|
static Font |
createTrueTypeFont(Doc doc,
java.lang.String font_path)
Embed an external TrueType font in the document as a Simple font.
|
static Font |
createTrueTypeFont(Doc doc,
java.lang.String font_path,
boolean embed)
Creates the true type font.
|
static Font |
createTrueTypeFont(Doc doc,
java.lang.String font_path,
boolean embed,
boolean subset)
Creates the true type font.
|
static Font |
createType1Font(Doc doc,
java.lang.String font_path)
Embed an external Type1 font in the document.
|
static Font |
createType1Font(Doc doc,
java.lang.String font_path,
boolean embed)
Creates the type1 font.
|
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 |
GetDescriptor()
Get the descriptor.
|
Obj |
getEmbeddedFont()
Get the embedded font.
|
int |
getEmbeddedFontBufSize()
Get the embedded font buf size.
|
java.lang.String |
getEmbeddedFontName()
Get the embedded font name.
|
java.lang.String[] |
getEncoding()
Get the encoding array
|
java.lang.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.
|
java.lang.String |
getName()
Get the font name.
|
Obj |
GetSDFObj()
Get the SDFObj.
|
int |
getStandardType1FontType()
Get the standard type1 font type.
|
int |
getType()
Get the current font type.
|
static int |
getType(Obj font_dict)
Get the font type from specified font dictionary.
|
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.
|
public static final int e_times_roman
public static final int e_times_bold
public static final int e_times_italic
public static final int e_times_bold_italic
public static final int e_helvetica
public static final int e_helvetica_bold
public static final int e_helvetica_oblique
public static final int e_helvetica_bold_oblique
public static final int e_courier
public static final int e_courier_bold
public static final int e_courier_oblique
public static final int e_courier_bold_oblique
public static final int e_symbol
public static final int e_zapf_dingbats
public static final int e_null
public static final int e_IdentityH
public static final int e_Indices
public static final int e_Type1
public static final int e_TrueType
public static final int e_MMType1
public static final int e_Type3
public static final int e_Type0
public static final int e_CIDType0
public static final int e_CIDType2
public Font()
public Font(Obj font_dict)
font_dict
- the embedded font dictionarypublic static Font create(Doc doc, int type) throws PDFNetException
doc
- Document in which the external font should be embedded.type
- the font typePDFNetException
public static Font create(Doc doc, int type, boolean embed) throws PDFNetException
doc
- Document in which the external font should be embedded.type
- the font typeembed
- a boolean indicating whether the font should be embedded or not.
For accurate font reproduction set the embed flag to 'true'.PDFNetException
public static Font create(Doc doc, Font from, java.lang.String char_set) throws PDFNetException
doc
- Document in which the external font should be embedded.from
- the font to copy fromchar_set
- the char set of the fontPDFNetException
public static Font create(Doc doc, java.lang.String name, java.lang.String char_set) throws PDFNetException
doc
- Document in which the external font should be embedded.name
- the name of the fontchar_set
- the char set of the fontPDFNetException
public static Font createTrueTypeFont(Doc doc, java.lang.String font_path) throws PDFNetException
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
public static Font createTrueTypeFont(Doc doc, java.io.InputStream font_stream) throws PDFNetException
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
public static Font createTrueTypeFont(Doc doc, java.lang.String font_path, boolean embed) throws PDFNetException
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
public static Font createTrueTypeFont(Doc doc, java.io.InputStream font_stream, boolean embed) throws PDFNetException
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
public static Font createTrueTypeFont(Doc doc, java.lang.String font_path, boolean embed, boolean subset) throws PDFNetException
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
public static Font createTrueTypeFont(Doc doc, java.io.InputStream font_stream, boolean embed, boolean subset) throws PDFNetException
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
public static Font createCIDTrueTypeFont(Doc doc, java.lang.String font_path) throws PDFNetException
doc
- document in which the external font should be embedded.font_path
- path to the external font file.PDFNetException
public static Font createCIDTrueTypeFont(Doc doc, java.io.InputStream font_stream) throws PDFNetException
doc
- document in which the external font should be embedded.font_stream
- Stream of external font file.PDFNetException
public static Font createCIDTrueTypeFont(Doc doc, java.lang.String font_path, boolean embed, boolean subset) throws PDFNetException
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 subsettedPDFNetException
public static Font createCIDTrueTypeFont(Doc doc, java.io.InputStream font_stream, boolean embed, boolean subset) throws PDFNetException
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 subsettedPDFNetException
public static Font createCIDTrueTypeFont(Doc doc, java.lang.String font_path, boolean embed, boolean subset, int encoding) throws PDFNetException
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 subsettedencoding
- the encoding type either e_IdentityH (default) or e_Indices (to write glyph indices rather than unicode)PDFNetException
public static Font createCIDTrueTypeFont(Doc doc, java.io.InputStream font_stream, boolean embed, boolean subset, int encoding) throws PDFNetException
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 subsettedencoding
- the encoding type either e_IdentityH (default) or e_Indices (to write glyph indices rather than unicode)PDFNetException
public static Font createCIDTrueTypeFont(Doc doc, java.lang.String font_path, boolean embed, boolean subset, int encoding, long ttc_font_index) throws PDFNetException
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 subsettedencoding
- the encoding type either e_IdentityH (default) or e_Indices (to write glyph indices rather than unicode)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 pickedPDFNetException
public static Font createCIDTrueTypeFont(Doc doc, java.io.InputStream font_stream, boolean embed, boolean subset, int encoding, long ttc_font_index) throws PDFNetException
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 subsettedencoding
- 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 pickedPDFNetException
public static Font createType1Font(Doc doc, java.lang.String font_path) throws PDFNetException
doc
- document in which the external font should be embedded.font_path
- path to the external font file.PDFNetException
public static Font createType1Font(Doc doc, java.lang.String font_path, boolean embed) throws PDFNetException
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
public int getType() throws PDFNetException
PDFNetException
public boolean isSimple() throws PDFNetException
PDFNetException
public static int getType(Obj font_dict) throws PDFNetException
font_dict
- the given font dictionaryPDFNetException
public Obj GetSDFObj()
public Obj GetDescriptor() throws PDFNetException
PDFNetException
public java.lang.String getName() throws PDFNetException
PDFNetException
public java.lang.String getFamilyName() throws PDFNetException
PDFNetException
public boolean isFixedWidth() throws PDFNetException
PDFNetException
public boolean isSerif() throws PDFNetException
PDFNetException
public boolean isSymbolic() throws PDFNetException
PDFNetException
public boolean isItalic() throws PDFNetException
PDFNetException
public boolean isAllCap() throws PDFNetException
PDFNetException
public boolean isForceBold() throws PDFNetException
PDFNetException
public boolean isHorizontalMode() throws PDFNetException
PDFNetException
public double getWidth(long char_code) throws PDFNetException
char_code
- the given character codePDFNetException
public double getMaxWidth() throws PDFNetException
PDFNetException
public double getMissingWidth() throws PDFNetException
PDFNetException
public FontCharCodeIterator getCharCodeIterator() throws PDFNetException
Note: this function is in the process of being tested and shouldn't be used in production applications.
PDFNetException
public PathData getGlyphPath(long char_code, boolean conics2cubics)
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 queryconics2cubics
- if set to true converts all quadratic Bezier curves to cubic
Beziers, otherwise no coversion is performed.public PathData getGlyphPath(long char_code, boolean conics2cubics, Matrix2D transform)
Note: Check PathData.isDefined to see if the char_code was mapped to 'undefined character code'.
char_code
- character to queryconics2cubics
- 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.public char[] mapToUnicode(long char_code) throws PDFNetException
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
public java.lang.String[] getEncoding() throws PDFNetException
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
public boolean isEmbedded() throws PDFNetException
PDFNetException
public java.lang.String getEmbeddedFontName() throws PDFNetException
PDFNetException
public Obj getEmbeddedFont() throws PDFNetException
Note: This function is not applicable to Type3 font and will throw an exception.
PDFNetException
public int getEmbeddedFontBufSize() throws PDFNetException
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
public short getUnitsPerEm() throws PDFNetException
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
public Rect getBBox() throws PDFNetException
PDFNetException
public double getAscent() throws PDFNetException
Note: Only relevant for scalable formats.
PDFNetException
public double getDescent() throws PDFNetException
Note: Only relevant for scalable formats.
PDFNetException
public int getStandardType1FontType() throws PDFNetException
PDFNetException
public boolean isCFF() throws PDFNetException
Note: Only Type1 and Type1C fonts can be represented in CFF format
PDFNetException
public Matrix2D getType3FontMatrix() throws PDFNetException
Note: Relevant only for a Type3 font.
PDFNetException
public Obj getType3GlyphStream(long char_code)
Note: Relevant only for a Type3 font.
char_code
- the char_code