Package org.docx4j.fonts
Class BestMatchingMapper
java.lang.Object
org.docx4j.fonts.Mapper
org.docx4j.fonts.BestMatchingMapper
public class BestMatchingMapper extends Mapper
This mapper uses Panose to guess the physical font
which is a closest fit for the font used in the
document.
It is most likely to be suitable on Linux or OSX
systems which don't have Microsoft's fonts installed.
- Author:
- jharrop
-
Field Summary
Fields Modifier and Type Field Description protected static org.slf4j.Logger
log
static int
MATCH_THRESHOLD
Max difference for it to be considered an acceptable match.Fields inherited from class org.docx4j.fonts.Mapper
boldForms, boldItalicForms, FONT_FALLBACK, fontMappings, italicForms, regularForms
-
Constructor Summary
Constructors Constructor Description BestMatchingMapper()
-
Method Summary
Modifier and Type Method Description static java.util.Map<java.lang.String,MicrosoftFonts.Font>
getMsFontsFilenames()
static void
main(java.lang.String[] args)
void
populateFontMappings(java.util.Set<java.lang.String> documentFontNames, Fonts wmlFonts)
Populate the fontMappings object.Methods inherited from class org.docx4j.fonts.Mapper
get, getBoldForm, getBoldItalicForm, getFontMappings, getItalicForm, getRegularForm, getSubstituteFontXsltExtension, getSubstituteFontXsltExtension, put, registerBoldForm, registerBoldItalicForm, registerItalicForm, registerRegularForm, size
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
log
protected static org.slf4j.Logger log -
MATCH_THRESHOLD
public static final int MATCH_THRESHOLDMax difference for it to be considered an acceptable match. Note that this value will depend on the weights in the difference function.- See Also:
- Constant Field Values
-
-
Constructor Details
-
BestMatchingMapper
public BestMatchingMapper()
-
-
Method Details
-
getMsFontsFilenames
-
populateFontMappings
public void populateFontMappings(java.util.Set<java.lang.String> documentFontNames, Fonts wmlFonts) throws java.lang.ExceptionPopulate the fontMappings object. We make an entry for each of the documentFontNames.- Specified by:
populateFontMappings
in classMapper
- Parameters:
documentFontNames
- - the fonts used in the documentwmlFonts
- - the content model for the fonts part- Throws:
java.lang.Exception
-
main
public static void main(java.lang.String[] args) throws java.lang.Exception- Throws:
java.lang.Exception
-