Class Mapper

java.lang.Object
org.docx4j.fonts.Mapper
Direct Known Subclasses:
BestMatchingMapper, IdentityPlusMapper

public abstract class Mapper
extends java.lang.Object
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 Details

  • Constructor Details

  • Method Details

    • getFontMappings

      @Deprecated public java.util.Map<java.lang.String,​PhysicalFont> getFontMappings()
      Deprecated.
    • get

      public PhysicalFont get​(java.lang.String key)
      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

      public void put​(java.lang.String key, PhysicalFont pf)
      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​(java.util.Set<java.lang.String> documentFontNames, Fonts wmlFonts) throws java.lang.Exception
      Populate the fontMappings object. We make an entry for each of the documentFontNames.
      Parameters:
      documentFontNames - - the fonts used in the document
      wmlFonts - - the content model for the fonts part
      Throws:
      java.lang.Exception
    • getSubstituteFontXsltExtension

      public static java.lang.String getSubstituteFontXsltExtension​(Mapper s, java.lang.String documentStyleId, java.lang.String bolditalic, boolean fontFamilyStack)
    • getSubstituteFontXsltExtension

      public java.lang.String getSubstituteFontXsltExtension​(java.lang.String documentStyleId, java.lang.String bolditalic, boolean fontFamilyStack)
    • registerRegularForm

      public void registerRegularForm​(java.lang.String fontNameAsInFontTablePart, PhysicalFont pfRegular)
    • registerBoldForm

      public void registerBoldForm​(java.lang.String fontNameAsInFontTablePart, PhysicalFont pfBold)
    • registerItalicForm

      public void registerItalicForm​(java.lang.String fontNameAsInFontTablePart, PhysicalFont pfItalic)
    • registerBoldItalicForm

      public void registerBoldItalicForm​(java.lang.String fontNameAsInFontTablePart, PhysicalFont pfBoldItalic)
    • getRegularForm

      public PhysicalFont getRegularForm​(java.lang.String fontNameAsInFontTablePart)
    • getBoldForm

      public PhysicalFont getBoldForm​(java.lang.String fontNameAsInFontTablePart, PhysicalFont pf)
    • getItalicForm

      public PhysicalFont getItalicForm​(java.lang.String fontNameAsInFontTablePart, PhysicalFont pf)
    • getBoldItalicForm

      public PhysicalFont getBoldItalicForm​(java.lang.String fontNameAsInFontTablePart, PhysicalFont pf)