Class FontMetrics
Defined in: graphics2d.js.
Constructor Attributes | Constructor Name and Description |
---|---|
FontMetrics(font)
This utility class allows to get the metrics of a given font.
|
Method Attributes | Method Name and Description |
---|---|
Gets the font ascent.
|
|
Gets the font descent.
|
|
Gets the font height.
|
|
getStringBounds(aString)
Gets the bounds of the given string for this font metrics.
|
Class Detail
FontMetrics(font)
This utility class allows to get the metrics of a given font. Note that this class will approximate
the metrics on older browsers where CanvasRenderingContext2D.measureText() is only partially implemented.
Builds a font metrics instance for the given font.
Author: Renaud Pawlak, Emmanuel Puybaret.
Author: Renaud Pawlak, Emmanuel Puybaret.
- Parameters:
- {string} font
- the given font, in a CSS canvas-compatible representation
Method Detail
{number}
getAscent()
Gets the font ascent.
- Returns:
- {number} the font ascent
{number}
getDescent()
Gets the font descent.
- Returns:
- {number} the font descent
{number}
getHeight()
Gets the font height.
- Returns:
- {number} the font height
{java.awt.geom.Rectangle2D}
getStringBounds(aString)
Gets the bounds of the given string for this font metrics.
- Parameters:
- {string} aString
- the string to get the bounds of
- Returns:
- {java.awt.geom.Rectangle2D} the bounds as an instance of java.awt.geom.Rectangle2D