public class FontCalculator extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
java.awt.Font |
fontToFitRectangle(java.awt.geom.Rectangle2D rectangle,
double scaleFactor,
java.lang.String text,
java.lang.String fontName,
int fontStyle)
Returns a font object that has the correct height to draw the specified text in the specified rectangle using
no minimal font height.
|
java.awt.Font |
fontToFitRectangle(java.awt.geom.Rectangle2D rectangle,
double scaleFactor,
java.lang.String text,
java.lang.String fontName,
int fontStyle,
int minHeight)
Returns a font object that has the correct height to draw the specified text in the specified rectangle.
|
float |
getAscent(java.awt.Font font) |
float |
getAscentToHeight(java.lang.String fontName,
int fontStyle,
float height) |
float |
getAspectRatio(java.awt.Font font,
java.lang.String text)
Returns the width of the given text divided by the height.
|
float |
getDescent(java.awt.Font font) |
float |
getDescentToHeight(java.lang.String fontName,
int fontStyle,
float height) |
float |
getFontSizeByTextHeight(float textHeight,
java.lang.String fontName,
int style) |
float |
getHeight(java.awt.Font font)
Deprecated.
As of release 2.2.0, replaced by
getTextHeightByFontSize(Font) . |
float |
getHeightSizeRatio(java.lang.String fontName,
int style) |
static FontCalculator |
getInstance() |
float |
getTextHeightByFontSize(float fontSize,
java.lang.String fontName,
int style) |
float |
getTextHeightByFontSize(java.awt.Font font) |
float |
getTextWidthToFontSize(java.lang.String fontName,
int fontStyle,
java.lang.String text,
float size) |
float |
getTextWidthToTextHeigth(java.lang.String fontName,
int fontStyle,
java.lang.String text,
float height) |
float |
getWidth(java.awt.Font font,
java.lang.String text) |
float |
getWidthToHeigth(java.lang.String fontName,
int fontStyle,
java.lang.String text,
float height)
Deprecated.
As of release 2.2.0, replaced by
getTextWidthToTextHeigth(String, int, String, float) . |
public static FontCalculator getInstance()
public float getHeightSizeRatio(java.lang.String fontName, int style)
public float getTextHeightByFontSize(float fontSize, java.lang.String fontName, int style)
public float getTextHeightByFontSize(java.awt.Font font)
public float getFontSizeByTextHeight(float textHeight, java.lang.String fontName, int style)
public float getDescent(java.awt.Font font)
public float getAscent(java.awt.Font font)
@Deprecated public float getHeight(java.awt.Font font)
getTextHeightByFontSize(Font)
.public float getWidth(java.awt.Font font, java.lang.String text)
public float getAspectRatio(java.awt.Font font, java.lang.String text)
@Deprecated public float getWidthToHeigth(java.lang.String fontName, int fontStyle, java.lang.String text, float height)
getTextWidthToTextHeigth(String, int, String, float)
.public float getTextWidthToTextHeigth(java.lang.String fontName, int fontStyle, java.lang.String text, float height)
public float getTextWidthToFontSize(java.lang.String fontName, int fontStyle, java.lang.String text, float size)
public float getDescentToHeight(java.lang.String fontName, int fontStyle, float height)
public float getAscentToHeight(java.lang.String fontName, int fontStyle, float height)
public java.awt.Font fontToFitRectangle(java.awt.geom.Rectangle2D rectangle, double scaleFactor, java.lang.String text, java.lang.String fontName, int fontStyle)
rectangle
- the rectangle to fit the text intoscaleFactor
- the factor by which the font height should be scaled (If 1.0 is provided here, the text will
will the width or the height of the rectangle completely. Note that due to possible rounding imprecision
a value below 1.0 is recommended so that the text fits completely into the rectangle.)text
- the text to be drawnfontName
- the name of the font to be usedfontStyle
- the style of the font to be usedGraphicsUtils.drawStringInRectangle(Graphics2D, Rectangle2D, String)
public java.awt.Font fontToFitRectangle(java.awt.geom.Rectangle2D rectangle, double scaleFactor, java.lang.String text, java.lang.String fontName, int fontStyle, int minHeight)
rectangle
- the rectangle to fit the text intoscaleFactor
- the factor by which the font height should be scaled (If 1.0 is provided here, the text will
will the width or the height of the rectangle completely. Note that due to possible rounding imprecision
a value below 1.0 is recommended so that the text fits completely into the rectangle.)text
- the text to be drawnfontName
- the name of the font to be usedfontStyle
- the style of the font to be usedminHeight
- the minimal font height the text should havenull
if the font would have to be smaller than the specified minimal heightGraphicsUtils.drawStringInRectangle(Graphics2D, Rectangle2D, String)