Class Fonts

java.lang.Object
com.luciad.text.Fonts

public final class Fonts extends Object
This class allows you to register custom fonts.

By default, the following fonts are supported:

Font Name Font
Arial Liberation Sans Serif
Arial Narrow Liberation Sans Narrow
Arial Black Archivo Black
Bitstream Vera Sans Bistream Vera Sans
Calibri Open Sans
Console Inconsolata
Noto Sans Noto Sans
Times New Roman Liberation Serif

For international language support, the Noto font from Google was added. As the Noto font is very extensive, only a small subset of fonts is available. List of currently supported alphabets in the Noto font:

  • Arabic
  • Armenian
  • Cyrillic
  • Devanagari
  • Georgian
  • Greek
  • Gujarati
  • Gurmukhi
  • Hangul (Koran)
  • Han
  • Hebrew
  • Hiragana
  • Kannada
  • Katakana
  • Laotian
  • Latin
  • Malayalam
  • Oriya
  • Tamil
  • Telugu
  • Thai

Note that these are all vector fonts, so for these default fonts any font size can be used.

You can register additional fonts using the Fonts#registerFont function.

Since:
2024.1
  • Method Details Link icon

    • registerFont Link icon

      public static void registerFont(@NotNull String fontName, @NotNull String fontPath) throws IllegalArgumentException
      Registers an additional font that can be used in alongside the default ones, for example for use in a TextStyle.

      Using a font name that is already in use overwrites it, this includes the fonts available by default.

      Node: registering bitmap fonts instead of vector fonts is supported, but it may have downsides:

      • not all font sizes are supported. Using an unsupported size when using bitmap fonts will result in an exception
      • HiDPI support for bitmap fonts is limited: text quality may be lower than the quality when using vector fonts
      Parameters:
      fontName - identifier of the font.
      fontPath - the path to the font file.
      Throws:
      IllegalArgumentException - when the path is invalid.
    • registerFont Link icon

      public static void registerFont(@NotNull FontConfig fontConfig) throws IllegalArgumentException
      Registers an additional font that can be used in alongside the default ones, for example for use in a TextStyle.

      Using a font name that is already in use overwrites it, this includes the fonts available by default.

      Node: registering bitmap fonts instead of vector fonts is supported, but it may have downsides:

      • not all font sizes are supported. Using an unsupported size when using bitmap fonts will result in an exception
      • HiDPI support for bitmap fonts is limited: text quality may be lower than the quality when using vector fonts
      Parameters:
      fontConfig - the configuration of the font
      Throws:
      IllegalArgumentException - when one of the paths is invalid.
    • getSupportedFontSizes Link icon

      @NotNull public static List<Long> getSupportedFontSizes(@NotNull String fontName) throws IllegalArgumentException
      This function is used to see which font sizes are supported by a bitmap font.

      Not necessary for vector fonts, also known as outline fonts, since they can scale to any size. For these fonts, and empty list is returned.

      Parameters:
      fontName - identifier of the font.
      Returns:
      A list of support font sizes. For vector fonts an empty list is returned.
      Throws:
      IllegalArgumentException - when the font is not registered.