Record Class GlyphMetrics

java.lang.Object
java.lang.Record
cloud.opencode.base.image.codec.font.GlyphMetrics
Record Components:
advanceWidth - horizontal advance in pixels | 水平 advance(像素)
leftSideBearing - left side bearing in pixels | 左侧 bearing(像素)
x0 - bbox left (inclusive) | 包围盒左(含)
y0 - bbox top (inclusive, often negative) | 包围盒上 (含,常为负)
x1 - bbox right (exclusive) | 包围盒右(不含)
y1 - bbox bottom (exclusive) | 包围盒下(不含)

public record GlyphMetrics(int advanceWidth, int leftSideBearing, int x0, int y0, int x1, int y1) extends Record
Pixel-space metrics for a single glyph (codepoint) at a specific pixel height. 给定像素高度下,单个字形(codepoint)的像素空间度量。

advanceWidth and leftSideBearing are in pixels at the requested font size. The bounding box (x0, y0) (top-left, inclusive) and (x1, y1) (bottom-right, exclusive) is in image-space pixels with y growing downward; coordinates are relative to the pen position (the baseline x and y) — i.e. y0 is typically negative (above baseline) for ascending glyphs.

advanceWidthleftSideBearing 为请求字号下的像素。 包围盒 (x0, y0)(左上,含)与 (x1, y1)(右下,不含)位于图像 空间像素中,y 向下增长;坐标相对于笔位(基线 x 与 y)— 例如对升部字形 y0 通常为负(基线以上)。

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

    Constructors
    Constructor
    Description
    GlyphMetrics(int advanceWidth, int leftSideBearing, int x0, int y0, int x1, int y1)
    Creates an instance of a GlyphMetrics record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the value of the advanceWidth record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    int
    Glyph bbox height in pixels.
    int
    Glyph bbox width in pixels.
    final int
    Returns a hash code value for this object.
    int
    Returns the value of the leftSideBearing record component.
    final String
    Returns a string representation of this record class.
    int
    x0()
    Returns the value of the x0 record component.
    int
    x1()
    Returns the value of the x1 record component.
    int
    y0()
    Returns the value of the y0 record component.
    int
    y1()
    Returns the value of the y1 record component.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • GlyphMetrics

      public GlyphMetrics(int advanceWidth, int leftSideBearing, int x0, int y0, int x1, int y1)
      Creates an instance of a GlyphMetrics record class.
      Parameters:
      advanceWidth - the value for the advanceWidth record component
      leftSideBearing - the value for the leftSideBearing record component
      x0 - the value for the x0 record component
      y0 - the value for the y0 record component
      x1 - the value for the x1 record component
      y1 - the value for the y1 record component
  • Method Details

    • glyphWidth

      public int glyphWidth()
      Glyph bbox width in pixels. 字形包围盒像素宽。
      Returns:
      x1 - x0 | x1 - x0
    • glyphHeight

      public int glyphHeight()
      Glyph bbox height in pixels. 字形包围盒像素高。
      Returns:
      y1 - y0 | y1 - y0
    • toString

      public final String 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.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • 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.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • advanceWidth

      public int advanceWidth()
      Returns the value of the advanceWidth record component.
      Returns:
      the value of the advanceWidth record component
    • leftSideBearing

      public int leftSideBearing()
      Returns the value of the leftSideBearing record component.
      Returns:
      the value of the leftSideBearing record component
    • x0

      public int x0()
      Returns the value of the x0 record component.
      Returns:
      the value of the x0 record component
    • y0

      public int y0()
      Returns the value of the y0 record component.
      Returns:
      the value of the y0 record component
    • x1

      public int x1()
      Returns the value of the x1 record component.
      Returns:
      the value of the x1 record component
    • y1

      public int y1()
      Returns the value of the y1 record component.
      Returns:
      the value of the y1 record component