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.FontTypes -
Field Summary
Fields inherited from interface com.dua3.utility.text.FontUtil
NO_IMPLEMENTATION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionconvert(com.dua3.utility.text.Font font)getFamilies(com.dua3.utility.text.FontUtil.FontTypes types)com.dua3.utility.math.geometry.Dimension2dgetTextDimension(CharSequence s, com.dua3.utility.text.Font f)com.dua3.utility.math.geometry.Dimension2dgetTextDimension(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.List<com.dua3.utility.text.Font>loadFonts(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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.dua3.utility.text.FontUtil
getFamilies
-
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)
-
getTextDimension
public com.dua3.utility.math.geometry.Dimension2d getTextDimension(CharSequence text, Font awtFont)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)
-
getTextDimension
public com.dua3.utility.math.geometry.Dimension2d getTextDimension(CharSequence s, com.dua3.utility.text.Font f)- Specified by:
getTextDimensionin interfacecom.dua3.utility.text.FontUtil<Font>
-
getTextHeight
- Specified by:
getTextHeightin interfacecom.dua3.utility.text.FontUtil<Font>
-
loadFonts
- Specified by:
loadFontsin interfacecom.dua3.utility.text.FontUtil<Font>- Throws:
IOException
-
getFamilies
- Specified by:
getFamiliesin interfacecom.dua3.utility.text.FontUtil<Font>
-
getTextWidth
- Specified by:
getTextWidthin interfacecom.dua3.utility.text.FontUtil<Font>
-
convert
- Specified by:
convertin interfacecom.dua3.utility.text.FontUtil<Font>
-