Class FontUtil
- java.lang.Object
-
- org.qdl_lang.gui.FontUtil
-
public class FontUtil extends Object
Created by Jeff Gaynor
on 6/27/24 at 7:08 AM
-
-
Field Summary
Fields Modifier and Type Field Description static String
STYLE_BOLD
static String
STYLE_BOLD_ITALIC
static String
STYLE_ITALIC
static String
STYLE_ITALIC_BOLD
static String
STYLE_PLAIN
-
Constructor Summary
Constructors Constructor Description FontUtil()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static boolean
checkSingleFont(String name, int type, int size)
static List<String>
findQDLFonts()
A utility that runs through all of the fons on your system and finds those that are able to output all of the QDL character set.static List<String>
findQDLFonts(double weight)
static String
findUnsupportedCharacters(Font font, char[] y)
static String
findUnsupportedCharacters(Font font, String x)
A font utility to check the support for a font.protected String
fontReport(Font font)
static String
getStyle(Font font)
Convert the Swing constant for the font style into the QDL name.static int
getStyle(String styleName)
Convert the QDL names for font styles into the constant that Swing understands.
Caveat any unknown font style is rendered as the default, which isFont.BOLD
-
-
-
Field Detail
-
STYLE_PLAIN
public static final String STYLE_PLAIN
- See Also:
- Constant Field Values
-
STYLE_BOLD
public static final String STYLE_BOLD
- See Also:
- Constant Field Values
-
STYLE_ITALIC
public static final String STYLE_ITALIC
- See Also:
- Constant Field Values
-
STYLE_BOLD_ITALIC
public static final String STYLE_BOLD_ITALIC
- See Also:
- Constant Field Values
-
STYLE_ITALIC_BOLD
public static final String STYLE_ITALIC_BOLD
- See Also:
- Constant Field Values
-
-
Method Detail
-
getStyle
public static String getStyle(Font font)
Convert the Swing constant for the font style into the QDL name.- Parameters:
font
-- Returns:
-
getStyle
public static int getStyle(String styleName)
Convert the QDL names for font styles into the constant that Swing understands.
Caveat any unknown font style is rendered as the default, which isFont.BOLD
- Parameters:
styleName
-- Returns:
-
findQDLFonts
public static List<String> findQDLFonts() throws Throwable
A utility that runs through all of the fons on your system and finds those that are able to output all of the QDL character set.The issue
The issue is that Swing is restricted to TrueType fonts and very few of those have all the unicode characters in them. Really only the built-in Java is reliable. This checks by using the
QDLConstants.UNICODE_CHARS
and checks how much of it is printable. Any result from that greater than -1 flags which character Swing fails at.This is compounded by the fact that other font formats might include more. For instance "Ubuntu Mono" as an Open Type font has everything, but several characters as missing in the True Type version. Applications may be clever too and auto switch to replace a missing character from another font or member of a family of fonts. Can't do that in Swing either on a per character basis.
Common failures are the APL symbols for the apply and floor operator, or the alternate Greek letters for rho, theta, etc. Math symbol sets had the latter, only APL character sets reliably have the first, but usually don't have any Math symbols.
- Returns:
- Throws:
Throwable
-
findQDLFonts
public static List<String> findQDLFonts(double weight) throws Throwable
- Throws:
Throwable
-
checkSingleFont
public static boolean checkSingleFont(String name, int type, int size)
-
findUnsupportedCharacters
public static String findUnsupportedCharacters(Font font, String x)
A font utility to check the support for a font. This returns the string of characters that this font cannot display.- Parameters:
font
-x
-- Returns:
-
-