public class PDType0Font extends PDFont implements PDVectorFont
DEFAULT_FONT_MATRIX, dict| Constructor and Description |
|---|
PDType0Font(COSDictionary fontDictionary)
Constructor for reading a Type0 font from a PDF file.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addToSubset(int codePoint)
Adds the given Unicode point to the subset.
|
int |
codeToCID(int code)
Returns the CID for the given character code.
|
int |
codeToGID(int code)
Returns the GID for the given character code.
|
protected byte[] |
encode(int unicode)
Encodes the given Unicode code point for use in a PDF content stream.
|
float |
getAverageFontWidth()
This will get the average font width for all characters.
|
String |
getBaseFont()
Returns the PostScript name of the font.
|
org.apache.fontbox.util.BoundingBox |
getBoundingBox()
Returns the font's bounding box.
|
org.apache.fontbox.cmap.CMap |
getCMap()
Returns the font's CMap.
|
org.apache.fontbox.cmap.CMap |
getCMapUCS2()
Returns the font's UCS2 CMap, only present this font uses a predefined CMap.
|
PDCIDFont |
getDescendantFont()
Returns the descendant font.
|
Vector |
getDisplacement(int code)
Returns the displacement vector (w0, w1) in text space, for the given character.
|
PDFontDescriptor |
getFontDescriptor()
Returns the font descriptor, may be null.
|
Matrix |
getFontMatrix()
Returns the font matrix, which represents the transformation from glyph space to text space.
|
float |
getHeight(int code)
Returns the height of the given character, in glyph space.
|
String |
getName()
Returns the name of this font, either the PostScript "BaseName" or the Type 3 "Name".
|
GeneralPath |
getPath(int code)
Returns the glyph path for the given character code.
|
Vector |
getPositionVector(int code)
Returns the position vector (v), in text space, for the given character.
|
protected float |
getStandard14Width(int code)
Returns the glyph width from the AFM if this is a Standard 14 font.
|
float |
getWidth(int code)
Returns the advance width of the given character, in glyph space.
|
float |
getWidthFromFont(int code)
Returns the width of a glyph in the embedded font file.
|
boolean |
hasGlyph(int code)
Returns true if this font contains a glyph for the given character code.
|
boolean |
isDamaged()
Returns true if the embedded font file is damaged.
|
boolean |
isEmbedded()
Returns true if the font file is embedded in the PDF.
|
boolean |
isStandard14()
Returns true if this font is one of the "Standard 14" fonts and receives special handling.
|
boolean |
isVertical()
Returns true if the font uses vertical writing mode.
|
static PDType0Font |
load(PDDocument doc,
File file)
Loads a TTF to be embedded into a document as a Type 0 font.
|
static PDType0Font |
load(PDDocument doc,
InputStream input)
Loads a TTF to be embedded into a document as a Type 0 font.
|
static PDType0Font |
load(PDDocument doc,
InputStream input,
boolean embedSubset)
Loads a TTF to be embedded into a document as a Type 0 font.
|
static PDType0Font |
load(PDDocument doc,
org.apache.fontbox.ttf.TrueTypeFont ttf,
boolean embedSubset)
Loads a TTF to be embedded into a document as a Type 0 font.
|
int |
readCode(InputStream in)
Reads a character code from a content stream string.
|
void |
subset()
Replaces this font with a subset containing only the given Unicode characters.
|
String |
toString() |
String |
toUnicode(int code)
Returns the Unicode character sequence which corresponds to the given character code.
|
boolean |
willBeSubset()
Returns true if this font will be subset when embedded.
|
encode, equals, getCOSObject, getSpaceWidth, getStandard14AFM, getStringWidth, getSubType, getType, getWidths, hashCode, readCMap, setFontDescriptor, toUnicodepublic PDType0Font(COSDictionary fontDictionary) throws IOException
fontDictionary - The font dictionary according to the PDF specification.IOException - if the descendant font is missing.public static PDType0Font load(PDDocument doc, File file) throws IOException
doc - The PDF document that will hold the embedded font.file - A TrueType font.IOException - If there is an error reading the font file.public static PDType0Font load(PDDocument doc, InputStream input) throws IOException
doc - The PDF document that will hold the embedded font.input - A TrueType font.IOException - If there is an error reading the font stream.public static PDType0Font load(PDDocument doc, InputStream input, boolean embedSubset) throws IOException
doc - The PDF document that will hold the embedded font.input - A TrueType font.embedSubset - True if the font will be subset before embeddingIOException - If there is an error reading the font stream.public static PDType0Font load(PDDocument doc, org.apache.fontbox.ttf.TrueTypeFont ttf, boolean embedSubset) throws IOException
doc - The PDF document that will hold the embedded font.ttf - A TrueType font.embedSubset - True if the font will be subset before embeddingIOException - If there is an error reading the font stream.public void addToSubset(int codePoint)
PDFontaddToSubset in class PDFontcodePoint - Unicode code pointpublic void subset()
throws IOException
PDFontsubset in class PDFontIOException - if the subset could not be writtenpublic boolean willBeSubset()
PDFontwillBeSubset in class PDFontpublic String getBaseFont()
public PDCIDFont getDescendantFont()
public org.apache.fontbox.cmap.CMap getCMap()
public org.apache.fontbox.cmap.CMap getCMapUCS2()
public PDFontDescriptor getFontDescriptor()
PDFontLikegetFontDescriptor in interface PDFontLikegetFontDescriptor in class PDFontpublic Matrix getFontMatrix()
PDFontLikegetFontMatrix in interface PDFontLikegetFontMatrix in class PDFontpublic boolean isVertical()
PDFontisVertical in class PDFontpublic float getHeight(int code)
throws IOException
PDFontLike
Warning: This method is deprecated in PDFBox 2.0 because there is no meaningful value
which it can return. The PDFontLike.getWidth(int) method returns the advance width of a glyph,
but there is no corresponding advance height. The logical height of a character is the same
for every character in a font, so if you want that, retrieve the font bbox's height.
Otherwise if you want the visual bounds of the glyph then call getPath(..) on the appropriate
PDFont subclass to retrieve the glyph outline as a GeneralPath.
getHeight in interface PDFontLikegetHeight in class PDFontcode - character codeIOExceptionprotected byte[] encode(int unicode)
throws IOException
PDFontThis method is called when embedding text in PDFs and when filling in fields.
encode in class PDFontunicode - Unicode code point.IOException - If the text could not be encoded.public float getAverageFontWidth()
PDFontgetAverageFontWidth in interface PDFontLikegetAverageFontWidth in class PDFontpublic Vector getPositionVector(int code)
PDFontLikegetPositionVector in interface PDFontLikegetPositionVector in class PDFontcode - character codepublic Vector getDisplacement(int code) throws IOException
PDFontgetDisplacement in class PDFontcode - character codeIOExceptionpublic float getWidth(int code)
throws IOException
PDFontLikeIf you want the visual bounds of the glyph then call getPath(..) on the appropriate PDFont subclass to retrieve the glyph outline as a GeneralPath instead.
getWidth in interface PDFontLikegetWidth in class PDFontcode - character codeIOExceptionprotected float getStandard14Width(int code)
PDFontgetStandard14Width in class PDFontcode - character codepublic float getWidthFromFont(int code)
throws IOException
PDFontLikegetWidthFromFont in interface PDFontLikegetWidthFromFont in class PDFontcode - character codeIOException - if the font could not be readpublic boolean isEmbedded()
PDFontLikeisEmbedded in interface PDFontLikeisEmbedded in class PDFontpublic String toUnicode(int code) throws IOException
PDFonttoUnicode in class PDFontcode - character codeIOExceptionpublic String getName()
PDFontLikegetName in interface PDFontLikegetName in class PDFontpublic org.apache.fontbox.util.BoundingBox getBoundingBox()
throws IOException
PDFontLikegetBoundingBox in interface PDFontLikegetBoundingBox in class PDFontIOExceptionpublic int readCode(InputStream in) throws IOException
PDFontreadCode in class PDFontin - string streamIOException - if the CMap or stream cannot be readpublic int codeToCID(int code)
code - character codepublic int codeToGID(int code)
throws IOException
code - character codeIOExceptionpublic boolean isStandard14()
PDFontisStandard14 in class PDFontpublic boolean isDamaged()
PDFontLikeisDamaged in interface PDFontLikeisDamaged in class PDFontpublic GeneralPath getPath(int code) throws IOException
PDVectorFontgetPath in interface PDVectorFontcode - character code in a PDF. Not to be confused with unicode.IOException - if the font could not be readpublic boolean hasGlyph(int code)
throws IOException
PDVectorFonthasGlyph in interface PDVectorFontcode - character code in a PDF. Not to be confused with unicode.IOExceptionCopyright © 2002–2017 The Apache Software Foundation. All rights reserved.