Class FontMetrics


  • public final class FontMetrics
    extends java.lang.Object
    Instances of this class provide measurement information about fonts including ascent, descent, height, leading space between rows, and average character width. FontMetrics are obtained from GCs using the getFontMetrics() method.
    See Also:
    GC.getFontMetrics(), Sample code and further information
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object object)
      Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.
      int getAscent()
      Returns the ascent of the font described by the receiver.
      double getAverageCharacterWidth()
      Returns the average character width, measured in points, of the font described by the receiver.
      int getAverageCharWidth()
      Deprecated.
      Use getAverageCharacterWidth() instead
      int getDescent()
      Returns the descent of the font described by the receiver.
      int getHeight()
      Returns the height of the font described by the receiver, measured in points.
      int getLeading()
      Returns the leading area of the font described by the receiver.
      int hashCode()
      Returns an integer hash code for the receiver.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object object)
        Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        object - the object to compare with this object
        Returns:
        true if the object is the same as this object and false otherwise
        See Also:
        hashCode()
      • getAscent

        public int getAscent()
        Returns the ascent of the font described by the receiver. A font's ascent is the distance from the baseline to the top of actual characters, not including any of the leading area, measured in points.
        Returns:
        the ascent of the font
      • getAverageCharacterWidth

        public double getAverageCharacterWidth()
        Returns the average character width, measured in points, of the font described by the receiver.
        Returns:
        the average character width of the font
        Since:
        3.107
      • getAverageCharWidth

        @Deprecated
        public int getAverageCharWidth()
        Deprecated.
        Use getAverageCharacterWidth() instead
        Returns the average character width, measured in points, of the font described by the receiver.
        Returns:
        the average character width of the font
      • getDescent

        public int getDescent()
        Returns the descent of the font described by the receiver. A font's descent is the distance from the baseline to the bottom of actual characters, not including any of the leading area, measured in points.
        Returns:
        the descent of the font
      • getHeight

        public int getHeight()
        Returns the height of the font described by the receiver, measured in points. A font's height is the sum of its ascent, descent and leading area.
        Returns:
        the height of the font
        See Also:
        getAscent(), getDescent(), getLeading()
      • getLeading

        public int getLeading()
        Returns the leading area of the font described by the receiver. A font's leading area is the space above its ascent which may include accents or other marks.
        Returns:
        the leading space of the font
      • hashCode

        public int hashCode()
        Returns an integer hash code for the receiver. Any two objects that return true when passed to equals must return the same value for this method.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the receiver's hash
        See Also:
        equals(java.lang.Object)