Package org.apache.poi.hssf.usermodel
Class FontDetails
- java.lang.Object
-
- org.apache.poi.hssf.usermodel.FontDetails
-
public class FontDetails extends Object
Stores width and height details about a font.
-
-
Constructor Summary
Constructors Constructor Description FontDetails(String fontName, int height)
Construct the font details with the given name and height.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChar(char c, int width)
void
addChars(char[] characters, int[] widths)
protected static String
buildFontCharactersProperty(String fontName)
protected static String
buildFontHeightProperty(String fontName)
protected static String
buildFontWidthsProperty(String fontName)
static FontDetails
create(String fontName, Properties fontMetricsProps)
Create an instance ofFontDetails
by loading them from the provided property object.int
getCharWidth(char c)
Retrieves the width of the specified character.String
getFontName()
int
getHeight()
int
getStringWidth(String str)
Gets the width of all characters in a string.
-
-
-
Constructor Detail
-
FontDetails
public FontDetails(String fontName, int height)
Construct the font details with the given name and height.- Parameters:
fontName
- The font name.height
- The height of the font.
-
-
Method Detail
-
getFontName
public String getFontName()
-
getHeight
public int getHeight()
-
addChar
public void addChar(char c, int width)
-
getCharWidth
public int getCharWidth(char c)
Retrieves the width of the specified character. If the metrics for a particular character are not available it defaults to returning the width for the 'W' character.
-
addChars
public void addChars(char[] characters, int[] widths)
-
create
public static FontDetails create(String fontName, Properties fontMetricsProps)
Create an instance ofFontDetails
by loading them from the provided property object.- Parameters:
fontName
- the font namefontMetricsProps
- the property object holding the details of this particular font.- Returns:
- a new FontDetails instance.
-
getStringWidth
public int getStringWidth(String str)
Gets the width of all characters in a string.- Parameters:
str
- The string to measure.- Returns:
- The width of the string for a 10 point font.
-
-