Class WFontMetrics

java.lang.Object
eu.webtoolkit.jwt.WFontMetrics

public class WFontMetrics
extends java.lang.Object
A value class that describes font metrics for a font.

This class provides font metrics for a given font. It is returned by an implementation of WPaintDevice.getFontMetrics(), and may differ between devices.

All methods return pixel dimensions.

See Also:
WPaintDevice
  • Constructor Summary

    Constructors
    Constructor Description
    WFontMetrics​(WFont font, double leading, double ascent, double descent)
    Creates a font metrics information object.
  • Method Summary

    Modifier and Type Method Description
    double getAscent()
    Returns the font ascent length.
    double getDescent()
    Returns the font descent length.
    WFont getFont()
    Returns the font for which these font metrics were computed.
    double getHeight()
    Returns the font height.
    double getLeading()
    Returns the font leading length.
    double getSize()
    Returns the font size.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • WFontMetrics

      public WFontMetrics​(WFont font, double leading, double ascent, double descent)
      Creates a font metrics information object.
  • Method Details

    • getFont

      public WFont getFont()
      Returns the font for which these font metrics were computed.
    • getSize

      public double getSize()
      Returns the font size.

      This is the same as:

      
       font().size().sizeLength()
      
       

      e.g.~for a font with size set to 16px, this returns 16.

    • getHeight

      public double getHeight()
      Returns the font height.

      The font height is the total height of a text line. It is usually a bit bigger than the font size to have natural line spacing.

    • getLeading

      public double getLeading()
      Returns the font leading length.

      This is vertical space provided on top of the ascent (empty space which serves as natural line spacing).

    • getAscent

      public double getAscent()
      Returns the font ascent length.

      This is vertical space which corresponds to the maximum height of a character over the baseline (although many fonts violate this for some glyphs).

    • getDescent

      public double getDescent()
      Returns the font descent length.

      This is vertical space which corresponds to the maximum height of a character under the baseline (although many fonts violate this for some glyphs).