Interface PDFontLike
- All Known Implementing Classes:
PDCIDFont
,PDCIDFontType0
,PDCIDFontType2
,PDFont
,PDMMType1Font
,PDSimpleFont
,PDTrueTypeFont
,PDType0Font
,PDType1CFont
,PDType1Font
,PDType3Font
- Author:
- John Hewson
-
Method Summary
Modifier and TypeMethodDescriptionfloat
This will get the average font width for all characters.org.apache.fontbox.util.BoundingBox
Returns 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.float
getHeight
(int code) Deprecated.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.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
Returns true if the embedded font file is damaged.boolean
Returns true if the font file is embedded in the PDF.
-
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.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:
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. See the cyan rectangles in the DrawPrintTextLocations.java example to see this in action.
- 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. -
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
-
getBoundingBox()
.getHeight()
instead.