Package org.openpatch.scratch.internal
Class Font
java.lang.Object
org.openpatch.scratch.internal.Font
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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic processing.core.PFontprocessing.core.PFontgetFont(int targetSize) getName()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 voidreset()Forgets every font loaded so far, so that a changed font setting takes effect instead of the old one lingering in the cache.
-
Field Details
-
defaultFont
public static processing.core.PFont defaultFontThe default font.
-
-
Constructor Details
-
Font
Constructs a font with the specified name and path. The underlying font file is not actually loaded untilgetFont(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 fontpath- the path to the font file
-
Font
Copy constructor.- Parameters:
font- the font to copy
-
-
Method Details
-
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
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)
-