Class WFontMetrics

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

public class WFontMetrics extends 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:
  • 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).