Package limn.graphics
Record Class TextMetrics
java.lang.Object
java.lang.Record
limn.graphics.TextMetrics
- Record Components:
width- advance width of the whole stringascent- distance from baseline to the font's ascender (positive up)descent- distance from baseline to the descender (positive down)lineHeight- recommended baseline-to-baseline distance (ascent + descent + line gap)
public record TextMetrics(float width, float ascent, float descent, float lineHeight)
extends Record
Measured extents of a single line of text, in logical points, relative to
the baseline. Values are unquantized (independent of the monitor content
scale), so layout decisions match what
drawText renders at any
HiDPI factor.-
Constructor Summary
ConstructorsConstructorDescriptionTextMetrics(float width, float ascent, float descent, float lineHeight) Creates an instance of aTextMetricsrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfloatascent()Returns the value of theascentrecord component.floatdescent()Returns the value of thedescentrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.floatheight()floatReturns the value of thelineHeightrecord component.final StringtoString()Returns a string representation of this record class.floatwidth()Returns the value of thewidthrecord component.
-
Constructor Details
-
TextMetrics
public TextMetrics(float width, float ascent, float descent, float lineHeight) Creates an instance of aTextMetricsrecord class.- Parameters:
width- the value for thewidthrecord componentascent- the value for theascentrecord componentdescent- the value for thedescentrecord componentlineHeight- the value for thelineHeightrecord component
-
-
Method Details
-
height
public float height()- Returns:
- total height of the line box (ascent + descent)
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
width
public float width()Returns the value of thewidthrecord component.- Returns:
- the value of the
widthrecord component
-
ascent
public float ascent()Returns the value of theascentrecord component.- Returns:
- the value of the
ascentrecord component
-
descent
public float descent()Returns the value of thedescentrecord component.- Returns:
- the value of the
descentrecord component
-
lineHeight
public float lineHeight()Returns the value of thelineHeightrecord component.- Returns:
- the value of the
lineHeightrecord component
-