Class PDCIDFont
- java.lang.Object
-
- com.tom_roush.pdfbox.pdmodel.font.PDCIDFont
-
- All Implemented Interfaces:
COSObjectable,PDFontLike,PDVectorFont
- Direct Known Subclasses:
PDCIDFontType0,PDCIDFontType2
public abstract class PDCIDFont extends Object implements COSObjectable, PDFontLike, PDVectorFont
A CIDFont. A CIDFont is a PDF object that contains information about a CIDFont program. Although its Type value is Font, a CIDFont is not actually a font.It is not usually necessary to use this class directly, prefer
PDType0Font.
-
-
Field Summary
Fields Modifier and Type Field Description protected COSDictionarydictprotected PDType0Fontparent
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract intcodeToCID(int code)Returns the CID for the given character code.abstract intcodeToGID(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.floatgetAverageFontWidth()This will get the average font width for all characters.StringgetBaseFont()The PostScript name of the font.abstract BoundingBoxgetBoundingBox()Returns the font's bounding box.PDCIDSystemInfogetCIDSystemInfo()Returns the CIDSystemInfo, or null if it is missing (which isn't allowed but could happen).COSDictionarygetCOSObject()Convert this standard java object to a COS object.PDFontDescriptorgetFontDescriptor()Returns the font descriptor, may be null.abstract MatrixgetFontMatrix()Returns the font matrix, which represents the transformation from glyph space to text space.abstract floatgetHeight(int code)Returns the height of the given character, in glyph space.StringgetName()Returns the name of this font, either the PostScript "BaseName" or the Type 3 "Name".PDType0FontgetParent()Returns the Type 0 font which is the parent of this font.VectorgetPositionVector(int code)Returns the position vector (v), in text space, for the given character.floatgetVerticalDisplacementVectorY(int code)Returns the y-component of the vertical displacement vector (w1).floatgetWidth(int code)Returns the advance width of the given character, in glyph space.abstract floatgetWidthFromFont(int code)Returns the width of a glyph in the embedded font file.abstract booleanisEmbedded()Returns true if the font file is embedded in the PDF.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.tom_roush.pdfbox.pdmodel.font.PDFontLike
isDamaged
-
Methods inherited from interface com.tom_roush.pdfbox.pdmodel.font.PDVectorFont
getPath, hasGlyph
-
-
-
-
Field Detail
-
parent
protected final PDType0Font parent
-
dict
protected final COSDictionary dict
-
-
Method Detail
-
getCOSObject
public COSDictionary getCOSObject()
Description copied from interface:COSObjectableConvert this standard java object to a COS object.- Specified by:
getCOSObjectin interfaceCOSObjectable- Returns:
- The cos object that matches this Java object.
-
getBaseFont
public String getBaseFont()
The PostScript name of the font.- Returns:
- The postscript name of the font.
-
getName
public String getName()
Description copied from interface:PDFontLikeReturns the name of this font, either the PostScript "BaseName" or the Type 3 "Name".- Specified by:
getNamein interfacePDFontLike
-
getFontDescriptor
public PDFontDescriptor getFontDescriptor()
Description copied from interface:PDFontLikeReturns the font descriptor, may be null.- Specified by:
getFontDescriptorin interfacePDFontLike
-
getFontMatrix
public abstract Matrix getFontMatrix()
Description copied from interface:PDFontLikeReturns the font matrix, which represents the transformation from glyph space to text space.- Specified by:
getFontMatrixin interfacePDFontLike
-
getParent
public final PDType0Font getParent()
Returns the Type 0 font which is the parent of this font.- Returns:
- parent Type 0 font
-
getBoundingBox
public abstract BoundingBox getBoundingBox() throws IOException
Description copied from interface:PDFontLikeReturns the font's bounding box.- Specified by:
getBoundingBoxin interfacePDFontLike- Throws:
IOException
-
getPositionVector
public Vector getPositionVector(int code)
Description copied from interface:PDFontLikeReturns the position vector (v), in text space, for the given character. This represents the position of vertical origin relative to horizontal origin, for horizontal writing it will always be (0, 0). For vertical writing both x and y are set.- Specified by:
getPositionVectorin interfacePDFontLike- Parameters:
code- character code- Returns:
- position vector
-
getVerticalDisplacementVectorY
public float getVerticalDisplacementVectorY(int code)
Returns the y-component of the vertical displacement vector (w1).- Parameters:
code- character code- Returns:
- w1y
-
getHeight
public abstract float getHeight(int code) throws IOExceptionDescription copied from interface:PDFontLikeReturns the height of the given character, in glyph space. This can be expensive to calculate. Results are only approximate.- Specified by:
getHeightin interfacePDFontLike- Parameters:
code- character code- Throws:
IOException
-
getWidth
public float getWidth(int code) throws IOExceptionDescription copied from interface:PDFontLikeReturns the advance width of the given character, in glyph space.- Specified by:
getWidthin interfacePDFontLike- Parameters:
code- character code- Throws:
IOException
-
getWidthFromFont
public abstract float getWidthFromFont(int code) throws IOExceptionDescription copied from interface:PDFontLikeReturns the width of a glyph in the embedded font file.- Specified by:
getWidthFromFontin interfacePDFontLike- Parameters:
code- character code- Returns:
- width in glyph space
- Throws:
IOException- if the font could not be read
-
isEmbedded
public abstract boolean isEmbedded()
Description copied from interface:PDFontLikeReturns true if the font file is embedded in the PDF.- Specified by:
isEmbeddedin interfacePDFontLike
-
getAverageFontWidth
public float getAverageFontWidth()
Description copied from interface:PDFontLikeThis will get the average font width for all characters.- Specified by:
getAverageFontWidthin interfacePDFontLike- Returns:
- The width is in 1000 unit of text space, ie 333 or 777
-
getCIDSystemInfo
public PDCIDSystemInfo getCIDSystemInfo()
Returns the CIDSystemInfo, or null if it is missing (which isn't allowed but could happen).
-
codeToCID
public abstract int codeToCID(int code)
Returns the CID for the given character code. If not found then CID 0 is returned.- Parameters:
code- character code- Returns:
- CID
-
codeToGID
public abstract int codeToGID(int code) throws IOExceptionReturns the GID for the given character code.- Parameters:
code- character code- Returns:
- GID
- Throws:
IOException
-
encode
protected abstract byte[] encode(int unicode) throws IOExceptionEncodes the given Unicode code point for use in a PDF content stream. Content streams use a multi-byte encoding with 1 to 4 bytes.This method is called when embedding text in PDFs and when filling in fields.
- Parameters:
unicode- Unicode code point.- Returns:
- Array of 1 to 4 PDF content stream bytes.
- Throws:
IOException- If the text could not be encoded.
-
-