Package com.github.tadukoo.view.font
Class FontResourceLoader
java.lang.Object
com.github.tadukoo.view.font.FontResourceLoader
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptionprivate final StringThe path to the directory where the fonts are storedprivate final GraphicsEnvironmentTheGraphicsEnvironmentto use for theFontsprivate final com.github.tadukoo.util.logger.EasyLoggerTheEasyLoggerto use in logging any problemsprivate final booleanWhether to log warnings or not about unsupported font formatsFields inherited from interface com.github.tadukoo.view.font.FontConstants
BLACK, BLACK_ITALIC, BOLD, BOLD_ITALIC, EXTRA_LIGHT, EXTRA_LIGHT_ITALIC, ITALIC, LIGHT, LIGHT_ITALIC, MEDIUM, MEDIUM_ITALIC, OTF, REGULAR, SEMI_BOLD, SEMI_BOLD_ITALIC, THIN, THIN_ITALIC, TTF -
Constructor Summary
ConstructorsConstructorDescriptionFontResourceLoader(boolean logWarnings, com.github.tadukoo.util.logger.EasyLogger logger, GraphicsEnvironment graphEnv, String fontDirectoryPath) Constructs a new FontResourceLoader with the givenEasyLogger,GraphicsEnvironment, and fonts directory -
Method Summary
Modifier and TypeMethodDescriptioncom.github.tadukoo.util.logger.EasyLoggerbooleanloadFont(FontFamily font, boolean requireLoadAll) Loads a singleFontFamily.loadFonts(List<FontFamily> fonts, boolean requireLoadAll) Loads a collection ofFont Families.
-
Field Details
-
logWarnings
private final boolean logWarningsWhether to log warnings or not about unsupported font formats -
logger
private final com.github.tadukoo.util.logger.EasyLogger loggerTheEasyLoggerto use in logging any problems -
graphEnv
TheGraphicsEnvironmentto use for theFonts -
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 givenEasyLogger,GraphicsEnvironment, and fonts directory- Parameters:
logWarnings- Whether to log warnings or not about unsupported font formatslogger- TheEasyLoggerto use in logging any problems - may be null if logWarnings = falsegraphEnv- TheGraphicsEnvironmentto use for theFontsfontDirectoryPath- 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
EasyLoggerto use in logging any problems
-
getGraphEnv
- Returns:
- The
GraphicsEnvironmentto use for theFonts
-
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 ofFont Families. Just iterates over the list callingloadFont(FontFamily, boolean).- Parameters:
fonts- The list ofFont Familiesto be loadedrequireLoadAll- 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 problemsFontFormatException- If the Fonts themselves have issues
-
loadFont
public String loadFont(FontFamily font, boolean requireLoadAll) throws IOException, FontFormatException Loads a singleFontFamily. 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- TheFontFamilyto be loadedrequireLoadAll- 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 problemsFontFormatException- If the Font itself has issues
-