COSObjectable
, PDFontLike
PDSimpleFont
, PDType0Font
public abstract class PDFont extends java.lang.Object implements COSObjectable, PDFontLike
Modifier and Type | Field | Description |
---|---|---|
protected static Matrix |
DEFAULT_FONT_MATRIX |
|
protected COSDictionary |
dict |
Modifier | Constructor | Description |
---|---|---|
protected |
PDFont(COSDictionary fontDictionary) |
Constructor.
|
Modifier and Type | Method | Description |
---|---|---|
abstract void |
addToSubset(int codePoint) |
Adds the given Unicode point to the subset.
|
protected abstract byte[] |
encode(int unicode) |
Encodes the given Unicode code point for use in a PDF content stream.
|
byte[] |
encode(java.lang.String text) |
Encodes the given string for use in a PDF content stream.
|
boolean |
equals(java.lang.Object other) |
|
float |
getAverageFontWidth() |
This will get the average font width for all characters.
|
abstract BoundingBox |
getBoundingBox() |
Returns the font's bounding box.
|
COSDictionary |
getCOSObject() |
Convert this standard java object to a COS object.
|
Vector |
getDisplacement(int code) |
Returns the displacement vector (w0, w1) in text space, for the given character.
|
PDFontDescriptor |
getFontDescriptor() |
Returns the font descriptor, may be null.
|
Matrix |
getFontMatrix() |
Returns the font matrix, which represents the transformation from glyph space to text space.
|
abstract float |
getHeight(int code) |
Returns the height of the given character, in glyph space.
|
abstract java.lang.String |
getName() |
Returns the name of this font, either the PostScript "BaseName" or the Type 3 "Name".
|
Vector |
getPositionVector(int code) |
Returns the position vector (v), in text space, for the given character.
|
float |
getSpaceWidth() |
Determines the width of the space character.
|
protected 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(java.lang.String text) |
Returns the width of the given Unicode string.
|
java.lang.String |
getSubType() |
This will get the subtype of font.
|
java.lang.String |
getType() |
This will always return "Font" for fonts.
|
float |
getWidth(int code) |
Returns the advance width of the given character, in glyph space.
|
abstract float |
getWidthFromFont(int code) |
Returns the width of a glyph in the embedded font file.
|
protected java.util.List<java.lang.Float> |
getWidths() |
The widths of the characters.
|
int |
hashCode() |
|
abstract boolean |
isDamaged() |
Returns true if the embedded font file is damaged.
|
abstract boolean |
isEmbedded() |
Returns true if the font file is embedded in the PDF.
|
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 CMap |
readCMap(COSBase base) |
Reads a CMap given a COS Stream or Name.
|
abstract int |
readCode(java.io.InputStream in) |
Reads a character code from a content stream string.
|
protected void |
setFontDescriptor(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.
|
java.lang.String |
toString() |
|
java.lang.String |
toUnicode(int code) |
Returns the Unicode character sequence which corresponds to the given character code.
|
java.lang.String |
toUnicode(int code,
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.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
hasExplicitWidth
protected static final Matrix DEFAULT_FONT_MATRIX
protected final COSDictionary dict
protected PDFont(COSDictionary fontDictionary) throws java.io.IOException
fontDictionary
- Font dictionary.java.io.IOException
protected final FontMetrics getStandard14AFM()
public PDFontDescriptor getFontDescriptor()
PDFontLike
getFontDescriptor
in interface PDFontLike
protected final void setFontDescriptor(PDFontDescriptor fontDescriptor)
protected final CMap readCMap(COSBase base) throws java.io.IOException
base
- COSName or COSStreamjava.io.IOException
public COSDictionary getCOSObject()
COSObjectable
getCOSObject
in interface COSObjectable
public Vector getPositionVector(int code)
PDFontLike
getPositionVector
in interface PDFontLike
code
- character codepublic Vector getDisplacement(int code) throws java.io.IOException
code
- character codejava.io.IOException
public float getWidth(int code) throws java.io.IOException
PDFontLike
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 instead.
getWidth
in interface PDFontLike
code
- character codejava.io.IOException
protected abstract float getStandard14Width(int code)
code
- character codepublic abstract float getWidthFromFont(int code) throws java.io.IOException
PDFontLike
getWidthFromFont
in interface PDFontLike
code
- character codejava.io.IOException
- if the font could not be readpublic abstract boolean isEmbedded()
PDFontLike
isEmbedded
in interface PDFontLike
public abstract float getHeight(int code) throws java.io.IOException
PDFontLike
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.
getHeight
in interface PDFontLike
code
- character codejava.io.IOException
public final byte[] encode(java.lang.String text) throws java.io.IOException
text
- Any Unicode text.java.io.IOException
- If the text could not be encoded.protected abstract byte[] encode(int unicode) throws java.io.IOException
This method is called when embedding text in PDFs and when filling in fields.
unicode
- Unicode code point.java.io.IOException
- If the text could not be encoded.public float getStringWidth(java.lang.String text) throws java.io.IOException
text
- The text to get the width of.java.io.IOException
- If there is an error getting the width information.public float getAverageFontWidth()
getAverageFontWidth
in interface PDFontLike
public abstract int readCode(java.io.InputStream in) throws java.io.IOException
in
- string streamjava.io.IOException
- if the CMap or stream cannot be readpublic java.lang.String toUnicode(int code, GlyphList customGlyphList) throws java.io.IOException
code
- character codecustomGlyphList
- a custom glyph list to use instead of the Adobe Glyph Listjava.io.IOException
public java.lang.String toUnicode(int code) throws java.io.IOException
code
- character codejava.io.IOException
public java.lang.String getType()
public java.lang.String getSubType()
public abstract java.lang.String getName()
PDFontLike
getName
in interface PDFontLike
public abstract BoundingBox getBoundingBox() throws java.io.IOException
PDFontLike
getBoundingBox
in interface PDFontLike
java.io.IOException
protected final java.util.List<java.lang.Float> getWidths()
public Matrix getFontMatrix()
PDFontLike
getFontMatrix
in interface 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 java.io.IOException
java.io.IOException
- if the subset could not be writtenpublic abstract boolean willBeSubset()
public abstract boolean isDamaged()
PDFontLike
isDamaged
in interface PDFontLike
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © 2002–2018. All rights reserved.