Class PDCIDFontType2
java.lang.Object
org.apache.pdfbox.pdmodel.font.PDCIDFont
org.apache.pdfbox.pdmodel.font.PDCIDFontType2
- All Implemented Interfaces:
COSObjectable, PDFontLike, PDVectorFont
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionPDCIDFontType2(COSDictionary fontDictionary, PDType0Font parent) Constructor.PDCIDFontType2(COSDictionary fontDictionary, PDType0Font parent, org.apache.fontbox.ttf.TrueTypeFont trueTypeFont) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionintcodeToCID(int code) Returns the CID for the given character code.intcodeToGID(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.org.apache.fontbox.util.BoundingBoxReturns the font's bounding box.Returns the font matrix, which represents the transformation from glyph space to text space.floatgetHeight(int code) Returns the height of the given character, in glyph space.getPath(int code) Returns the glyph path for the given character code in a PDF.org.apache.fontbox.ttf.TrueTypeFontReturns the embedded or substituted TrueType font.floatgetWidthFromFont(int code) Returns the width of a glyph in the embedded font file.booleanhasGlyph(int code) Returns true if this font contains a glyph for the given character code in a PDF.booleanReturns true if the embedded font file is damaged.booleanReturns true if the font file is embedded in the PDF.Methods inherited from class PDCIDFont
getAverageFontWidth, getBaseFont, getCIDSystemInfo, getCOSObject, getFontDescriptor, getName, getParent, getPositionVector, getVerticalDisplacementVectorY, getWidth, hasExplicitWidth
-
Constructor Details
-
PDCIDFontType2
Constructor.- Parameters:
fontDictionary- The font dictionary according to the PDF specification.parent- The parent font.- Throws:
IOException
-
PDCIDFontType2
public PDCIDFontType2(COSDictionary fontDictionary, PDType0Font parent, org.apache.fontbox.ttf.TrueTypeFont trueTypeFont) throws IOException Constructor.- Parameters:
fontDictionary- The font dictionary according to the PDF specification.parent- The parent font.trueTypeFont- The true type font used to create the parent font- Throws:
IOException
-
-
Method Details
-
getFontMatrix
Description copied from interface:PDFontLikeReturns the font matrix, which represents the transformation from glyph space to text space. -
getBoundingBox
-
codeToCID
-
codeToGID
Returns the GID for the given character code.- Specified by:
codeToGIDin classPDCIDFont- Parameters:
code- character code- Returns:
- GID
- Throws:
IOException
-
getHeight
Description copied from interface:PDFontLikeReturns the height of the given character, in glyph space. This can be expensive to calculate. Results are only approximate.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.- Parameters:
code- character code- Throws:
IOException
-
getWidthFromFont
Description copied from interface:PDFontLikeReturns the width of a glyph in the embedded font file.- Parameters:
code- character code- Returns:
- width in glyph space
- Throws:
IOException- if the font could not be read
-
encode
public byte[] encode(int unicode) Description copied from class:PDCIDFontEncodes 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.
-
isEmbedded
public boolean isEmbedded()Description copied from interface:PDFontLikeReturns true if the font file is embedded in the PDF. -
isDamaged
public boolean isDamaged()Description copied from interface:PDFontLikeReturns true if the embedded font file is damaged. -
getTrueTypeFont
public org.apache.fontbox.ttf.TrueTypeFont getTrueTypeFont()Returns the embedded or substituted TrueType font. May be an OpenType font if the font is not embedded. -
getPath
Description copied from interface:PDVectorFontReturns the glyph path for the given character code in a PDF.- Parameters:
code- character code in a PDF. Not to be confused with unicode.- Throws:
IOException- if the font could not be read
-
hasGlyph
Description copied from interface:PDVectorFontReturns true if this font contains a glyph for the given character code in a PDF.- Parameters:
code- character code in a PDF. Not to be confused with unicode.- Throws:
IOException
-