Interface PDFontLike
-
- All Known Implementing Classes:
PDCIDFont,PDCIDFontType0,PDCIDFontType2,PDFont,PDMMType1Font,PDSimpleFont,PDTrueTypeFont,PDType0Font,PDType1CFont,PDType1Font,PDType3Font
public interface PDFontLikeA font-like object.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description floatgetAverageFontWidth()This will get the average font width for all characters.BoundingBoxgetBoundingBox()Returns the font's bounding box.PDFontDescriptorgetFontDescriptor()Returns the font descriptor, may be null.MatrixgetFontMatrix()Returns the font matrix, which represents the transformation from glyph space to text space.floatgetHeight(int code)Deprecated.UsegetBoundingBox().getHeight()instead.StringgetName()Returns the name of this font, either the PostScript "BaseName" or the Type 3 "Name".VectorgetPositionVector(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.booleanisDamaged()Returns true if the embedded font file is damaged.booleanisEmbedded()Returns true if the font file is embedded in the PDF.
-
-
-
Method Detail
-
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
BoundingBox getBoundingBox() throws IOException
Returns the font's bounding box.- Throws:
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 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 Path. See the cyan rectangles in the DrawPrintTextLocations.java example to see this in action.- Parameters:
code- character code- Throws:
IOException
-
getWidth
float getWidth(int code) throws IOExceptionReturns 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 Path instead. See the cyan rectangles in the DrawPrintTextLocations.java example to see this in action.
- Parameters:
code- character code- Throws:
IOException
-
hasExplicitWidth
boolean hasExplicitWidth(int code) throws IOExceptionReturns 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
float getWidthFromFont(int code) throws IOExceptionReturns 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
-
-