Top Description Fields Constructors Methods
org.apache.poi.hssf.usermodel

public Class FontDetails

extends Object
Class Inheritance
Imports
java.util.HashMap, .Map, .Properties, .StringTokenizer

Stores width and height details about a font.

Field Summary

Modifier and TypeField and Description
private String
private int
private final Map<Character, Integer>

Constructor Summary

AccessConstructor and Description
public
FontDetails(String
The font name.
fontName
,
int
The height of the font.
height
)

Construct the font details with the given name and height.

Method Summary

Modifier and TypeMethod and Description
public void
addChar(char c, int width)

public void
addChars(char[] characters, int[] widths)

protected static String
protected static String
protected static String
public static FontDetails

Returns:

a new FontDetails instance.
create
(String
the font name
fontName
,
Properties
the property object holding the details of this particular font.
fontMetricsProps
)

Create an instance of FontDetails by loading them from the provided property object.

public int
getCharWidth(char c)

Retrieves the width of the specified character.

public String
public int
public int

Returns:

The width of the string for a 10 point font.
getStringWidth
(String
The string to measure.
str
)

Gets the width of all characters in a string.

private static String[]
split(String text, String separator, int max)

Split the given string into an array of strings using the given delimiter.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_fontNameback to summary
private String _fontName
_heightback to summary
private int _height
charWidthsback to summary
private final Map<Character, Integer> charWidths

Constructor Detail

FontDetailsback to summary
public FontDetails(String fontName, int height)

Construct the font details with the given name and height.

Parameters
fontName:String

The font name.

height:int

The height of the font.

Method Detail

addCharback to summary
public void addChar(char c, int width)
addCharsback to summary
public void addChars(char[] characters, int[] widths)
buildFontCharactersPropertyback to summary
protected static String buildFontCharactersProperty(String fontName)
buildFontHeightPropertyback to summary
protected static String buildFontHeightProperty(String fontName)
buildFontWidthsPropertyback to summary
protected static String buildFontWidthsProperty(String fontName)
createback to summary
public static FontDetails create(String fontName, Properties fontMetricsProps)

Create an instance of FontDetails by loading them from the provided property object.

Parameters
fontName:String

the font name

fontMetricsProps:Properties

the property object holding the details of this particular font.

Returns:FontDetails

a new FontDetails instance.

getCharWidthback to summary
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.

getFontNameback to summary
public String getFontName()
getHeightback to summary
public int getHeight()
getStringWidthback to summary
public int getStringWidth(String str)

Gets the width of all characters in a string.

Parameters
str:String

The string to measure.

Returns:int

The width of the string for a 10 point font.

splitback to summary
private static String[] split(String text, String separator, int max)

Split the given string into an array of strings using the given delimiter.