Package net.codecrete.qrbill.canvas
Class FontMetrics
- java.lang.Object
-
- net.codecrete.qrbill.canvas.FontMetrics
-
public class FontMetrics extends java.lang.ObjectSimple font metrics class to be independent of graphics subsystems and installed fonts.Only supports Helvetica font.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doublegetAscender(int fontSize)Distance between baseline and top of highest letter.static doublegetDescender(int fontSize)Distance between baseline and bottom of letter extending the farest below the baseline.static doublegetLineHeight(int fontSize)Distance between the baselines of two consecutive text lines.static java.lang.String[]splitLines(java.lang.String text, double maxLength, int fontSize)Splits the text into lines.
-
-
-
Method Detail
-
getAscender
public static double getAscender(int fontSize)
Distance between baseline and top of highest letter.- Parameters:
fontSize- the font size (in pt)- Returns:
- the distance (in mm)
-
getDescender
public static double getDescender(int fontSize)
Distance between baseline and bottom of letter extending the farest below the baseline.- Parameters:
fontSize- the font size (in pt)- Returns:
- the distance (in mm)
-
getLineHeight
public static double getLineHeight(int fontSize)
Distance between the baselines of two consecutive text lines.- Parameters:
fontSize- the font size (in pt)- Returns:
- the distance (in mm)
-
splitLines
public static java.lang.String[] splitLines(java.lang.String text, double maxLength, int fontSize)Splits the text into lines.If a line would exceed the specified maximum length, line breaks are inserted. Newlines are treated as fixed line breaks.
- Parameters:
text- the textmaxLength- the maximum line length (in pt)fontSize- the font size (in pt)- Returns:
- an array of text lines
-
-