Package org.apache.pdfbox.pdmodel.font
Class PDType1CFont
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.font.PDFont
-
- org.apache.pdfbox.pdmodel.font.PDSimpleFont
-
- org.apache.pdfbox.pdmodel.font.PDType1CFont
-
- All Implemented Interfaces:
COSObjectable
public class PDType1CFont extends PDSimpleFont
This class represents a CFF/Type2 Font (aka Type1C Font).- Author:
- Villu Ruusmann
-
-
Field Summary
-
Fields inherited from class org.apache.pdfbox.pdmodel.font.PDFont
cmap, cmapObjects, font, fontMatrix, resourceRootCMAP, toUnicodeCmap
-
-
Constructor Summary
Constructors Constructor Description PDType1CFont(COSDictionary fontDictionary)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Calling this will release all cached information.java.lang.String
encode(byte[] bytes, int offset, int length)
This will perform the encoding of a character if needed.int
encodeToCID(byte[] bytes, int offset, int length)
float
getAverageFontWidth()
This will get the average font width for all characters.java.awt.Font
getawtFont()
Looks up, creates, returns the AWT Font.PDRectangle
getFontBoundingBox()
This will get the fonts bounding box.float
getFontHeight(byte[] bytes, int offset, int length)
This will get the font height for a character.PDMatrix
getFontMatrix()
This will get the matrix that is used to transform glyph space to text space.float
getFontWidth(byte[] bytes, int offset, int length)
This will get the font width for a character.float
getStringWidth(java.lang.String string)
This will get the width of this string for this font.-
Methods inherited from class org.apache.pdfbox.pdmodel.font.PDSimpleFont
determineEncoding, drawString, getSpaceWidth, getToUnicode, isFontSubstituted, setIsFontSubstituted, setToUnicode, writeFont
-
Methods inherited from class org.apache.pdfbox.pdmodel.font.PDFont
clearResources, cmapEncoding, drawString, equals, getAFM, getAverageFontWidthFromAFMFile, getBaseFont, getCodeFromArray, getCOSObject, getEncoding, getFirstChar, getFontDescriptor, getFontEncoding, getFontWidth, getFontWidthFromAFMFile, getLastChar, getStringFromArray, getSubType, getToUnicodeCMap, getType, getWidths, hashCode, hasToUnicode, isSymbolicFont, isType0Font, isType1Font, isType3Font, parseCmap, setBaseFont, setEncoding, setFirstChar, setFontDescriptor, setFontEncoding, setHasToUnicode, setLastChar, setWidths
-
-
-
-
Constructor Detail
-
PDType1CFont
public PDType1CFont(COSDictionary fontDictionary) throws java.io.IOException
Constructor.- Parameters:
fontDictionary
- the corresponding dictionary- Throws:
java.io.IOException
-
-
Method Detail
-
encode
public java.lang.String encode(byte[] bytes, int offset, int length) throws java.io.IOException
This will perform the encoding of a character if needed.
-
encodeToCID
public int encodeToCID(byte[] bytes, int offset, int length)
- Overrides:
encodeToCID
in classPDFont
-
getFontWidth
public float getFontWidth(byte[] bytes, int offset, int length) throws java.io.IOException
This will get the font width for a character.- Overrides:
getFontWidth
in classPDSimpleFont
- Parameters:
bytes
- The character code to get the width for.offset
- The offset into the array.length
- The length of the data.- Returns:
- The width is in 1000 unit of text space, ie 333 or 777
- Throws:
java.io.IOException
- If an error occurs while parsing.
-
getFontHeight
public float getFontHeight(byte[] bytes, int offset, int length) throws java.io.IOException
This will get the font height for a character.- Overrides:
getFontHeight
in classPDSimpleFont
- Parameters:
bytes
- The character code to get the width for.offset
- The offset into the array.length
- The length of the data.- Returns:
- The width is in 1000 unit of text space, ie 333 or 777
- Throws:
java.io.IOException
- If an error occurs while parsing.
-
getStringWidth
public float getStringWidth(java.lang.String string) throws java.io.IOException
This will get the width of this string for this font.- Overrides:
getStringWidth
in classPDFont
- Parameters:
string
- The string to get the width of.- Returns:
- The width of the string in 1000 units of text space, ie 333 567...
- Throws:
java.io.IOException
- If there is an error getting the width information.
-
getAverageFontWidth
public float getAverageFontWidth() throws java.io.IOException
This will get the average font width for all characters.- Overrides:
getAverageFontWidth
in classPDSimpleFont
- Returns:
- The width is in 1000 unit of text space, ie 333 or 777
- Throws:
java.io.IOException
- If an error occurs while parsing.
-
getFontBoundingBox
public PDRectangle getFontBoundingBox() throws java.io.IOException
This will get the fonts bounding box.- Overrides:
getFontBoundingBox
in classPDSimpleFont
- Returns:
- The fonts bouding box.
- Throws:
java.io.IOException
- If there is an error getting the bounding box.
-
getFontMatrix
public PDMatrix getFontMatrix()
This will get the matrix that is used to transform glyph space to text space. By default there are 1000 glyph units to 1 text space unit, but type3 fonts can use any value. Note:If this is a type3 font then it can be modified via the PDType3Font.setFontMatrix, otherwise this is a read-only property.- Overrides:
getFontMatrix
in classPDFont
- Returns:
- The matrix to transform from glyph space to text space.
-
getawtFont
public java.awt.Font getawtFont() throws java.io.IOException
Looks up, creates, returns the AWT Font.- Overrides:
getawtFont
in classPDSimpleFont
- Returns:
- returns the awt font to bes used for rendering
- Throws:
java.io.IOException
- if something went wrong.
-
-