| Modifier and Type | Field and Description |
|---|---|
| private CMap | |
| private final CmapLookup | |
| private CMap | |
| private final PDCIDFont | |
| private PDCIDFontType2Embedder | |
| private final GsubData | |
| private boolean | |
| private boolean | |
| private static final Log | |
| private final Set | |
| private TrueTypeFont |
| Access | Constructor and Description |
|---|---|
| public | PDType0Font(COSDictionary
The font dictionary according to the PDF specification. fontDictionary)Constructor for reading a Type0 font from a PDF file. |
| private | PDType0Font(PDDocument document, TrueTypeFont ttf, boolean embedSubset, boolean
whether to close the ttf parameter after embedding. Must be true when the ttf
parameter was created in the load() method, false when the ttf parameter was passed to the
load() method. closeTTF, boolean whether to enable vertical substitutions. vertical)Private. |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | addToSubset(int
Unicode code point codePoint)Implements abstract org. Adds the given Unicode point to the subset. |
| public int | Returns: CID for the given character codecharacter code code)Returns the CID for the given character code. |
| public int | Returns: GID for the given character codecharacter code code)Returns the GID for the given character code. |
| protected byte[] | encode(int
Unicode code point. unicode)Implements abstract org. Encodes the given Unicode code point for use in a PDF content stream. |
| public byte[] | Returns: the encoded glyph IDthe ID of the glyph to be encoded glyphId)Returns the encoded value for the given glyph ID. |
| private void | |
| public float | getAverageFontWidth()
Overrides org. Implements org. This will get the average font width for all characters. |
| public String | |
| public BoundingBox | getBoundingBox()
Implements org. Returns the font's bounding box. |
| public CMap | |
| public CmapLookup | |
| public CMap | Returns: the font's UCS2 CMap if presentReturns the font's UCS2 CMap, only present this font uses a predefined CMap. |
| public PDCIDFont | |
| public Vector | getDisplacement(int
character code code)Overrides org. Returns the displacement vector (w0, w1) in text space, for the given character. |
| public PDFontDescriptor | getFontDescriptor()
Overrides org. Implements org. Returns the font descriptor, may be null. |
| public Matrix | getFontMatrix()
Overrides org. Implements org. Returns the font matrix, which represents the transformation from glyph space to text space. |
| public GsubData | |
| public float | getHeight(int
character code code)Implements org. Returns the height of the given character, in glyph space. |
| public String | getName()
Implements org. Returns the name of this font, either the PostScript "BaseName" or the Type 3 "Name". |
| public GeneralPath | getNormalizedPath(int
character code in a PDF. Not to be confused with unicode. code)Implements org. Returns the normalized glyph path for the given character code in a PDF. |
| public GeneralPath | getPath(int
character code in a PDF. Not to be confused with unicode. code)Implements org. Returns the glyph path for the given character code. |
| public Vector | getPositionVector(int
character code code)Overrides org. Implements org. Returns the position vector (v), in text space, for the given character. |
| protected float | getStandard14Width(int
character code code)Implements abstract org. Returns the glyph width from the AFM if this is a Standard 14 font. |
| public float | getWidth(int
character code code)Overrides org. Implements org. Returns the advance width of the given character, in glyph space. |
| public float | getWidthFromFont(int
character code code)Implements org. Returns the width of a glyph in the embedded font file. |
| public boolean | hasExplicitWidth(int
character code code)Implements org. Returns true if the Font dictionary specifies an explicit width for the given glyph. |
| public boolean | hasGlyph(int
character code in a PDF. Not to be confused with unicode. code)Implements org. Returns true if this font contains a glyph for the given character code in a PDF. |
| public boolean | isDamaged()
Implements org. Returns true if the embedded font file is damaged. |
| public boolean | isEmbedded()
Implements org. Returns true if the font file is embedded in the PDF. |
| public boolean | isStandard14()
Overrides org. Returns true if this font is one of the "Standard 14" fonts and receives special handling. |
| public boolean | isVertical()
Implements abstract org. Returns true if the font uses vertical writing mode. |
| public static PDType0Font | Returns: A Type0 font with a CIDFontType2 descendant.The PDF document that will hold the embedded font. doc, File A TrueType font. file)Loads a TTF to be embedded and subset into a document as a Type 0 font. |
| public static PDType0Font | Returns: A Type0 font with a CIDFontType2 descendant.The PDF document that will hold the embedded font. doc, InputStream An input stream of a TrueType font. It will be closed before returning. input)Loads a TTF to be embedded and subset into a document as a Type 0 font. |
| public static PDType0Font | Returns: A Type0 font with a CIDFontType2 descendant.The PDF document that will hold the embedded font. doc, InputStream An input stream of a TrueType font. It will be closed before returning. input, boolean True if the font will be subset before embedding. Set this to false when
creating a font for AcroForm. embedSubset)Loads a TTF to be embedded into a document as a Type 0 font. |
| public static PDType0Font | Returns: A Type0 font with a CIDFontType2 descendant.The PDF document that will hold the embedded font. doc, RandomAccessRead source of a TrueType font. randomAccessRead, boolean True if the font will be subset before embedding. Set this to false when creating a font for
AcroForm. embedSubset, boolean whether to enable vertical substitutions. vertical)Loads a TTF to be embedded into a document as a Type 0 font. |
| public static PDType0Font | Returns: A Type0 font with a CIDFontType2 descendant.The PDF document that will hold the embedded font. doc, TrueTypeFont A TrueType font. ttf, boolean True if the font will be subset before embedding. Set this to false when creating a font for
AcroForm. embedSubset)Loads a TTF to be embedded into a document as a Type 0 font. |
| public static PDType0Font | Returns: A Type0 font with a CIDFontType2 descendant.The PDF document that will hold the embedded font. doc, File A TrueType font. file)Loads a TTF to be embedded into a document as a vertical Type 0 font. |
| public static PDType0Font | Returns: A Type0 font with a CIDFontType2 descendant.The PDF document that will hold the embedded font. doc, InputStream A TrueType font. input)Loads a TTF to be embedded into a document as a vertical Type 0 font. |
| public static PDType0Font | Returns: A Type0 font with a CIDFontType2 descendant.The PDF document that will hold the embedded font. doc, InputStream A TrueType font. input, boolean True if the font will be subset before embedding embedSubset)Loads a TTF to be embedded into a document as a vertical Type 0 font. |
| public static PDType0Font | Returns: A Type0 font with a CIDFontType2 descendant.The PDF document that will hold the embedded font. doc, TrueTypeFont A TrueType font. ttf, boolean True if the font will be subset before embedding embedSubset)Loads a TTF to be embedded into a document as a vertical Type 0 font. |
| public int | readCode(InputStream
string stream in)Implements abstract org. Reads a character code from a content stream string. |
| private void | |
| public void | subset()
Implements abstract org. Replaces this font with a subset containing only the given Unicode characters. |
| public String | toString()
Overrides org. Returns a string representation of the object. |
| public String | toUnicode(int
character code code)Overrides org. Returns the Unicode character sequence which corresponds to the given character code. |
| public boolean | willBeSubset()
Implements abstract org. Returns true if this font will be subset when embedded. |
| cMap | back to summary |
|---|---|
| private CMap cMap | |
| cmapLookup | back to summary |
|---|---|
| private final CmapLookup cmapLookup | |
| cMapUCS2 | back to summary |
|---|---|
| private CMap cMapUCS2 | |
| descendantFont | back to summary |
|---|---|
| private final PDCIDFont descendantFont | |
| embedder | back to summary |
|---|---|
| private PDCIDFontType2Embedder embedder | |
| gsubData | back to summary |
|---|---|
| private final GsubData gsubData | |
| isCMapPredefined | back to summary |
|---|---|
| private boolean isCMapPredefined | |
| isDescendantCJK | back to summary |
|---|---|
| private boolean isDescendantCJK | |
| LOG | back to summary |
|---|---|
| private static final Log LOG | |
| noUnicode | back to summary |
|---|---|
| private final Set<Integer> noUnicode | |
| ttf | back to summary |
|---|---|
| private TrueTypeFont ttf | |
| PDType0Font | back to summary |
|---|---|
| public PDType0Font(COSDictionary fontDictionary) throws IOException Constructor for reading a Type0 font from a PDF file.
| |
| PDType0Font | back to summary |
|---|---|
| private PDType0Font(PDDocument document, TrueTypeFont ttf, boolean embedSubset, boolean closeTTF, boolean vertical) throws IOException Private. Creates a new PDType0Font font for embedding.
| |
| addGlyphsToSubset | back to summary |
|---|---|
| public void addGlyphsToSubset(Set<Integer> glyphIds) | |
| addToSubset | back to summary |
|---|---|
| public void addToSubset(int codePoint) Implements abstract org. Doc from org. Adds the given Unicode point to the subset.
| |
| codeToCID | back to summary |
|---|---|
| public int codeToCID(int code) Returns the CID for the given character code. If not found then CID 0 is returned.
| |
| codeToGID | back to summary |
|---|---|
| public int codeToGID(int code) throws IOException Returns the GID for the given character code.
| |
| encode | back to summary |
|---|---|
| protected byte[] encode(int unicode) throws IOException Implements abstract org. Doc from org. Encodes the given Unicode code point for use in a PDF content stream. Content streams use a multi-byte encoding with 1 to 4 bytes. This method is called when embedding text in PDFs and when filling in fields.
| |
| encodeGlyphId | back to summary |
|---|---|
| public byte[] encodeGlyphId(int glyphId) Returns the encoded value for the given glyph ID.
| |
| fetchCMapUCS2 | back to summary |
|---|---|
| private void fetchCMapUCS2() throws IOException Fetches the corresponding UCS2 CMap if the font's CMap is predefined. | |
| getAverageFontWidth | back to summary |
|---|---|
| public float getAverageFontWidth() Overrides org. Implements org. Doc from org. This will get the average font width for all characters.
| |
| getBaseFont | back to summary |
|---|---|
| public String getBaseFont() Returns the PostScript name of the font.
| |
| getBoundingBox | back to summary |
|---|---|
| public BoundingBox getBoundingBox() throws IOException Implements org. Doc from org. Returns the font's bounding box.
| |
| getCMap | back to summary |
|---|---|
| public CMap getCMap() Returns the font's CMap.
| |
| getCmapLookup | back to summary |
|---|---|
| public CmapLookup getCmapLookup() Returns the CMap lookup table if present.
| |
| getCMapUCS2 | back to summary |
|---|---|
| public CMap getCMapUCS2() Returns the font's UCS2 CMap, only present this font uses a predefined CMap.
| |
| getDescendantFont | back to summary |
|---|---|
| public PDCIDFont getDescendantFont() Returns the descendant font.
| |
| getDisplacement | back to summary |
|---|---|
| public Vector getDisplacement(int code) throws IOException Overrides org. Doc from org. Returns the displacement vector (w0, w1) in text space, for the given character. For horizontal text only the x component is used, for vertical text only the y component.
| |
| getFontDescriptor | back to summary |
|---|---|
| public PDFontDescriptor getFontDescriptor() Overrides org. Implements org. Doc from org. Returns the font descriptor, may be null.
| |
| getFontMatrix | back to summary |
|---|---|
| public Matrix getFontMatrix() Overrides org. Implements org. Doc from org. Returns the font matrix, which represents the transformation from glyph space to text space. | |
| getGsubData | back to summary |
|---|---|
| public GsubData getGsubData() Returns the GSubData if present.
| |
| getHeight | back to summary |
|---|---|
| public float getHeight(int code) throws IOException Implements org. Doc from org. Returns the height of the given character, in glyph space. This can be expensive to calculate. Results are only approximate. Warning This method is deprecated in PDFBox 2.0 because there is no meaningful value which it can return. The
| |
| getName | back to summary |
|---|---|
| public String getName() Implements org. Doc from org. Returns the name of this font, either the PostScript "BaseName" or the Type 3 "Name". | |
| getNormalizedPath | back to summary |
|---|---|
| public GeneralPath getNormalizedPath(int code) throws IOException Implements org. Doc from org. Returns the normalized glyph path for the given character code in a PDF. The resulting path is normalized to the PostScript 1000 unit square, and fallback glyphs are returned where appropriate, e.g. for missing glyphs.
| |
| getPath | back to summary |
|---|---|
| public GeneralPath getPath(int code) throws IOException Implements org. Doc from org. Returns the glyph path for the given character code.
| |
| getPositionVector | back to summary |
|---|---|
| public Vector getPositionVector(int code) Overrides org. Implements org. Doc from org. Returns the position vector (v), in text space, for the given character. This represents the position of vertical origin relative to horizontal origin, for horizontal writing it will always be (0, 0). For vertical writing both x and y are set. | |
| getStandard14Width | back to summary |
|---|---|
| protected float getStandard14Width(int code) Implements abstract org. Doc from org. Returns the glyph width from the AFM if this is a Standard 14 font.
| |
| getWidth | back to summary |
|---|---|
| public float getWidth(int code) throws IOException Overrides org. Implements org. Doc from org. Returns the advance width of the given character, in glyph space. 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. See the cyan rectangles in the DrawPrintTextLocations.java example to see this in action.
| |
| getWidthFromFont | back to summary |
|---|---|
| public float getWidthFromFont(int code) throws IOException Implements org. Doc from org. Returns the width of a glyph in the embedded font file.
| |
| hasExplicitWidth | back to summary |
|---|---|
| public boolean hasExplicitWidth(int code) throws IOException Implements org. Doc from org. Returns true if the Font dictionary specifies an explicit width for the given glyph. This includes Width, W but not default widths entries.
| |
| hasGlyph | back to summary |
|---|---|
| public boolean hasGlyph(int code) throws IOException Implements org. Doc from org. Returns true if this font contains a glyph for the given character code in a PDF.
| |
| isDamaged | back to summary |
|---|---|
| public boolean isDamaged() Implements org. Doc from org. Returns true if the embedded font file is damaged.
| |
| isEmbedded | back to summary |
|---|---|
| public boolean isEmbedded() Implements org. Doc from org. Returns true if the font file is embedded in the PDF.
| |
| isStandard14 | back to summary |
|---|---|
| public boolean isStandard14() Overrides org. Doc from org. Returns true if this font is one of the "Standard 14" fonts and receives special handling.
| |
| isVertical | back to summary |
|---|---|
| public boolean isVertical() Implements abstract org. Doc from org. Returns true if the font uses vertical writing mode.
| |
| load | back to summary |
|---|---|
| public static PDType0Font load(PDDocument doc, File file) throws IOException Loads a TTF to be embedded and subset into a document as a Type 0 font. If you are loading a font for AcroForm, then use the 3-parameter constructor instead.
| |
| load | back to summary |
|---|---|
| public static PDType0Font load(PDDocument doc, InputStream input) throws IOException Loads a TTF to be embedded and subset into a document as a Type 0 font. If you are loading a font for AcroForm, then use the 3-parameter constructor instead.
| |
| load | back to summary |
|---|---|
| public static PDType0Font load(PDDocument doc, InputStream input, boolean embedSubset) throws IOException Loads a TTF to be embedded into a document as a Type 0 font.
| |
| load | back to summary |
|---|---|
| public static PDType0Font load(PDDocument doc, RandomAccessRead randomAccessRead, boolean embedSubset, boolean vertical) throws IOException Loads a TTF to be embedded into a document as a Type 0 font.
| |
| load | back to summary |
|---|---|
| public static PDType0Font load(PDDocument doc, TrueTypeFont ttf, boolean embedSubset) throws IOException Loads a TTF to be embedded into a document as a Type 0 font.
| |
| loadVertical | back to summary |
|---|---|
| public static PDType0Font loadVertical(PDDocument doc, File file) throws IOException Loads a TTF to be embedded into a document as a vertical Type 0 font.
| |
| loadVertical | back to summary |
|---|---|
| public static PDType0Font loadVertical(PDDocument doc, InputStream input) throws IOException Loads a TTF to be embedded into a document as a vertical Type 0 font.
| |
| loadVertical | back to summary |
|---|---|
| public static PDType0Font loadVertical(PDDocument doc, InputStream input, boolean embedSubset) throws IOException Loads a TTF to be embedded into a document as a vertical Type 0 font.
| |
| loadVertical | back to summary |
|---|---|
| public static PDType0Font loadVertical(PDDocument doc, TrueTypeFont ttf, boolean embedSubset) throws IOException Loads a TTF to be embedded into a document as a vertical Type 0 font.
| |
| readCode | back to summary |
|---|---|
| public int readCode(InputStream in) throws IOException Implements abstract org. Doc from org. Reads a character code from a content stream string. Codes may be up to 4 bytes long.
| |
| readEncoding | back to summary |
|---|---|
| private void readEncoding() throws IOException Reads the font's Encoding entry, which should be a CMap name/stream. | |
| subset | back to summary |
|---|---|
| public void subset() throws IOException Implements abstract org. Doc from org. Replaces this font with a subset containing only the given Unicode characters.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides org. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |
| toUnicode | back to summary |
|---|---|
| public String toUnicode(int code) Overrides org. Doc from org. Returns the Unicode character sequence which corresponds to the given character code. | |
| willBeSubset | back to summary |
|---|---|
| public boolean willBeSubset() Implements abstract org. Doc from org. Returns true if this font will be subset when embedded.
| |