Package limn.graphics

Record Class Font

Record Components:
family - typeface family, case-insensitive (ships "Roboto")
size - em size in logical points (like CSS px)
isBold - whether to select the bold face
isItalic - whether to select the italic face

public record Font(String family, float size, boolean isBold, boolean isItalic) extends Record
A typeface selection: family name, size in logical points, and weight/style (regular / bold / italic / bold-italic). The backend resolves the (family, isBold, isItalic) triple against its registered faces ("default", and unknown families, map to the embedded Roboto) and rasterizes glyphs at size × contentScale physical pixels, so text is crisp at any HiDPI scale; glyph bitmaps are never scaled.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Family alias that always resolves to the toolkit's embedded font.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Font(String family, float size)
    Regular weight/style at the given family and size.
    Font(String family, float size, boolean isBold, boolean isItalic)
    Creates an instance of a Font record class.
  • Method Summary

    Modifier and Type
    Method
    Description
     
     
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the value of the family record component.
    final int
    Returns a hash code value for this object.
    boolean
    Returns the value of the isBold record component.
    boolean
    Returns the value of the isItalic record component.
     
    static Font
    of(float size)
    The default family at the given size (regular).
    float
    Returns the value of the size record component.
    final String
    Returns a string representation of this record class.
    withSize(float newSize)
     

    Methods inherited from class java.lang.Object

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

    • DEFAULT_FAMILY

      public static final String DEFAULT_FAMILY
      Family alias that always resolves to the toolkit's embedded font.
      See Also:
  • Constructor Details

    • Font

      public Font(String family, float size, boolean isBold, boolean isItalic)
      Creates an instance of a Font record class.
      Parameters:
      family - the value for the family record component
      size - the value for the size record component
      isBold - the value for the isBold record component
      isItalic - the value for the isItalic record component
    • Font

      public Font(String family, float size)
      Regular weight/style at the given family and size.
  • Method Details

    • of

      public static Font of(float size)
      The default family at the given size (regular).
    • withSize

      public Font withSize(float newSize)
      Returns:
      this font at a different size (weight/style preserved).
    • bold

      public Font bold()
      Returns:
      this font in bold.
    • italic

      public Font italic()
      Returns:
      this font in italic.
    • boldItalic

      public Font boldItalic()
      Returns:
      this font in bold italic.
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • family

      public String family()
      Returns the value of the family record component.
      Returns:
      the value of the family record component
    • size

      public float size()
      Returns the value of the size record component.
      Returns:
      the value of the size record component
    • isBold

      public boolean isBold()
      Returns the value of the isBold record component.
      Returns:
      the value of the isBold record component
    • isItalic

      public boolean isItalic()
      Returns the value of the isItalic record component.
      Returns:
      the value of the isItalic record component