Package org.eclipse.swt.graphics
Class FontMetrics
- java.lang.Object
-
- org.eclipse.swt.graphics.FontMetrics
-
public final class FontMetrics extends Object
Instances of this class provide measurement information about fonts including ascent, descent, height, leading space between rows, and average character width.FontMetricsare obtained fromGCs using thegetFontMetrics()method.
-
-
Field Summary
Fields Modifier and Type Field Description org.eclipse.swt.internal.win32.TEXTMETRIChandleOn Windows, handle is a Win32 TEXTMETRIC struct (Warning: This field is platform dependent)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description booleanequals(Object object)Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.intgetAscent()Returns the ascent of the font described by the receiver.doublegetAverageCharacterWidth()Returns the average character width, measured in points, of the font described by the receiver.intgetAverageCharWidth()Deprecated.Use getAverageCharacterWidth() insteadintgetDescent()Returns the descent of the font described by the receiver.intgetHeight()Returns the height of the font described by the receiver, measured in points.intgetLeading()Returns the leading area of the font described by the receiver.inthashCode()Returns an integer hash code for the receiver.static FontMetricswin32_new(org.eclipse.swt.internal.win32.TEXTMETRIC handle)Invokes platform specific functionality to allocate a new font metrics.
-
-
-
Field Detail
-
handle
public org.eclipse.swt.internal.win32.TEXTMETRIC handle
On Windows, handle is a Win32 TEXTMETRIC struct (Warning: This field is platform dependent)IMPORTANT: This field is not part of the SWT public API. It is marked public only so that it can be shared within the packages provided by SWT. It is not available on all platforms and should never be accessed from application code.
- Restriction:
- This field is not intended to be referenced by clients.
-
-
Method Detail
-
equals
public boolean equals(Object object)
Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.- Overrides:
equalsin classObject- Parameters:
object- the object to compare with this object- Returns:
trueif the object is the same as this object andfalseotherwise- 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() insteadReturns 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 returntruewhen passed toequalsmust return the same value for this method.- Overrides:
hashCodein classObject- Returns:
- the receiver's hash
- See Also:
equals(java.lang.Object)
-
win32_new
public static FontMetrics win32_new(org.eclipse.swt.internal.win32.TEXTMETRIC handle)
Invokes platform specific functionality to allocate a new font metrics.IMPORTANT: This method is not part of the public API for
FontMetrics. It is marked public only so that it can be shared within the packages provided by SWT. It is not available on all platforms, and should never be called from application code.- Parameters:
handle- theTEXTMETRICcontaining information about a font- Returns:
- a new font metrics object containing the specified
TEXTMETRIC - Restriction:
- This method is not intended to be referenced by clients.
-
-