Class Fonts
Under FlatLaf the canonical "common" font is the LookAndFeel default font (UI
key "defaultFont"). This class derives every application font from
that base so typography stays consistent across platforms and themes.
The named fonts form a size ladder expressed as point deltas from the base UI size, so they track the platform/theme default rather than using hard-coded absolute sizes:
monster (+8) > huge (+5) > large (+2) > bigger (+1) > default (0)
> medium (-1) > tween (-2) > small (-3) > tiny (-4)
with bold/italic variants derived at the same sizes. Monospaced fonts follow a
parallel ladder built on Font.MONOSPACED.
Call refresh() once after installing FlatLaf, and again after any
theme switch, to (re)populate the named fonts. The named fields are intended
to be read on the Swing event dispatch thread.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic FontboldFontDelta(int sizeDelta) Convenience method to derive a bold font from the base UI font using a size delta (in points) relative to the base.static FontcommonFont(int style, int size) Derive a font from the active LookAndFeel family at an absolute point size.static FontplainFontDelta(int sizeDelta) Convenience method to derive a plain font from the base UI font using a size delta (in points) relative to the base.static voidrefresh()Refresh the named fonts from the current LookAndFeel.static FontScale an existing font by a multiplicative factor.
-
Field Details
-
monsterFont
-
hugeFont
-
largeFont
-
biggerFont
-
defaultFont
-
defaultLargeFont
-
defaultBoldFont
-
defaultItalicFont
-
mediumFont
-
mediumBoldFont
-
mediumItalicFont
-
mediumItalicBoldFont
-
tweenFont
-
tweenBoldFont
-
tweenItalicFont
-
smallFont
-
tinyFont
-
defaultMono
-
mono
-
smallMono
-
tinyMono
-
-
Method Details
-
refresh
public static void refresh()Refresh the named fonts from the current LookAndFeel.Clears the derived-font cache and rebuilds every named font relative to the current base UI size. Call this after installing FlatLaf and again after any theme switch.
-
plainFontDelta
Convenience method to derive a plain font from the base UI font using a size delta (in points) relative to the base.- Parameters:
sizeDelta- points to add to the base size (may be negative)- Returns:
- the derived plain font
-
boldFontDelta
Convenience method to derive a bold font from the base UI font using a size delta (in points) relative to the base.- Parameters:
sizeDelta- points to add to the base size (may be negative)- Returns:
- the derived bold font
-
commonFont
Derive a font from the active LookAndFeel family at an absolute point size.- Parameters:
style- AWT font style bitmasksize- requested point size- Returns:
- the derived font, clamped to the minimum supported size
-
scaleFont
Scale an existing font by a multiplicative factor.- Parameters:
font- font to scalescaleFactor- positive scale factor- Returns:
- the scaled font
-