Record Class TextMetrics
java.lang.Object
java.lang.Record
cloud.opencode.base.image.codec.font.TextMetrics
- Record Components:
width- horizontal advance in pixels | 水平 advance(像素)ascent- pixels above baseline (positive) | 基线以上像素(正)descent- pixels below baseline (negative per stb convention) | 基线以下像素(按 stb 约定为负)lineGap- recommended extra gap between lines in pixels | 建议的额外行间隔(像素)
Pixel-space metrics for a text run rendered at a specific pixel height.
给定像素高度下,一段文本的像素空间度量。
All values are in pixels at the requested font size. Per
stb_truetype convention, descent is negative (below the
baseline). Use lineHeight() to get the natural single-line height
including lineGap.
所有值为请求字号下的像素值。按 stb_truetype 约定,descent
为负(基线以下)。使用 lineHeight() 获取包含 lineGap 的自然
单行高度。
Security | 安全性:
- Thread-safe: Yes - immutable record. - 线程安全: 是 — 不可变 record。
- Since:
- JDK 25, opencode-base-image-codec V1.0.4
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionTextMetrics(int width, int ascent, int descent, int lineGap) Creates an instance of aTextMetricsrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintascent()Returns the value of theascentrecord component.intdescent()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.intlineGap()Returns the value of thelineGaprecord component.intTotal line height:ascent - descent + lineGap.final StringtoString()Returns a string representation of this record class.intwidth()Returns the value of thewidthrecord component.
-
Constructor Details
-
TextMetrics
public TextMetrics(int width, int ascent, int descent, int lineGap) Creates an instance of aTextMetricsrecord class.
-
-
Method Details
-
lineHeight
public int lineHeight()Total line height:ascent - descent + lineGap. 总行高:ascent - descent + lineGap。- Returns:
- line height in pixels | 像素行高
-
toString
-
hashCode
-
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 thecomparemethod from their corresponding wrapper classes. -
width
-
ascent
-
descent
-
lineGap
-