public abstract class PDFont extends Object implements org.apache.pdfbox.pdmodel.common.COSObjectable, org.apache.pdfbox.pdmodel.font.PDFontLike
Modifier and Type | Field and Description |
---|---|
protected static org.apache.pdfbox.util.Matrix |
DEFAULT_FONT_MATRIX |
protected org.apache.pdfbox.cos.COSDictionary |
dict |
Modifier | Constructor and Description |
---|---|
protected |
PDFont(org.apache.pdfbox.cos.COSDictionary fontDictionary)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
addToSubset(int codePoint)
Adds the given Unicode point to the subset.
|
byte[] |
encode(Character character)
Encodes the given character for use in a PDF content stream.
|
abstract byte[] |
encode(int unicode)
Encodes the given Unicode code point for use in a PDF content stream.
|
byte[] |
encode(String text)
Encodes the given string for use in a PDF content stream.
|
boolean |
equals(Object other) |
float |
getAverageFontWidth()
This will get the average font width for all characters.
|
float |
getCharacterWidth(Character character)
Returns the width of the given Unicode character.
|
org.apache.pdfbox.cos.COSDictionary |
getCOSObject() |
org.apache.pdfbox.util.Vector |
getDisplacement(int code)
Returns the displacement vector (w0, w1) in text space, for the given character.
|
org.apache.pdfbox.pdmodel.font.PDFontDescriptor |
getFontDescriptor() |
org.apache.pdfbox.util.Matrix |
getFontMatrix() |
org.apache.pdfbox.util.Vector |
getPositionVector(int code) |
float |
getRealWidth(int code,
float size) |
float |
getSpaceWidth()
Determines the width of the space character.
|
protected org.apache.fontbox.afm.FontMetrics |
getStandard14AFM()
Returns the AFM if this is a Standard 14 font.
|
protected abstract float |
getStandard14Width(int code)
Returns the glyph width from the AFM if this is a Standard 14 font.
|
float |
getStringWidth(String text)
Returns the width of the given Unicode string.
|
String |
getSubType()
This will get the subtype of font.
|
protected org.apache.fontbox.cmap.CMap |
getToUnicodeCMap()
Get the /ToUnicode CMap.
|
String |
getType()
This will always return "Font" for fonts.
|
float |
getWidth(int code) |
protected List<Float> |
getWidths()
The widths of the characters.
|
int |
hashCode() |
boolean |
isStandard14()
Returns true if this font is one of the "Standard 14" fonts and receives special handling.
|
abstract boolean |
isVertical()
Returns true if the font uses vertical writing mode.
|
protected org.apache.fontbox.cmap.CMap |
readCMap(org.apache.pdfbox.cos.COSBase base)
Reads a CMap given a COS Stream or Name.
|
abstract int |
readCode(InputStream in)
Reads a character code from a content stream string.
|
protected void |
setFontDescriptor(org.apache.pdfbox.pdmodel.font.PDFontDescriptor fontDescriptor)
Sets the font descriptor when embedding a font.
|
abstract void |
subset()
Replaces this font with a subset containing only the given Unicode characters.
|
String |
toString() |
String |
toUnicode(int code)
Returns the Unicode character sequence which corresponds to the given character code.
|
String |
toUnicode(int code,
org.apache.pdfbox.pdmodel.font.encoding.GlyphList customGlyphList)
Returns the Unicode character sequence which corresponds to the given character code.
|
abstract boolean |
willBeSubset()
Returns true if this font will be subset when embedded.
|
protected static final org.apache.pdfbox.util.Matrix DEFAULT_FONT_MATRIX
protected final org.apache.pdfbox.cos.COSDictionary dict
protected PDFont(org.apache.pdfbox.cos.COSDictionary fontDictionary)
fontDictionary
- Font dictionary.protected final org.apache.fontbox.afm.FontMetrics getStandard14AFM()
public org.apache.pdfbox.pdmodel.font.PDFontDescriptor getFontDescriptor()
getFontDescriptor
in interface org.apache.pdfbox.pdmodel.font.PDFontLike
protected final void setFontDescriptor(org.apache.pdfbox.pdmodel.font.PDFontDescriptor fontDescriptor)
fontDescriptor
- font descriptor of the embedded fontprotected final org.apache.fontbox.cmap.CMap readCMap(org.apache.pdfbox.cos.COSBase base) throws IOException
base
- COSName or COSStreamIOException
- if the CMap could not be readpublic org.apache.pdfbox.cos.COSDictionary getCOSObject()
getCOSObject
in interface org.apache.pdfbox.pdmodel.common.COSObjectable
public org.apache.pdfbox.util.Vector getPositionVector(int code)
getPositionVector
in interface org.apache.pdfbox.pdmodel.font.PDFontLike
public org.apache.pdfbox.util.Vector getDisplacement(int code) throws IOException
code
- character codeIOException
- if the data could not be readpublic float getRealWidth(int code, float size) throws IOException
IOException
public float getWidth(int code) throws IOException
getWidth
in interface org.apache.pdfbox.pdmodel.font.PDFontLike
IOException
protected abstract float getStandard14Width(int code)
code
- character codepublic final byte[] encode(String text) throws IOException
text
- Any Unicode text.IOException
- If the text could not be encoded.IllegalArgumentException
- if a character isn't supported by the font.public final byte[] encode(Character character) throws IOException
character
- Any Unicode character.IOException
- If the text could not be encoded.IllegalArgumentException
- if a character isn't supported by the font.public abstract byte[] encode(int unicode) throws IOException
This method is called when embedding text in PDFs and when filling in fields.
unicode
- Unicode code point.IOException
- If the text could not be encoded.IllegalArgumentException
- if a character isn't supported by the font.public float getStringWidth(String text) throws IOException
text
- The text to get the width of.IOException
- If there is an error getting the width information.IllegalArgumentException
- if a character isn't supported by the font.public float getCharacterWidth(Character character) throws IOException
character
- The character to get the width of.IOException
- If there is an error getting the width information.IllegalArgumentException
- if a character isn't supported by the font.public float getAverageFontWidth()
getAverageFontWidth
in interface org.apache.pdfbox.pdmodel.font.PDFontLike
public abstract int readCode(InputStream in) throws IOException
in
- string streamIOException
- if the CMap or stream cannot be readpublic String toUnicode(int code, org.apache.pdfbox.pdmodel.font.encoding.GlyphList customGlyphList)
code
- character codecustomGlyphList
- a custom glyph list to use instead of the Adobe Glyph Listpublic String toUnicode(int code)
code
- character codepublic String getType()
public String getSubType()
protected final List<Float> getWidths()
public org.apache.pdfbox.util.Matrix getFontMatrix()
getFontMatrix
in interface org.apache.pdfbox.pdmodel.font.PDFontLike
public float getSpaceWidth()
public abstract boolean isVertical()
public boolean isStandard14()
public abstract void addToSubset(int codePoint)
codePoint
- Unicode code pointpublic abstract void subset() throws IOException
IOException
- if the subset could not be writtenpublic abstract boolean willBeSubset()
protected org.apache.fontbox.cmap.CMap getToUnicodeCMap()
Copyright © 2024. All rights reserved.