public abstract class PDCIDFont extends java.lang.Object implements COSObjectable, PDFontLike, PDVectorFont
It is not usually necessary to use this class directly, prefer PDType0Font
.
Modifier and Type | Field and Description |
---|---|
private float |
averageWidth |
private float |
defaultWidth |
protected COSDictionary |
dict |
private float[] |
dw2 |
private PDFontDescriptor |
fontDescriptor |
protected PDType0Font |
parent |
private java.util.Map<java.lang.Integer,Vector> |
positionVectors |
private java.util.Map<java.lang.Integer,java.lang.Float> |
verticalDisplacementY |
private java.util.Map<java.lang.Integer,java.lang.Float> |
widths |
Constructor and Description |
---|
PDCIDFont(COSDictionary fontDictionary,
PDType0Font parent)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
abstract int |
codeToCID(int code)
Returns the CID for the given character code.
|
abstract int |
codeToGID(int code)
Returns the GID for the given character code.
|
protected abstract 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.
|
java.lang.String |
getBaseFont()
The PostScript name of the font.
|
PDCIDSystemInfo |
getCIDSystemInfo()
Returns the CIDSystemInfo, or null if it is missing (which isn't allowed but could happen).
|
COSDictionary |
getCOSObject()
Convert this standard java object to a COS object.
|
private Vector |
getDefaultPositionVector(int cid)
Returns the default position vector (v).
|
private float |
getDefaultWidth()
This will get the default width.
|
PDFontDescriptor |
getFontDescriptor()
Returns the font descriptor, may be null.
|
java.lang.String |
getName()
Returns the name of this font, either the PostScript "BaseName" or the Type 3 "Name".
|
PDType0Font |
getParent()
Returns the Type 0 font which is the parent of this font.
|
Vector |
getPositionVector(int code)
Returns the position vector (v), in text space, for the given character.
|
float |
getVerticalDisplacementVectorY(int code)
Returns the y-component of the vertical displacement vector (w1).
|
float |
getWidth(int code)
Returns the advance width of the given character, in glyph space.
|
private float |
getWidthForCID(int cid) |
boolean |
hasExplicitWidth(int code)
Returns true if the Font dictionary specifies an explicit width for the given glyph.
|
(package private) int[] |
readCIDToGIDMap() |
private void |
readVerticalDisplacements() |
private void |
readWidths() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getBoundingBox, getFontMatrix, getHeight, getWidthFromFont, isDamaged, isEmbedded
getPath, hasGlyph
protected final PDType0Font parent
private java.util.Map<java.lang.Integer,java.lang.Float> widths
private float defaultWidth
private float averageWidth
private final java.util.Map<java.lang.Integer,java.lang.Float> verticalDisplacementY
private final java.util.Map<java.lang.Integer,Vector> positionVectors
private float[] dw2
protected final COSDictionary dict
private PDFontDescriptor fontDescriptor
PDCIDFont(COSDictionary fontDictionary, PDType0Font parent)
fontDictionary
- The font dictionary according to the PDF specification.private void readWidths()
private void readVerticalDisplacements()
public COSDictionary getCOSObject()
COSObjectable
getCOSObject
in interface COSObjectable
public java.lang.String getBaseFont()
public java.lang.String getName()
PDFontLike
getName
in interface PDFontLike
public PDFontDescriptor getFontDescriptor()
PDFontLike
getFontDescriptor
in interface PDFontLike
public final PDType0Font getParent()
private float getDefaultWidth()
private Vector getDefaultPositionVector(int cid)
cid
- CIDprivate float getWidthForCID(int cid)
public boolean hasExplicitWidth(int code) throws java.io.IOException
PDFontLike
hasExplicitWidth
in interface PDFontLike
code
- character codejava.io.IOException
- if the font could not be readpublic Vector getPositionVector(int code)
PDFontLike
getPositionVector
in interface PDFontLike
code
- character codepublic float getVerticalDisplacementVectorY(int code)
code
- character codepublic float getWidth(int code) throws java.io.IOException
PDFontLike
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 instead. See the cyan rectangles in the DrawPrintTextLocations.java example to see this in action.
getWidth
in interface PDFontLike
code
- character codejava.io.IOException
public float getAverageFontWidth()
PDFontLike
getAverageFontWidth
in interface PDFontLike
public PDCIDSystemInfo getCIDSystemInfo()
public abstract int codeToCID(int code)
code
- character codepublic abstract int codeToGID(int code) throws java.io.IOException
code
- character codejava.io.IOException
protected abstract byte[] encode(int unicode) throws java.io.IOException
This method is called when embedding text in PDFs and when filling in fields.
unicode
- Unicode code point.java.io.IOException
- If the text could not be encoded.final int[] readCIDToGIDMap() throws java.io.IOException
java.io.IOException