public class FontMapper
extends java.util.Observable
implements java.lang.Cloneable, java.lang.Comparable
FontMapper fm = new FontMapper();
fm.addMappingRule("*times*", "Times");
fm.setDefaultFont("Helvetica");
Modifier and Type | Field and Description |
---|---|
static int |
LINE_HEIGHT_DEFAULT |
static int |
LINE_HEIGHT_NONE |
Constructor and Description |
---|
FontMapper()
Creates a FontMapper.
|
FontMapper(de.vc.config.Configuration config)
Creates a FontMapper based on a configuration.
|
FontMapper(java.io.InputStream xml)
Creates a FontMapper from a XML font-mapping stream.
|
FontMapper(java.lang.String xmlFile)
Creates a FontMapper from a XML font-mapping file.
|
Modifier and Type | Method and Description |
---|---|
FontMappingRule |
addMappingRule(java.lang.String inFont,
java.lang.String outFont)
Adds mapping information for a font.
|
de.vc.config.Configuration |
buildConfiguration()
Builds a configuration containing all mapping rules, default font and
character transcodings.
|
void |
clearMapping()
Removes all mapping rules except the default font.
|
FontMapper |
cloned()
A deep clone of this mapping is returned.
|
int |
compareTo(java.lang.Object o) |
void |
configure(de.vc.config.Configuration config)
Set up this mapper from a configuration.
|
void |
configure(java.io.InputStream configuration)
Configure this font mapper with new configuration.
|
java.lang.String |
getDefaultFont()
Gets the default font.
|
int |
getDefaultLineHeight()
Gets the default line height (percentage) applied to paragraphs (fo:block).
|
java.util.List |
getEntries()
Gets an unmodifieable list of all FontMappingEntries.
|
java.lang.String |
getForRenderer()
Get's the name of the renderer for which the font-mapping
should be used.
|
java.lang.String |
getID() |
FontMappingRule |
getMappingRule(java.lang.String font)
Gets the mapping entry of a font.
|
java.util.Map |
getNameMap()
Gets a map of input font-name/pattern (String) to output font-name (String).
|
boolean |
hasID()
Return true if this mapper has an ID.
|
boolean |
isGlobalMapper()
Returns true if this mapper is for global use
and not dedicated for a certain renderer.
|
Measure |
lineHeightForFont(java.lang.String font)
Returns the line height for a given font.
|
void |
logMapping()
Writes mapping infos through the logger (INFO level).
|
java.lang.String |
mapFontName(java.lang.String font)
Maps an input font according to registered mapping rules to an
output font.
|
int |
matches(java.lang.String renderer) |
void |
removeMappingRule(java.lang.String font)
Removes a mapping.
|
boolean |
renameRule(java.lang.String oldFont,
java.lang.String newFont)
Renames a mapping rule.
|
void |
setDefaultFont(java.lang.String defaultFont)
Sets the default font, a null value disables the default font.
|
void |
setDefaultLineHeight(int defaultLineHeight)
Sets the default line height (percentage) or disables line height.
|
void |
setForRenderer(java.lang.String forRenderer) |
void |
setID(java.lang.String id) |
void |
storeTo(java.io.OutputStream os)
Stores mapping information into given OutputStream.
|
java.lang.String |
transcodeText(java.lang.String font,
java.lang.String text)
Transcodes a string according substitution rules of a font.
|
public static final int LINE_HEIGHT_NONE
public static final int LINE_HEIGHT_DEFAULT
public FontMapper()
public FontMapper(java.lang.String xmlFile) throws de.vc.config.ConfigurationException, java.io.IOException
xmlFile
- XML filejava.io.IOException
de.vc.config.ConfigurationException
public FontMapper(java.io.InputStream xml) throws de.vc.config.ConfigurationException, java.io.IOException
xml
- XML stream.java.io.IOException
de.vc.config.ConfigurationException
public FontMapper(de.vc.config.Configuration config) throws de.vc.config.ConfigurationException, java.io.IOException
config
- Configuration.java.io.IOException
de.vc.config.ConfigurationException
public java.lang.String mapFontName(java.lang.String font)
font
- Input font.public Measure lineHeightForFont(java.lang.String font)
font
- Fontnamepublic FontMappingRule addMappingRule(java.lang.String inFont, java.lang.String outFont)
addMappingRule("*Arial*","Helvetica");
inFont
- Input font that will be replaced. Font name may contain
wildcards (* and ?).outFont
- Output font that is replacing input font.public boolean renameRule(java.lang.String oldFont, java.lang.String newFont)
oldFont
- Old input font.newFont
- New input font.public void removeMappingRule(java.lang.String font)
font
- Name of input font.public java.util.Map getNameMap()
public void clearMapping()
public void setDefaultFont(java.lang.String defaultFont)
defaultFont
- Name of default font.public java.lang.String getDefaultFont()
public int getDefaultLineHeight()
LINE_HEIGHT_NONE
public java.lang.String getForRenderer()
public boolean isGlobalMapper()
public boolean hasID()
public void setDefaultLineHeight(int defaultLineHeight)
defaultLineHeight
- Line height (percentage) or LINE_HEIGHT_NONE.LINE_HEIGHT_NONE
public void setForRenderer(java.lang.String forRenderer)
public java.lang.String transcodeText(java.lang.String font, java.lang.String text)
font
- Font of text.text
- Text.public FontMappingRule getMappingRule(java.lang.String font)
font
- Input font name/pattern.public java.util.List getEntries()
FontMappingRule
.public void storeTo(java.io.OutputStream os)
os
- OutputStream.public FontMapper cloned()
public void configure(java.io.InputStream configuration) throws de.vc.config.ConfigurationException, java.io.IOException
configuration
- New configuration.de.vc.config.ConfigurationException
java.io.IOException
public void configure(de.vc.config.Configuration config) throws de.vc.config.ConfigurationException
config
- Configuration.de.vc.config.ConfigurationException
public de.vc.config.Configuration buildConfiguration()
public void logMapping()
public int matches(java.lang.String renderer)
public int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable
o
- the Object to be compared.public java.lang.String getID()
public void setID(java.lang.String id)
© 2003-2011 by Sascha Schmidt (vision-cloud.de). All Rights Reserved.