Package org.apache.pdfbox.pdmodel.font
Class PDType0Font
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.font.PDFont
-
- org.apache.pdfbox.pdmodel.font.PDSimpleFont
-
- org.apache.pdfbox.pdmodel.font.PDType0Font
-
- All Implemented Interfaces:
COSObjectable
public class PDType0Font extends PDSimpleFont
This is implementation of the Type0 Font. See PDFBOX-605 for the related improvement issue.- Version:
- $Revision: 1.9 $
- Author:
- Ben Litchfield
-
-
Field Summary
-
Fields inherited from class org.apache.pdfbox.pdmodel.font.PDFont
cmap, cmapObjects, font, fontMatrix, resourceRootCMAP, toUnicodeCmap
-
-
Constructor Summary
Constructors Constructor Description PDType0Font()
Constructor.PDType0Font(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[] c, int offset, int length)
This will perform the encoding of a character if needed.float
getAverageFontWidth()
This will get the average font width for all characters.java.awt.Font
getawtFont()
Looks up, creates, returns the AWT Font.PDFont
getDescendantFont()
Provides the descendant font.PDRectangle
getFontBoundingBox()
This will get the fonts bounding box.float
getFontHeight(byte[] c, int offset, int length)
This will get the font height for a character.float
getFontWidth(byte[] c, int offset, int length)
This will get the font width for a character.float
getFontWidth(int charCode)
Determines the width of the given character.-
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, encodeToCID, equals, getAFM, getAverageFontWidthFromAFMFile, getBaseFont, getCodeFromArray, getCOSObject, getEncoding, getFirstChar, getFontDescriptor, getFontEncoding, getFontMatrix, getFontWidthFromAFMFile, getLastChar, getStringFromArray, getStringWidth, getSubType, getToUnicodeCMap, getType, getWidths, hashCode, hasToUnicode, isSymbolicFont, isType0Font, isType1Font, isType3Font, parseCmap, setBaseFont, setEncoding, setFirstChar, setFontDescriptor, setFontEncoding, setHasToUnicode, setLastChar, setWidths
-
-
-
-
Constructor Detail
-
PDType0Font
public PDType0Font()
Constructor.
-
PDType0Font
public PDType0Font(COSDictionary fontDictionary)
Constructor.- Parameters:
fontDictionary
- The font dictionary according to the PDF specification.
-
-
Method Detail
-
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.
-
getFontBoundingBox
public PDRectangle getFontBoundingBox() throws java.io.IOException
This will get the fonts bounding box.- Overrides:
getFontBoundingBox
in classPDSimpleFont
- Returns:
- The fonts bounding box.
- Throws:
java.io.IOException
- If there is an error getting the bounding box.
-
getFontWidth
public float getFontWidth(byte[] c, int offset, int length) throws java.io.IOException
This will get the font width for a character.- Overrides:
getFontWidth
in classPDSimpleFont
- Parameters:
c
- 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[] c, int offset, int length) throws java.io.IOException
This will get the font height for a character.- Overrides:
getFontHeight
in classPDSimpleFont
- Parameters:
c
- The character code to get the height 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.
-
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.
-
getFontWidth
public float getFontWidth(int charCode)
Determines the width of the given character.- Overrides:
getFontWidth
in classPDFont
- Parameters:
charCode
- the code of the given character- Returns:
- the width of the character
-
encode
public java.lang.String encode(byte[] c, int offset, int length) throws java.io.IOException
Description copied from class:PDFont
This will perform the encoding of a character if needed.
-
getDescendantFont
public PDFont getDescendantFont()
Provides the descendant font.- Returns:
- the descendant font.
-
-