Class FontResourceLoader

java.lang.Object
com.github.tadukoo.view.font.FontResourceLoader
All Implemented Interfaces:
FontConstants

public class FontResourceLoader extends Object implements FontConstants
Font Resource Loader is used to load Font Families.
Since:
Alpha v.0.2
Version:
Alpha v.0.3
Author:
Logan Ferree (Tadukoo)
  • Field Details

    • logWarnings

      private final boolean logWarnings
      Whether to log warnings or not about unsupported font formats
    • logger

      private final com.github.tadukoo.util.logger.EasyLogger logger
      The EasyLogger to use in logging any problems
    • graphEnv

      private final GraphicsEnvironment graphEnv
      The GraphicsEnvironment to use for the Fonts
    • fontDirectoryPath

      private final String fontDirectoryPath
      The path to the directory where the fonts are stored
  • Constructor Details

    • FontResourceLoader

      public FontResourceLoader(boolean logWarnings, com.github.tadukoo.util.logger.EasyLogger logger, GraphicsEnvironment graphEnv, String fontDirectoryPath)
      Constructs a new FontResourceLoader with the given EasyLogger, GraphicsEnvironment, and fonts directory
      Parameters:
      logWarnings - Whether to log warnings or not about unsupported font formats
      logger - The EasyLogger to use in logging any problems - may be null if logWarnings = false
      graphEnv - The GraphicsEnvironment to use for the Fonts
      fontDirectoryPath - The path to the directory where the fonts are stored
  • Method Details

    • getLogWarnings

      public boolean getLogWarnings()
      Returns:
      Whether to log warnings or not about unsupported font formats
    • getLogger

      public com.github.tadukoo.util.logger.EasyLogger getLogger()
      Returns:
      The EasyLogger to use in logging any problems
    • getGraphEnv

      public GraphicsEnvironment getGraphEnv()
      Returns:
      The GraphicsEnvironment to use for the Fonts
    • getFontDirectoryPath

      public String getFontDirectoryPath()
      Returns:
      The path to the directory where the fonts are stored
    • loadFonts

      public List<String> loadFonts(List<FontFamily> fonts, boolean requireLoadAll) throws IOException, FontFormatException
      Loads a collection of Font Families. Just iterates over the list calling loadFont(FontFamily, boolean).
      Parameters:
      fonts - The list of Font Families to be loaded
      requireLoadAll - Whether all variants need loaded for each Font Family or not
      Returns:
      A List of fonts to be used (will choose alternates if applicable, and return nulls for issues)
      Throws:
      IOException - For file loading problems
      FontFormatException - If the Fonts themselves have issues
    • loadFont

      public String loadFont(FontFamily font, boolean requireLoadAll) throws IOException, FontFormatException
      Loads a single FontFamily. If an alternate is specified and we can't find the given font, the alternate will be loaded and its name returned as a string. If we fail to load the font, a null will be returned instead.
      Parameters:
      font - The FontFamily to be loaded
      requireLoadAll - Whether all variants need loaded for the Font Family or not
      Returns:
      The font to be used (will choose alternate if applicable, and return null for issues)
      Throws:
      IOException - For file loading problems
      FontFormatException - If the Font itself has issues