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
Modifier and TypeFieldDescriptionprivate final String
The path to the directory where the fonts are storedprivate final GraphicsEnvironment
TheGraphicsEnvironment
to use for theFont
sprivate final com.github.tadukoo.util.logger.EasyLogger
TheEasyLogger
to use in logging any problemsprivate final boolean
Whether 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
ConstructorDescriptionFontResourceLoader
(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.EasyLogger
boolean
loadFont
(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 loggerTheEasyLogger
to use in logging any problems -
graphEnv
TheGraphicsEnvironment
to use for theFont
s -
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
- TheEasyLogger
to use in logging any problems - may be null if logWarnings = falsegraphEnv
- TheGraphicsEnvironment
to use for theFont
sfontDirectoryPath
- 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
- Returns:
- The
GraphicsEnvironment
to use for theFont
s
-
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 Families
to 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
- TheFontFamily
to 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
-