Module com.googlecode.lanterna
Class AWTTerminalFontConfiguration
java.lang.Object
com.googlecode.lanterna.terminal.swing.AWTTerminalFontConfiguration
- Direct Known Subclasses:
SwingTerminalFontConfiguration
This class encapsulates the font information used by an
AWTTerminal. By customizing this class, you can
choose which fonts are going to be used by an AWTTerminal component and some other related settings.- Author:
- martin
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumControls how the SGR bold will take effect when enabled on a character. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default font size used unless overridden -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAWTTerminalFontConfiguration(boolean useAntiAliasing, AWTTerminalFontConfiguration.BoldMode boldMode, Font... fontsInOrderOfPriority) -
Method Summary
Modifier and TypeMethodDescriptionstatic Font[]filterMonospaced(Font... fonts) Given an array of fonts, returns another array with only the ones that are monospaced.static AWTTerminalFontConfigurationThis is the default font settings that will be used if you don't specify anythingstatic AWTTerminalFontConfigurationgetDefaultOfSize(int fontSize) Returns the default font settings except for a custom font size to use.intReturns the vertical size in pixels of the fonts configuredintReturns the horizontal size in pixels of the fonts configuredbooleanReturnstrueif anti-aliasing has been enabled,falseotherwisestatic AWTTerminalFontConfigurationnewInstance(Font... fontsInOrderOfPriority) Creates a new font configuration from a list of fonts in order of priority.protected static Font[]Returns the default font to use depending on the platformprotected static Font[]selectDefaultFont(int fontSize) Returns the default font to use depending on the platform
-
Field Details
-
DEFAULT_FONT_SIZE
public static final int DEFAULT_FONT_SIZEThe default font size used unless overridden- See Also:
-
-
Constructor Details
-
AWTTerminalFontConfiguration
protected AWTTerminalFontConfiguration(boolean useAntiAliasing, AWTTerminalFontConfiguration.BoldMode boldMode, Font... fontsInOrderOfPriority)
-
-
Method Details
-
selectDefaultFont
Returns the default font to use depending on the platform- Returns:
- Default font to use, system-dependent
-
selectDefaultFont
Returns the default font to use depending on the platform- Parameters:
fontSize- The size of the fonts to use- Returns:
- Default font to use, system-dependent
-
getDefault
This is the default font settings that will be used if you don't specify anything- Returns:
- An
AWTTerminalfont configuration object with default values set up
-
getDefaultOfSize
Returns the default font settings except for a custom font size to use.- Parameters:
fontSize- Size of the font- Returns:
- An
AWTTerminalfont configuration object with default values set up
-
filterMonospaced
Given an array of fonts, returns another array with only the ones that are monospaced. The fonts in the result will have the same order as in which they came in. A font is considered monospaced if the width of 'i' and 'W' is the same.- Parameters:
fonts- Fonts to filter monospaced fonts from- Returns:
- Array with the fonts from the input parameter that were monospaced
-
newInstance
Creates a new font configuration from a list of fonts in order of priority. This works by having the terminal attempt to draw each character with the fonts in the order they are specified in and stop once we find a font that can actually draw the character. For ASCII characters, it's very likely that the first font will always be used.- Parameters:
fontsInOrderOfPriority- Fonts to use when drawing text, in order of priority- Returns:
- Font configuration built from the font list
-
getFontWidth
public int getFontWidth()Returns the horizontal size in pixels of the fonts configured- Returns:
- Horizontal size in pixels of the fonts configured
-
getFontHeight
public int getFontHeight()Returns the vertical size in pixels of the fonts configured- Returns:
- Vertical size in pixels of the fonts configured
-
isAntiAliased
public boolean isAntiAliased()Returnstrueif anti-aliasing has been enabled,falseotherwise- Returns:
trueif anti-aliasing has been enabled,falseotherwise
-