Class FontUtil

java.lang.Object
org.fife.ui.rtextarea.FontUtil

public final class FontUtil extends Object
Utility methods related to fonts.
  • Method Details

    • createFont

      public static Font createFont(String family, int style, int size)
      Creates and returns a font with a default fallback font configured.
      Parameters:
      family - The font family.
      style - The font style.
      size - The font size.
      Returns:
      The font.
    • deriveFont

      public static Font deriveFont(Font baseFont, String newFamily)
      Returns a new font with all properties the same as a base font, but with a new font family. This saves a few lines of code around creating a Map, since deriving a font with a new family can be tricky to do while avoiding overwriting all other TextAttributes.
      Parameters:
      baseFont - The font to start with.
      newFamily - The new font family, or null for no change.
      Returns:
      The new font.
      See Also:
    • deriveFont

      public static Font deriveFont(Font baseFont, String newFamily, Integer newStyle, Number newSize)
      Returns a new font with all properties the same as a base font, but with optional changes. This saves a few lines of code around creating a Map, since deriving a font with a new family can be tricky to do while avoiding overwriting all other TextAttributes.
      Parameters:
      baseFont - The font to start with.
      newFamily - The new font family, or null for no change.
      newStyle - The new font style, or null for no change.
      newSize - The new font size, or null for no change.
      Returns:
      The new font.
      See Also:
    • getDefaultMonospacedFont

      public static Font getDefaultMonospacedFont()
      Returns the default monospaced font for this operating system.
      Returns:
      The default font.