COSObjectable, PDFontLike, PDVectorFontpublic class PDTrueTypeFont extends PDSimpleFont implements PDVectorFont
DEFAULT_FONT_MATRIX, dictencoding, glyphList| Constructor | Description |
|---|---|
PDTrueTypeFont(COSDictionary fontDictionary) |
Creates a new TrueType font from a Font dictionary.
|
| Modifier and Type | Method | Description |
|---|---|---|
int |
codeToGID(int code) |
Returns the GID for the given character code.
|
protected byte[] |
encode(int unicode) |
Encodes the given Unicode code point for use in a PDF content stream.
|
java.lang.String |
getBaseFont() |
Returns the PostScript name of the font.
|
org.apache.fontbox.util.BoundingBox |
getBoundingBox() |
Returns the font's bounding box.
|
org.apache.fontbox.FontBoxFont |
getFontBoxFont() |
Returns the embedded or system font used for rendering.
|
protected java.util.Map<java.lang.Integer,java.lang.Integer> |
getGIDToCode() |
Inverts the font's code -> GID mapping.
|
float |
getHeight(int code) |
Returns the height of the given character, in glyph space.
|
java.lang.String |
getName() |
Returns the name of this font, either the PostScript "BaseName" or the Type 3 "Name".
|
java.awt.geom.GeneralPath |
getPath(int code) |
Returns the glyph path for the given character code.
|
java.awt.geom.GeneralPath |
getPath(java.lang.String name) |
Returns the path for the character with the given name.
|
org.apache.fontbox.ttf.TrueTypeFont |
getTrueTypeFont() |
Returns the embedded or substituted TrueType font.
|
float |
getWidthFromFont(int code) |
Returns the width of a glyph in the embedded font file.
|
boolean |
hasGlyph(int code) |
Returns true if this font contains a glyph for the given character code.
|
boolean |
hasGlyph(java.lang.String name) |
Returns true if the font contains the character with the given name.
|
boolean |
isDamaged() |
Returns true if the embedded font file is damaged.
|
boolean |
isEmbedded() |
Returns true if the font file is embedded in the PDF.
|
static PDTrueTypeFont |
load(PDDocument doc,
java.io.File file,
Encoding encoding) |
Loads a TTF to be embedded into a document as a simple font.
|
static PDTrueTypeFont |
load(PDDocument doc,
java.io.InputStream input,
Encoding encoding) |
Loads a TTF to be embedded into a document as a simple font.
|
static PDTrueTypeFont |
load(PDDocument doc,
org.apache.fontbox.ttf.TrueTypeFont ttf,
Encoding encoding) |
Loads a TTF to be embedded into a document as a simple font.
|
static PDTrueTypeFont |
loadTTF(PDDocument doc,
java.io.File file) |
Deprecated.
Use
PDType0Font.load(PDDocument, File) instead. |
static PDTrueTypeFont |
loadTTF(PDDocument doc,
java.io.InputStream input) |
Deprecated.
Use
PDType0Font.load(PDDocument, InputStream) instead. |
int |
readCode(java.io.InputStream in) |
Reads a character code from a content stream string.
|
protected Encoding |
readEncodingFromFont() |
Called by readEncoding() if the encoding needs to be extracted from the font file.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, waitencode, equals, getAverageFontWidth, getCOSObject, getDisplacement, getFontDescriptor, getFontMatrix, getPositionVector, getSpaceWidth, getStandard14AFM, getStringWidth, getSubType, getType, getWidth, getWidths, hashCode, readCMap, setFontDescriptor, toStringaddToSubset, getEncoding, getGlyphList, getStandard14Width, getSymbolicFlag, hasExplicitWidth, isFontSymbolic, isStandard14, isSymbolic, isVertical, readEncoding, subset, toUnicode, toUnicode, willBeSubsetpublic PDTrueTypeFont(COSDictionary fontDictionary) throws java.io.IOException
fontDictionary - The font dictionary according to the PDF specification.java.io.IOExceptionpublic static PDTrueTypeFont load(PDDocument doc, java.io.File file, Encoding encoding) throws java.io.IOException
Note: Simple fonts only support 256 characters. For Unicode support, use
PDType0Font.load(PDDocument, File) instead.
doc - The PDF document that will hold the embedded font.file - A TTF file.encoding - The PostScript encoding vector to be used for embedding.java.io.IOException - If there is an error loading the data.public static PDTrueTypeFont load(PDDocument doc, java.io.InputStream input, Encoding encoding) throws java.io.IOException
Note: Simple fonts only support 256 characters. For Unicode support, use
PDType0Font.load(PDDocument, InputStream) instead.
doc - The PDF document that will hold the embedded font.input - A TTF file streamencoding - The PostScript encoding vector to be used for embedding.java.io.IOException - If there is an error loading the data.public static PDTrueTypeFont load(PDDocument doc, org.apache.fontbox.ttf.TrueTypeFont ttf, Encoding encoding) throws java.io.IOException
Note: Simple fonts only support 256 characters. For Unicode support, use
PDType0Font.load(PDDocument, InputStream) instead.
doc - The PDF document that will hold the embedded font.ttf - A true type fontencoding - The PostScript encoding vector to be used for embedding.java.io.IOException - If there is an error loading the data.@Deprecated public static PDTrueTypeFont loadTTF(PDDocument doc, java.io.File file) throws java.io.IOException
PDType0Font.load(PDDocument, File) instead.doc - The PDF document that will hold the embedded font.file - A TTF file.java.io.IOException - If there is an error loading the data.@Deprecated public static PDTrueTypeFont loadTTF(PDDocument doc, java.io.InputStream input) throws java.io.IOException
PDType0Font.load(PDDocument, InputStream) instead.doc - The PDF document that will hold the embedded font.input - A TTF file streamjava.io.IOException - If there is an error loading the data.public final java.lang.String getBaseFont()
protected Encoding readEncodingFromFont() throws java.io.IOException
PDSimpleFontreadEncodingFromFont in class PDSimpleFontjava.io.IOException - if the font file could not be read.public int readCode(java.io.InputStream in)
throws java.io.IOException
PDFontpublic java.lang.String getName()
PDFontLikegetName in interface PDFontLikegetName in class PDFontpublic org.apache.fontbox.util.BoundingBox getBoundingBox()
throws java.io.IOException
PDFontLikegetBoundingBox in interface PDFontLikegetBoundingBox in class PDFontjava.io.IOExceptionpublic boolean isDamaged()
PDFontLikeisDamaged in interface PDFontLikeisDamaged in class PDFontpublic org.apache.fontbox.ttf.TrueTypeFont getTrueTypeFont()
public float getWidthFromFont(int code)
throws java.io.IOException
PDFontLikegetWidthFromFont in interface PDFontLikegetWidthFromFont in class PDFontcode - character codejava.io.IOException - if the font could not be readpublic 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 PDFontLikegetHeight in class PDFontcode - character codejava.io.IOExceptionprotected byte[] encode(int unicode)
throws java.io.IOException
PDFontThis method is called when embedding text in PDFs and when filling in fields.
protected java.util.Map<java.lang.Integer,java.lang.Integer> getGIDToCode()
throws java.io.IOException
java.io.IOExceptionpublic boolean isEmbedded()
PDFontLikeisEmbedded in interface PDFontLikeisEmbedded in class PDFontpublic java.awt.geom.GeneralPath getPath(int code)
throws java.io.IOException
PDVectorFontgetPath in interface PDVectorFontcode - character code in a PDF. Not to be confused with unicode.java.io.IOException - if the font could not be readpublic java.awt.geom.GeneralPath getPath(java.lang.String name)
throws java.io.IOException
PDSimpleFontgetPath in class PDSimpleFontjava.io.IOException - if the path could not be readpublic boolean hasGlyph(java.lang.String name)
throws java.io.IOException
PDSimpleFonthasGlyph in class PDSimpleFontjava.io.IOException - if the path could not be readpublic org.apache.fontbox.FontBoxFont getFontBoxFont()
PDSimpleFontgetFontBoxFont in class PDSimpleFontpublic boolean hasGlyph(int code)
throws java.io.IOException
PDVectorFonthasGlyph in interface PDVectorFontcode - character code in a PDF. Not to be confused with unicode.java.io.IOExceptionpublic int codeToGID(int code)
throws java.io.IOException
code - character codejava.io.IOExceptionCopyright © 2002–2018. All rights reserved.