Top Description Methods
org.apache.pdfbox.pdmodel.font

public Interface PDFontLike

Known Direct Implementers
org.apache.pdfbox.pdmodel.font.PDCIDFont, org.apache.pdfbox.pdmodel.font.PDFont
Imports
java.io.IOException, org.apache.fontbox.util.BoundingBox, org.apache.pdfbox.util.Matrix, .Vector

A font-like object.
Author
John Hewson

Method Summary

Modifier and TypeMethod and Description
public float

Returns:

The width is in 1000 unit of text space, ie 333 or 777
getAverageFontWidth
()

This will get the average font width for all characters.

public BoundingBox

Returns:

the bounding box
getBoundingBox
()

Returns the font's bounding box.

public PDFontDescriptor

Returns:

the font descriptor or null
getFontDescriptor
()

Returns the font descriptor, may be null.

public Matrix

Returns:

the font matrix
getFontMatrix
()

Returns the font matrix, which represents the transformation from glyph space to text space.

public float

Returns:

the height of the given character
getHeight
(int
character code
code
)
Deprecated Use getBoundingBox().

Returns the height of the given character, in glyph space.

public String

Returns:

the name of the font
getName
()

Returns the name of this font, either the PostScript "BaseName" or the Type 3 "Name".

public Vector

Returns:

position vector
getPositionVector
(int
character code
code
)

Returns the position vector (v), in text space, for the given character.

public float

Returns:

the width of the given character
getWidth
(int
character code
code
)

Returns the advance width of the given character, in glyph space.

public float

Returns:

width in glyph space
getWidthFromFont
(int
character code
code
)

Returns the width of a glyph in the embedded font file.

public boolean

Returns:

true if the Font dictionary specifies an explicit width for the given glyph
hasExplicitWidth
(int
character code
code
)

Returns true if the Font dictionary specifies an explicit width for the given glyph.

public boolean

Returns:

true if the embedded font file is damaged
isDamaged
()

Returns true if the embedded font file is damaged.

public boolean

Returns:

true if the font file is embedded in the PDF
isEmbedded
()

Returns true if the font file is embedded in the PDF.

Method Detail

getAverageFontWidthback to summary
public float getAverageFontWidth()

This will get the average font width for all characters.

Returns:float

The width is in 1000 unit of text space, ie 333 or 777

getBoundingBoxback to summary
public BoundingBox getBoundingBox() throws IOException

Returns the font's bounding box.

Returns:BoundingBox

the bounding box

Exceptions
IOException:
if the bounding box could not be read
getFontDescriptorback to summary
public PDFontDescriptor getFontDescriptor()

Returns the font descriptor, may be null.

Returns:PDFontDescriptor

the font descriptor or null

getFontMatrixback to summary
public Matrix getFontMatrix()

Returns the font matrix, which represents the transformation from glyph space to text space.

Returns:Matrix

the font matrix

getHeightback to summary
public float getHeight(int code) throws IOException

Deprecated

Use 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. 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:int

character code

Returns:float

the height of the given character

Annotations
@Deprecated
Exceptions
IOException:
if the height could not be read
getNameback to summary
public String getName()

Returns the name of this font, either the PostScript "BaseName" or the Type 3 "Name".

Returns:String

the name of the font

getPositionVectorback to summary
public 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:int

character code

Returns:Vector

position vector

getWidthback to summary
public float getWidth(int code) throws 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:int

character code

Returns:float

the width of the given character

Exceptions
IOException:
if the width could not be read
getWidthFromFontback to summary
public float getWidthFromFont(int code) throws IOException

Returns the width of a glyph in the embedded font file.

Parameters
code:int

character code

Returns:float

width in glyph space

Exceptions
IOException:
if the font could not be read
hasExplicitWidthback to summary
public boolean hasExplicitWidth(int code) throws 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:int

character code

Returns:boolean

true if the Font dictionary specifies an explicit width for the given glyph

Exceptions
IOException:
if the font could not be read
isDamagedback to summary
public boolean isDamaged()

Returns true if the embedded font file is damaged.

Returns:boolean

true if the embedded font file is damaged

isEmbeddedback to summary
public boolean isEmbedded()

Returns true if the font file is embedded in the PDF.

Returns:boolean

true if the font file is embedded in the PDF