Package org.apache.pdfbox.pdmodel.font
Class PDCIDFont
java.lang.Object
org.apache.pdfbox.pdmodel.font.PDCIDFont
- All Implemented Interfaces:
COSObjectable
,PDFontLike
,PDVectorFont
- Direct Known Subclasses:
PDCIDFontType0
,PDCIDFontType2
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
.
- Author:
- Ben Litchfield
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionabstract 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
This will get the average font width for all characters.The PostScript name of the font.Returns the CIDSystemInfo, or null if it is missing (which isn't allowed but could happen).Convert this standard java object to a COS object.Returns the font descriptor, may be null.getName()
Returns the name of this font, either the PostScript "BaseName" or the Type 3 "Name".final PDType0Font
Returns the Type 0 font which is the parent of this font.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.boolean
hasExplicitWidth
(int code) Returns true if the Font dictionary specifies an explicit width for the given glyph.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.pdfbox.pdmodel.font.PDFontLike
getBoundingBox, getFontMatrix, getHeight, getWidthFromFont, isDamaged, isEmbedded
Methods inherited from interface org.apache.pdfbox.pdmodel.font.PDVectorFont
getPath, hasGlyph
-
Field Details
-
parent
-
dict
-
-
Method Details
-
getCOSObject
Description copied from interface:COSObjectable
Convert this standard java object to a COS object.- Specified by:
getCOSObject
in interfaceCOSObjectable
- Returns:
- The cos object that matches this Java object.
-
getBaseFont
The PostScript name of the font.- Returns:
- The postscript name of the font.
-
getName
Description copied from interface:PDFontLike
Returns the name of this font, either the PostScript "BaseName" or the Type 3 "Name".- Specified by:
getName
in interfacePDFontLike
-
getFontDescriptor
Description copied from interface:PDFontLike
Returns the font descriptor, may be null.- Specified by:
getFontDescriptor
in interfacePDFontLike
-
getParent
Returns the Type 0 font which is the parent of this font.- Returns:
- parent Type 0 font
-
hasExplicitWidth
Description copied from interface:PDFontLike
Returns true if the Font dictionary specifies an explicit width for the given glyph. This includes Width, W but not default widths entries.- Specified by:
hasExplicitWidth
in interfacePDFontLike
- Parameters:
code
- character code- Throws:
IOException
- if the font could not be read
-
getPositionVector
Description copied from interface:PDFontLike
Returns 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:
getPositionVector
in 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
-
getWidth
Description copied from interface:PDFontLike
Returns the advance width of the given character, in glyph space.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.
- Specified by:
getWidth
in interfacePDFontLike
- Parameters:
code
- character code- Throws:
IOException
-
getAverageFontWidth
public float getAverageFontWidth()Description copied from interface:PDFontLike
This will get the average font width for all characters.- Specified by:
getAverageFontWidth
in interfacePDFontLike
- Returns:
- The width is in 1000 unit of text space, ie 333 or 777
-
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
Returns the GID for the given character code.- Parameters:
code
- character code- Returns:
- GID
- Throws:
IOException
-
encode
Encodes 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.
-