Class Font

java.lang.Object
org.openpatch.scratch.internal.Font

public class Font extends Object
The Font class represents a font that can be used to render text on the screen. It supports various functionalities such as loading fonts from files, setting font sizes, and getting the font object for a specific size.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static processing.core.PFont
    The default font.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Font(String name, String path)
    Constructs a font with the specified name and path.
    Font(Font font)
    Copy constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    static processing.core.PFont
     
    processing.core.PFont
    getFont(int targetSize)
     
    Returns the name of the font.
    static AbstractMap<Integer,processing.core.PFont>
    Loads a font from the specified path and returns a map of font sizes.
    static void
    Forgets every font loaded so far, so that a changed font setting takes effect instead of the old one lingering in the cache.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • defaultFont

      public static processing.core.PFont defaultFont
      The default font.
  • Constructor Details

    • Font

      public Font(String name, String path)
      Constructs a font with the specified name and path. The underlying font file is not actually loaded until getFont(int) is first called, so constructing a Font (e.g. via a Sprite that has not been shown yet) does not require a running Applet.
      Parameters:
      name - the name of the font
      path - the path to the font file
    • Font

      public Font(Font font)
      Copy constructor.
      Parameters:
      font - the font to copy
  • Method Details

    • getName

      public String getName()
      Returns the name of the font.
      Returns:
      the name of the font
    • reset

      public static void reset()
      Forgets every font loaded so far, so that a changed font setting takes effect instead of the old one lingering in the cache.
    • getDefaultFont

      public static processing.core.PFont getDefaultFont()
    • loadFont

      public static AbstractMap<Integer,processing.core.PFont> loadFont(String path)
      Loads a font from the specified path and returns a map of font sizes.
      Parameters:
      path - the path to the font file
      Returns:
      a map of font sizes
    • getFont

      public processing.core.PFont getFont(int targetSize)