public class FontHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static java.util.Map<java.lang.String,java.awt.Font> |
FONT_CACHE
A cache of AWT fonts.
|
private static java.awt.Canvas |
FONT_CANVAS
A canvas used to compute the font metrics.
|
static java.util.Map<java.awt.font.TextAttribute,java.lang.Integer> |
UNDERLINE_FONT
A special map containing the attributes of a underlined font.
|
Constructor and Description |
---|
FontHelper() |
Modifier and Type | Method and Description |
---|---|
static void |
add(java.lang.String key,
java.awt.Font font)
Add a font to cache.
|
static java.awt.Font |
createFont(FontDetails<?> details)
Create a AWT font with the specified details.
|
static java.awt.Font |
deriveFont(java.awt.Font font,
FontDetails<?> fd,
int screenRes)
Derive the given font to match the screen resolution.
|
static java.awt.Font |
get(java.lang.String key)
Get a font from cache.
|
static FontMetricsHelper |
getFontMetrics(java.lang.String key)
Get the
FontMetricsHelper for the cached font, with the given key. |
public static java.util.Map<java.awt.font.TextAttribute,java.lang.Integer> UNDERLINE_FONT
private static final java.awt.Canvas FONT_CANVAS
private static final java.util.Map<java.lang.String,java.awt.Font> FONT_CACHE
public static java.awt.Font createFont(FontDetails<?> details)
details
- The font details.public static java.awt.Font deriveFont(java.awt.Font font, FontDetails<?> fd, int screenRes)
font
- The AWT font to derive.fd
- The font details.screenRes
- The screen resolution.public static FontMetricsHelper getFontMetrics(java.lang.String key)
FontMetricsHelper
for the cached font, with the given key.
These are build using the detached FONT_CANVAS
.
key
- The font key.public static java.awt.Font get(java.lang.String key)
key
- The font key.public static void add(java.lang.String key, java.awt.Font font)
key
- The font key.font
- The AWT font.