org.apache.poi.hssf.usermodel
Class FontDetails

java.lang.Object
  extended by org.apache.poi.hssf.usermodel.FontDetails

public class FontDetails
extends java.lang.Object

Stores width and height details about a font.

Author:
Glen Stampoultzis (glens at apache.org)

Constructor Summary
FontDetails(java.lang.String fontName, int height)
          Construct the font details with the given name and height.
 
Method Summary
 void addChar(char c, int width)
           
 void addChars(char[] characters, int[] widths)
           
protected static java.lang.String buildFontCharactersProperty(java.lang.String fontName)
           
protected static java.lang.String buildFontHeightProperty(java.lang.String fontName)
           
protected static java.lang.String buildFontWidthsProperty(java.lang.String fontName)
           
static FontDetails create(java.lang.String fontName, java.util.Properties fontMetricsProps)
          Create an instance of FontDetails by loading them from the provided property object.
 int getCharWidth(char c)
          Retrieves the width of the specified character.
 java.lang.String getFontName()
           
 int getHeight()
           
 int getStringWidth(java.lang.String str)
          Gets the width of all characters in a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FontDetails

public FontDetails(java.lang.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 java.lang.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)

buildFontHeightProperty

protected static java.lang.String buildFontHeightProperty(java.lang.String fontName)

buildFontWidthsProperty

protected static java.lang.String buildFontWidthsProperty(java.lang.String fontName)

buildFontCharactersProperty

protected static java.lang.String buildFontCharactersProperty(java.lang.String fontName)

create

public static FontDetails create(java.lang.String fontName,
                                 java.util.Properties fontMetricsProps)
Create an instance of FontDetails by loading them from the provided property object.

Parameters:
fontName - the font name
fontMetricsProps - the property object holding the details of this particular font.
Returns:
a new FontDetails instance.

getStringWidth

public int getStringWidth(java.lang.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.


Copyright 2008 The Apache Software Foundation or its licensors, as applicable.