Class Fonts

java.lang.Object
edu.cnu.mdi.ui.fonts.Fonts

public final class Fonts extends Object
Centralized font factory for MDI.

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 Details

    • monsterFont

      public static volatile Font monsterFont
    • hugeFont

      public static volatile Font hugeFont
    • largeFont

      public static volatile Font largeFont
    • biggerFont

      public static volatile Font biggerFont
    • defaultFont

      public static volatile Font defaultFont
    • defaultLargeFont

      public static volatile Font defaultLargeFont
    • defaultBoldFont

      public static volatile Font defaultBoldFont
    • defaultItalicFont

      public static volatile Font defaultItalicFont
    • mediumFont

      public static volatile Font mediumFont
    • mediumBoldFont

      public static volatile Font mediumBoldFont
    • mediumItalicFont

      public static volatile Font mediumItalicFont
    • mediumItalicBoldFont

      public static volatile Font mediumItalicBoldFont
    • tweenFont

      public static volatile Font tweenFont
    • tweenBoldFont

      public static volatile Font tweenBoldFont
    • tweenItalicFont

      public static volatile Font tweenItalicFont
    • smallFont

      public static volatile Font smallFont
    • tinyFont

      public static volatile Font tinyFont
    • defaultMono

      public static volatile Font defaultMono
    • mono

      public static volatile Font mono
    • smallMono

      public static volatile Font smallMono
    • tinyMono

      public static volatile Font 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

      public static Font plainFontDelta(int sizeDelta)
      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

      public static Font boldFontDelta(int sizeDelta)
      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

      public static Font commonFont(int style, int size)
      Derive a font from the active LookAndFeel family at an absolute point size.
      Parameters:
      style - AWT font style bitmask
      size - requested point size
      Returns:
      the derived font, clamped to the minimum supported size
    • scaleFont

      public static Font scaleFont(Font font, float scaleFactor)
      Scale an existing font by a multiplicative factor.
      Parameters:
      font - font to scale
      scaleFactor - positive scale factor
      Returns:
      the scaled font