Class PDCIDFontType0
- java.lang.Object
-
- com.tom_roush.pdfbox.pdmodel.font.PDCIDFont
-
- com.tom_roush.pdfbox.pdmodel.font.PDCIDFontType0
-
- All Implemented Interfaces:
COSObjectable,PDFontLike,PDVectorFont
public class PDCIDFontType0 extends PDCIDFont
Type 0 CIDFont (CFF).
-
-
Constructor Summary
Constructors Constructor Description PDCIDFontType0(COSDictionary fontDictionary, PDType0Font parent)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcodeToCID(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.floatgetAverageFontWidth()This will get the average font width for all characters.BoundingBoxgetBoundingBox()Returns the font's bounding box.CFFFontgetCFFFont()Returns the embedded CFF CIDFont, or null if the substitute is not a CFF font.FontBoxFontgetFontBoxFont()Returns the embedded or substituted font.MatrixgetFontMatrix()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.android.graphics.PathgetPath(int code)Returns the glyph path for the given character code.Type2CharStringgetType2CharString(int cid)Returns the Type 2 charstring for the given CID, or null if the substituted font does not contain Type 2 charstrings.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.booleanisDamaged()Returns true if the embedded font file is damaged.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 class com.tom_roush.pdfbox.pdmodel.font.PDCIDFont
getBaseFont, getCIDSystemInfo, getCOSObject, getFontDescriptor, getName, getParent, getPositionVector, getVerticalDisplacementVectorY, getWidth
-
-
-
-
Constructor Detail
-
PDCIDFontType0
public PDCIDFontType0(COSDictionary fontDictionary, PDType0Font parent) throws IOException
Constructor.- Parameters:
fontDictionary- The font dictionary according to the PDF specification.parent- The parent font.- Throws:
IOException
-
-
Method Detail
-
getFontMatrix
public final Matrix getFontMatrix()
Description copied from interface:PDFontLikeReturns the font matrix, which represents the transformation from glyph space to text space.- Specified by:
getFontMatrixin interfacePDFontLike- Specified by:
getFontMatrixin classPDCIDFont
-
getBoundingBox
public BoundingBox getBoundingBox()
Description copied from interface:PDFontLikeReturns the font's bounding box.- Specified by:
getBoundingBoxin interfacePDFontLike- Specified by:
getBoundingBoxin classPDCIDFont
-
getCFFFont
public CFFFont getCFFFont()
Returns the embedded CFF CIDFont, or null if the substitute is not a CFF font.
-
getFontBoxFont
public FontBoxFont getFontBoxFont()
Returns the embedded or substituted font.
-
getType2CharString
public Type2CharString getType2CharString(int cid) throws IOException
Returns the Type 2 charstring for the given CID, or null if the substituted font does not contain Type 2 charstrings.- Parameters:
cid- CID- Throws:
IOException- if the charstring could not be read
-
getPath
public android.graphics.Path getPath(int code) throws IOExceptionDescription copied from interface:PDVectorFontReturns the glyph path for the given character code.- Parameters:
code- character code- Throws:
IOException- if the font could not be read
-
hasGlyph
public boolean hasGlyph(int code) throws IOExceptionDescription copied from interface:PDVectorFontReturns true if this font contains a glyph for the given character code.- Parameters:
code- character code- Throws:
IOException
-
codeToCID
public int codeToCID(int code)
Returns the CID for the given character code. If not found then CID 0 is returned.
-
codeToGID
public int codeToGID(int code)
Description copied from class:PDCIDFontReturns the GID for the given character code.
-
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.
-
getWidthFromFont
public float getWidthFromFont(int code) throws IOExceptionDescription copied from interface:PDFontLikeReturns the width of a glyph in the embedded font file.- Specified by:
getWidthFromFontin interfacePDFontLike- Specified by:
getWidthFromFontin classPDCIDFont- Parameters:
code- character code- Returns:
- width in glyph space
- Throws:
IOException- if the font could not be read
-
isEmbedded
public boolean isEmbedded()
Description copied from interface:PDFontLikeReturns true if the font file is embedded in the PDF.- Specified by:
isEmbeddedin interfacePDFontLike- Specified by:
isEmbeddedin classPDCIDFont
-
isDamaged
public boolean isDamaged()
Description copied from interface:PDFontLikeReturns true if the embedded font file is damaged.
-
getHeight
public 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- Specified by:
getHeightin classPDCIDFont- Parameters:
code- character code- Throws:
IOException
-
getAverageFontWidth
public float getAverageFontWidth()
Description copied from interface:PDFontLikeThis will get the average font width for all characters.- Specified by:
getAverageFontWidthin interfacePDFontLike- Overrides:
getAverageFontWidthin classPDCIDFont- Returns:
- The width is in 1000 unit of text space, ie 333 or 777
-
-