Package limn.graphics

Interface FontLoader

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface FontLoader
Registers a font file the application ships, so its family becomes usable by name.

Installed by the backend through Fonts.installLoader(limn.graphics.FontLoader); UNAVAILABLE is the headless default, and it refuses rather than pretending a family exists.

This is the only way a face that is neither bundled in the backend nor installed in the operating system can enter the font stack. Without it an application that ships its own typeface has to ask the user to install it, and a capture or test that names such a family silently gets the default face instead, a difference nothing downstream can see.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final FontLoader
    No backend / headless: there is nothing that can parse a font file.
  • Method Summary

    Modifier and Type
    Method
    Description
    load(Path file)
    Reads the faces in one font file and registers them under their own family name.
  • Field Details

    • UNAVAILABLE

      static final FontLoader UNAVAILABLE
      No backend / headless: there is nothing that can parse a font file.
  • Method Details

    • load

      String load(Path file)
      Reads the faces in one font file and registers them under their own family name.

      Synchronous, and on the calling thread. What is read here is the file's name table (the family and style strings, kilobytes), not its glyphs; those are parsed on first use, the same way an operating-system face is. Registration has to complete before it returns, because the caller's next act is to name the family in a widget or in Fonts.setDefaultFamily(java.lang.String), and a family that is not registered yet resolves to the default face.

      Parameters:
      file - font file (TrueType, OpenType, or a collection); a relative path resolves against the process working directory
      Returns:
      the family name the faces registered under; pass this to Fonts.setDefaultFamily(java.lang.String) or to Font, rather than assuming the name from the file name, which need not match what the file declares
      Throws:
      UncheckedIOException - if the file cannot be read
      IllegalArgumentException - if it carries no usable face
      UnsupportedOperationException - if no backend is installed