com.lowagie.text.pdf

Class DefaultFontMapper

public class DefaultFontMapper extends Object implements FontMapper

Default class to map awt fonts to BaseFont.

Author: Paulo Soares (psoares@consiste.pt)

Nested Class Summary
static classDefaultFontMapper.BaseFontParameters
A representation of BaseFont parameters.
Field Summary
HashMapaliases
Maps aliases to names.
HashMapmapper
Maps names to BaseFont parameters.
Method Summary
BaseFontawtToPdf(Font font)
Returns a BaseFont which can be used to represent the given AWT Font
HashMapgetAliases()
DefaultFontMapper.BaseFontParametersgetBaseFontParameters(String name)
Looks for a BaseFont parameter associated with a name.
HashMapgetMapper()
intinsertDirectory(String dir)
Inserts all the fonts recognized by iText in the directory into the map.
voidinsertNames(Object[] allNames, String path)
Inserts the names in this map.
FontpdfToAwt(BaseFont font, int size)
Returns an AWT Font which can be used to represent the given BaseFont
voidputAlias(String alias, String awtName)
Maps an alias to a name.
voidputName(String awtName, DefaultFontMapper.BaseFontParameters parameters)
Maps a name to a BaseFont parameter.

Field Detail

aliases

private HashMap aliases
Maps aliases to names.

mapper

private HashMap mapper
Maps names to BaseFont parameters.

Method Detail

awtToPdf

public BaseFont awtToPdf(Font font)
Returns a BaseFont which can be used to represent the given AWT Font

Parameters: font the font to be converted

Returns: a BaseFont which has similar properties to the provided Font

getAliases

public HashMap getAliases()

getBaseFontParameters

public DefaultFontMapper.BaseFontParameters getBaseFontParameters(String name)
Looks for a BaseFont parameter associated with a name.

Parameters: name the name

Returns: the BaseFont parameter or null if not found.

getMapper

public HashMap getMapper()

insertDirectory

public int insertDirectory(String dir)
Inserts all the fonts recognized by iText in the directory into the map. The encoding will be BaseFont.CP1252 but can be changed later.

Parameters: dir the directory to scan

Returns: the number of files processed

insertNames

public void insertNames(Object[] allNames, String path)
Inserts the names in this map.

Parameters: allNames the returned value of calling (String, String, byte[]) path the full path to the font

pdfToAwt

public Font pdfToAwt(BaseFont font, int size)
Returns an AWT Font which can be used to represent the given BaseFont

Parameters: font the font to be converted size the desired point size of the resulting font

Returns: a Font which has similar properties to the provided BaseFont

putAlias

public void putAlias(String alias, String awtName)
Maps an alias to a name.

Parameters: alias the alias awtName the name

putName

public void putName(String awtName, DefaultFontMapper.BaseFontParameters parameters)
Maps a name to a BaseFont parameter.

Parameters: awtName the name parameters the BaseFont parameter