java.lang.Object
com.dua3.utility.swing.SwingFontUtil
- All Implemented Interfaces:
com.dua3.utility.text.FontUtil<Font>
Utility class for getting font properties through AWT. This class should normally not used directly by user code
as the functionality should be available in the
TextUtil utility class which
in turn uses this class via SPI (Java ServiceProvider interface).
See usage of FontUtil in TextUtil for details.-
Nested Class Summary
Nested classes/interfaces inherited from interface com.dua3.utility.text.FontUtil
com.dua3.utility.text.FontUtil.Bounds -
Field Summary
Fields inherited from interface com.dua3.utility.text.FontUtil
FONT_TYPE_TRUETYPE, NO_IMPLEMENTATION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvert(com.dua3.utility.text.Font font)com.dua3.utility.text.FontUtil.BoundsgetTextBounds(CharSequence s, com.dua3.utility.text.Font f)com.dua3.utility.text.FontUtil.BoundsgetTextBounds(CharSequence text, Font awtFont)Calculate the string bounds of a text using the font passed as argument.doublegetTextHeight(CharSequence s, com.dua3.utility.text.Font f)doublegetTextHeight(CharSequence text, Font awtFont)Calculate the height of a text using the font passed as argument.doublegetTextWidth(CharSequence s, com.dua3.utility.text.Font f)doublegetTextWidth(CharSequence text, Font awtFont)Calculate the width of a text using the font passed as argument.Optional<com.dua3.utility.text.Font>loadFont(String type, InputStream in)stringBounds(CharSequence text, com.dua3.utility.text.Font font)Calculate the string bounds of a text using the font passed as argument.stringBounds(CharSequence text, Font awtFont)Calculate the string bounds of a text using the font passed as argument.
-
Constructor Details
-
SwingFontUtil
public SwingFontUtil()
-
-
Method Details
-
stringBounds
Calculate the string bounds of a text using the font passed as argument.- Parameters:
text- the textfont- the font- Returns:
- the text's bounds (positioned at the origin)
-
stringBounds
Calculate the string bounds of a text using the font passed as argument.- Parameters:
text- the textawtFont- the font- Returns:
- the text's bounds (positioned at the origin)
-
getTextBounds
Calculate the string bounds of a text using the font passed as argument.- Parameters:
text- the textawtFont- the font- Returns:
- the text's bounds (positioned at the origin)
-
getTextHeight
Calculate the height of a text using the font passed as argument.- Parameters:
text- the textawtFont- the font- Returns:
- the text's bounds (positioned at the origin)
-
getTextWidth
Calculate the width of a text using the font passed as argument.- Parameters:
text- the textawtFont- the font- Returns:
- the text's bounds (positioned at the origin)
-
getTextBounds
public com.dua3.utility.text.FontUtil.Bounds getTextBounds(CharSequence s, com.dua3.utility.text.Font f)- Specified by:
getTextBoundsin interfacecom.dua3.utility.text.FontUtil<Font>
-
getTextHeight
- Specified by:
getTextHeightin interfacecom.dua3.utility.text.FontUtil<Font>
-
loadFont
public Optional<com.dua3.utility.text.Font> loadFont(String type, InputStream in) throws IOException- Specified by:
loadFontin interfacecom.dua3.utility.text.FontUtil<Font>- Throws:
IOException
-
getTextWidth
- Specified by:
getTextWidthin interfacecom.dua3.utility.text.FontUtil<Font>
-
convert
- Specified by:
convertin interfacecom.dua3.utility.text.FontUtil<Font>
-