Interface PDFontLike
-
- All Known Implementing Classes:
PDCIDFont
,PDCIDFontType0
,PDCIDFontType2
,PDFont
,PDMMType1Font
,PDSimpleFont
,PDTrueTypeFont
,PDType0Font
,PDType1CFont
,PDType1Font
,PDType3Font
public interface PDFontLike
A font-like object.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description float
getAverageFontWidth()
This will get the average font width for all characters.BoundingBox
getBoundingBox()
Returns the font's bounding box.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.float
getHeight(int code)
Deprecated.UsegetBoundingBox()
.getHeight()
instead.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
getWidth(int code)
Returns the advance width of the given character, in glyph space.float
getWidthFromFont(int code)
Returns the width of a glyph in the embedded font file.boolean
hasExplicitWidth(int code)
Returns true if the Font dictionary specifies an explicit width for the given glyph.boolean
isDamaged()
Returns true if the embedded font file is damaged.boolean
isEmbedded()
Returns true if the font file is embedded in the PDF.
-
-
-
Method Detail
-
getName
java.lang.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
BoundingBox getBoundingBox() throws java.io.IOException
Returns the font's bounding box.- Throws:
java.io.IOException
-
getPositionVector
Vector getPositionVector(int code)
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 float getHeight(int code) throws java.io.IOException
Deprecated.UsegetBoundingBox()
.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. The
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. See the cyan rectangles in the DrawPrintTextLocations.java example to see this in action.- Parameters:
code
- character code- Throws:
java.io.IOException
-
getWidth
float getWidth(int code) throws java.io.IOException
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.
- Parameters:
code
- character code- Throws:
java.io.IOException
-
hasExplicitWidth
boolean hasExplicitWidth(int code) throws java.io.IOException
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:
java.io.IOException
- if the font could not be read
-
getWidthFromFont
float getWidthFromFont(int code) throws java.io.IOException
Returns the width of a glyph in the embedded font file.- Parameters:
code
- character code- Returns:
- width in glyph space
- Throws:
java.io.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.
-
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
-
-