public class PDCIDFontType0 extends PDCIDFont
Modifier and Type | Class and Description |
---|---|
private class |
PDCIDFontType0.FF3ByteSource |
Modifier and Type | Field and Description |
---|---|
private java.lang.Float |
avgWidth |
private int[] |
cid2gid |
private CFFCIDFont |
cidFont |
private BoundingBox |
fontBBox |
private Matrix |
fontMatrix |
private java.awt.geom.AffineTransform |
fontMatrixTransform |
private java.util.Map<java.lang.Integer,java.lang.Float> |
glyphHeights |
private boolean |
isDamaged |
private boolean |
isEmbedded |
private static org.apache.commons.logging.Log |
LOG |
private FontBoxFont |
t1Font |
Constructor and Description |
---|
PDCIDFontType0(COSDictionary fontDictionary,
PDType0Font parent)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
codeToCID(int code)
Returns the CID for the given character code.
|
int |
codeToGID(int code)
Returns the GID for the given character code.
|
byte[] |
encode(int unicode)
Encodes the given Unicode code point for use in a PDF content stream.
|
private BoundingBox |
generateBoundingBox() |
private float |
getAverageCharacterWidth() |
float |
getAverageFontWidth()
This will get the average font width for all characters.
|
BoundingBox |
getBoundingBox()
Returns the font's bounding box.
|
CFFFont |
getCFFFont()
Returns the embedded CFF CIDFont, or null if the substitute is not a CFF font.
|
FontBoxFont |
getFontBoxFont()
Returns the embedded or substituted font.
|
Matrix |
getFontMatrix()
Returns the font matrix, which represents the transformation from glyph space to text space.
|
private java.lang.String |
getGlyphName(int code)
Returns the name of the glyph with the given character code.
|
float |
getHeight(int code)
Returns the height of the given character, in glyph space.
|
java.awt.geom.GeneralPath |
getPath(int code)
Returns the glyph path for the given character code in a PDF.
|
Type2CharString |
getType2CharString(int cid)
Returns the Type 2 charstring for the given CID, or null if the substituted font does not
contain Type 2 charstrings.
|
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 in a PDF.
|
boolean |
isDamaged()
Returns true if the embedded font file is damaged.
|
boolean |
isEmbedded()
Returns true if the font file is embedded in the PDF.
|
getBaseFont, getCIDSystemInfo, getCOSObject, getFontDescriptor, getName, getParent, getPositionVector, getVerticalDisplacementVectorY, getWidth, hasExplicitWidth, readCIDToGIDMap
private static final org.apache.commons.logging.Log LOG
private final CFFCIDFont cidFont
private final FontBoxFont t1Font
private final java.util.Map<java.lang.Integer,java.lang.Float> glyphHeights
private final boolean isEmbedded
private final boolean isDamaged
private java.lang.Float avgWidth
private Matrix fontMatrix
private final java.awt.geom.AffineTransform fontMatrixTransform
private BoundingBox fontBBox
private int[] cid2gid
public PDCIDFontType0(COSDictionary fontDictionary, PDType0Font parent) throws java.io.IOException
fontDictionary
- The font dictionary according to the PDF specification.parent
- The parent font.java.io.IOException
public final Matrix getFontMatrix()
PDFontLike
public BoundingBox getBoundingBox()
PDFontLike
private BoundingBox generateBoundingBox()
public CFFFont getCFFFont()
public FontBoxFont getFontBoxFont()
public Type2CharString getType2CharString(int cid) throws java.io.IOException
cid
- CIDjava.io.IOException
- if the charstring could not be readprivate java.lang.String getGlyphName(int code) throws java.io.IOException
java.io.IOException
public java.awt.geom.GeneralPath getPath(int code) throws java.io.IOException
PDVectorFont
code
- character code in a PDF. Not to be confused with unicode.java.io.IOException
- if the font could not be readpublic boolean hasGlyph(int code) throws java.io.IOException
PDVectorFont
code
- character code in a PDF. Not to be confused with unicode.java.io.IOException
public int codeToCID(int code)
public int codeToGID(int code)
PDCIDFont
public byte[] encode(int unicode)
PDCIDFont
This method is called when embedding text in PDFs and when filling in fields.
public float getWidthFromFont(int code) throws java.io.IOException
PDFontLike
code
- character codejava.io.IOException
- if the font could not be readpublic boolean isEmbedded()
PDFontLike
public boolean isDamaged()
PDFontLike
public float getHeight(int code) throws java.io.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. See the cyan rectangles in
the DrawPrintTextLocations.java example to see this in action.
code
- character codejava.io.IOException
public float getAverageFontWidth()
PDFontLike
getAverageFontWidth
in interface PDFontLike
getAverageFontWidth
in class PDCIDFont
private float getAverageCharacterWidth()