- All Known Implementing Classes:
PDCIDFont,PDCIDFontType0,PDCIDFontType2,PDFont,PDMMType1Font,PDSimpleFont,PDTrueTypeFont,PDType0Font,PDType1CFont,PDType1Font,PDType3Font
public interface PDFontLike
A font-like object.
- Author:
- John Hewson
-
Method Summary
Modifier and TypeMethodDescriptionfloatThis will get the average font width for all characters.org.apache.fontbox.util.BoundingBoxReturns the font's bounding box.Returns the font descriptor, may be null.Returns the font matrix, which represents the transformation from glyph space to text space.floatgetHeight(int code) Deprecated.Use {@link #getBoundingBox().getHeight()} instead.getName()Returns the name of this font, either the PostScript "BaseName" or the Type 3 "Name".getPositionVector(int code) Returns the position vector (v), in text space, for the given character.floatgetWidth(int code) Returns the advance width of the given character, in glyph space.floatgetWidthFromFont(int code) Returns the width of a glyph in the embedded font file.booleanhasExplicitWidth(int code) Returns true if the Font dictionary specifies an explicit width for the given glyph.booleanReturns true if the embedded font file is damaged.booleanReturns true if the font file is embedded in the PDF.booleanReturns true if a substitute font was searched via font mappings, but an exact match was not found, and a fallback was usedbooleanReturns true if the font file that was supposed to be embedded in the PDF is missing.
-
Method Details
-
getName
String getName()Returns the name of this font, either the PostScript "BaseName" or the Type 3 "Name". -
getFontDescriptor
PDFontDescriptor getFontDescriptor()Returns the font descriptor, may be null. -
getFontMatrix
Matrix getFontMatrix()Returns the font matrix, which represents the transformation from glyph space to text space. -
getBoundingBox
Returns the font's bounding box.- Throws:
IOException
-
getPositionVector
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.- Parameters:
code- character code- Returns:
- position vector
-
getHeight
Deprecated.Use {@link #getBoundingBox().getHeight()} instead.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. ThegetWidth(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.- Parameters:
code- character code- Throws:
IOException
-
getWidth
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.- Parameters:
code- character code- Throws:
IOException
-
hasExplicitWidth
Returns true if the Font dictionary specifies an explicit width for the given glyph. This includes Width, W but not default widths entries.- Parameters:
code- character code- Throws:
IOException- if the font could not be read
-
getWidthFromFont
Returns the width of a glyph in the embedded font file.- Parameters:
code- character code- Returns:
- width in glyph space
- Throws:
IOException- if the font could not be read
-
isEmbedded
boolean isEmbedded()Returns true if the font file is embedded in the PDF. -
isDamaged
boolean isDamaged()Returns true if the embedded font file is damaged. -
isOriginalEmbeddedMissing
boolean isOriginalEmbeddedMissing()Returns true if the font file that was supposed to be embedded in the PDF is missing. -
isMappingFallbackUsed
boolean isMappingFallbackUsed()Returns true if a substitute font was searched via font mappings, but an exact match was not found, and a fallback was used -
getAverageFontWidth
float getAverageFontWidth()This will get the average font width for all characters.- Returns:
- The width is in 1000 unit of text space, ie 333 or 777
-