Package org.docx4j.fonts
Class Mapper
java.lang.Object
org.docx4j.fonts.Mapper
- Direct Known Subclasses:
BestMatchingMapper,IdentityPlusMapper
Maps font names used in the document to
fonts physically available
on the system.
So, a mapper per document.
If fonts are added to the document
(ie fonts introduced into use)
then the mapper should be updated
to include a mapping for the
new font.
There are 2 implementations:
- IndentityPlusMapper, which is best
where most of the fonts used in the
document are physically present
on the system
- BestMatchingMapper, useful on
Linux and OSX systems on which
Microsoft fonts have not been
installed.
Whichever one you use, you can
add/remove mappings programmatically
to customise to your needs.
- Author:
- jharrop
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ConcurrentHashMap<String,PhysicalFont> protected ConcurrentHashMap<String,PhysicalFont> static final Stringprotected static final Map<String,PhysicalFont> protected ConcurrentHashMap<String,PhysicalFont> protected static org.slf4j.Loggerprotected ConcurrentHashMap<String,PhysicalFont> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet a PhysicalFont from FontMappings, by case-insensitive name.getBoldForm(String fontNameAsInFontTablePart, PhysicalFont pf) getBoldItalicForm(String fontNameAsInFontTablePart, PhysicalFont pf) Deprecated.getItalicForm(String fontNameAsInFontTablePart, PhysicalFont pf) getRegularForm(String fontNameAsInFontTablePart) getSubstituteFontXsltExtension(String documentStyleId, String bolditalic, boolean fontFamilyStack) static StringgetSubstituteFontXsltExtension(Mapper s, String documentStyleId, String bolditalic, boolean fontFamilyStack) abstract voidpopulateFontMappings(Set<String> documentFontNames, Fonts wmlFonts) Populate the fontMappings object.voidput(String key, PhysicalFont pf) Put a PhysicalFont into FontMappings, by case-insensitive name.voidregisterBoldForm(String fontNameAsInFontTablePart, PhysicalFont pfBold) voidregisterBoldItalicForm(String fontNameAsInFontTablePart, PhysicalFont pfBoldItalic) voidregisterItalicForm(String fontNameAsInFontTablePart, PhysicalFont pfItalic) voidregisterRegularForm(String fontNameAsInFontTablePart, PhysicalFont pfRegular) intsize()
-
Field Details
-
log
protected static org.slf4j.Logger log -
regularForms
-
boldForms
-
italicForms
-
boldItalicForms
-
fontMappings
-
FONT_FALLBACK
- See Also:
-
-
Constructor Details
-
Mapper
public Mapper()
-
-
Method Details
-
getFontMappings
Deprecated. -
get
Get a PhysicalFont from FontMappings, by case-insensitive name. (Although Word always uses Title Case for font names, it is actually case insensitive; the spec is silent on this.)- Parameters:
key-- Returns:
-
put
Put a PhysicalFont into FontMappings, by case-insensitive name. (Although Word always uses Title Case for font names, it is actually case insensitive; the spec is silent on this.)- Parameters:
key-pf-
-
size
public int size() -
populateFontMappings
public abstract void populateFontMappings(Set<String> documentFontNames, Fonts wmlFonts) throws Exception Populate the fontMappings object. We make an entry for each of the documentFontNames.- Parameters:
documentFontNames- - the fonts used in the documentwmlFonts- - the content model for the fonts part- Throws:
Exception
-
getSubstituteFontXsltExtension
-
getSubstituteFontXsltExtension
-
registerRegularForm
-
registerBoldForm
-
registerItalicForm
-
registerBoldItalicForm
-
getRegularForm
-
getBoldForm
-
getItalicForm
-
getBoldItalicForm
-