Record Class FontFace

java.lang.Object
java.lang.Record
nl.colorize.multimedialib.stage.FontFace

public record FontFace(MediaLoader owner, FilePointer origin, String family, FontStyle style) extends Record
Describes a TrueType or FreeType font that can be used by the renderer to draw text. The font consists of the font family and the font style.

MultimediaLib does not rely on system fonts, any fonts used in the application must be loaded explicitly using MediaLoader.loadFont(FilePointer, String, FontStyle), which will loads the font from a resource file packaged with the application. Applications should therefore not attempt to create instances of this class directly, instances are obtained from the MediaLoader when the font is first loaded.

  • Constructor Details

    • FontFace

      public FontFace(MediaLoader owner, FilePointer origin, String family, FontStyle style)
      Creates an instance of a FontFace record class.
      Parameters:
      owner - the value for the owner record component
      origin - the value for the origin record component
      family - the value for the family record component
      style - the value for the style record component
  • Method Details

    • derive

      public FontFace derive(FontStyle style)
    • derive

      public FontFace derive(int size)
    • derive

      public FontFace derive(int size, boolean bold)
    • derive

      public FontFace derive(ColorRGB color)
    • scale

      public FontFace scale(Canvas canvas)
      Derives a version of this font that is scaled to match the specified display mode. If the canvas is zoomed in or zoomed out, the size indicated in the font style should also be scaled accordingly.
    • toString

      public 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 Objects::equals(Object,Object).
      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.
    • owner

      public MediaLoader owner()
      Returns the value of the owner record component.
      Returns:
      the value of the owner record component
    • origin

      public FilePointer origin()
      Returns the value of the origin record component.
      Returns:
      the value of the origin record component
    • family

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

      public FontStyle style()
      Returns the value of the style record component.
      Returns:
      the value of the style record component