public class FontMapper extends java.util.Observable implements java.lang.Cloneable, java.lang.Comparable<FontMapper>
FontMapper fm = new FontMapper();
fm.addMappingRule("*times*", "Times");
fm.setDefaultFont("Helvetica");
Modifier and Type | Field and Description |
---|---|
static int |
FONT_LINE_HEIGHT_AUTO |
static int |
FONT_LINE_HEIGHT_DISABLED |
static int |
FONT_LINE_HEIGHT_JAVA_FONT_METRICS |
static int |
LINE_HEIGHT_CORRECTION_AUTO
Don't apply any line height.
|
static int |
LINE_HEIGHT_CORRECTION_DISABLED |
static int |
LINE_HEIGHT_CORRECTION_ENABLED |
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(FontMapper 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.
|
java.util.List<FontMappingRule> |
getEntries()
Gets an unmodifieable list of all FontMappingEntries.
|
int |
getFontLineHeight() |
int |
getFontLineHeight(java.lang.String font) |
java.lang.String |
getForRenderer()
Get's the name of the renderer for which the font-mapping
should be used.
|
java.lang.String |
getID() |
int |
getLineHeightCorrection() |
int |
getLineHeightCorrection(java.lang.String font) |
FontMappingRule |
getMappingRule(java.lang.String font)
Gets the mapping entry of a font.
|
java.util.Map<java.lang.String,java.lang.String> |
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.
|
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 |
setFontLineHeight(int rule)
If line-height correction is enabled, JFO must calculate the line-height of a text
in some circumstances.
|
void |
setForRenderer(java.lang.String forRenderer) |
void |
setID(java.lang.String id) |
void |
setLineHeightCorrection(int correction) |
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_CORRECTION_AUTO
public static final int LINE_HEIGHT_CORRECTION_DISABLED
public static final int LINE_HEIGHT_CORRECTION_ENABLED
public static final int FONT_LINE_HEIGHT_AUTO
public static final int FONT_LINE_HEIGHT_DISABLED
public static final int FONT_LINE_HEIGHT_JAVA_FONT_METRICS
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 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<java.lang.String,java.lang.String> getNameMap()
public void clearMapping()
public void setDefaultFont(java.lang.String defaultFont)
defaultFont
- Name of default font.public java.lang.String getDefaultFont()
public int getLineHeightCorrection()
public int getLineHeightCorrection(java.lang.String font)
public void setLineHeightCorrection(int correction)
public int getFontLineHeight()
public int getFontLineHeight(java.lang.String font)
public void setFontLineHeight(int rule)
rule
- FONT_LINE_HEIGHT_DISABLED
,
FONT_LINE_HEIGHT_JAVA_FONT_METRICS
public java.lang.String getForRenderer()
public boolean isGlobalMapper()
public boolean hasID()
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<FontMappingRule> 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(FontMapper o)
compareTo
in interface java.lang.Comparable<FontMapper>
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.