Class PhysicalFonts

java.lang.Object
org.docx4j.fonts.PhysicalFonts

public class PhysicalFonts extends Object
The fonts which are physically installed on the system. They can be discovered automatically, or you can just add specific fonts. Do NOT add fonts embedded in a docx to physicalFontMap!
Author:
dev
  • Field Details

    • log

      protected static org.slf4j.Logger log
    • fontCache

      protected static FontCache fontCache
  • Constructor Details

    • PhysicalFonts

      public PhysicalFonts()
  • Method Details

    • getPhysicalFonts

      @Deprecated public static Map<String,PhysicalFont> getPhysicalFonts()
      Deprecated.
    • get

      public static PhysicalFont get(String key)
      Get a PhysicalFont 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 static void put(String key, PhysicalFont pf)
      Put a PhysicalFont 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 -
    • getRegex

      public static String getRegex()
    • setRegex

      public static void setRegex(String regex)
      Set a regex to limit to the common fonts in order to lower memory use. eg on Mac regex=".*(Courier New|Arial|Times New Roman|Comic Sans|Georgia|Impact|Lucida Console|Lucida Sans Unicode|Palatino Linotype|Tahoma|Trebuchet|Verdana|Symbol|Webdings|Wingdings|MS Sans Serif|MS Serif).*"; on Windows: regex=".*(calibri|cour|arial|times|comic|georgia|impact|LSANS|pala|tahoma|trebuc|verdana|symbol|webdings|wingding).*"; If you want to use this, set it before instantiating a Mapper.
      Since:
      2.8.1
    • discoverPhysicalFonts

      public static final void discoverPhysicalFonts() throws Exception
      Autodetect fonts available on the system.
      Throws:
      Exception
    • addPhysicalFont

      public static void addPhysicalFont(URI fontUrl)
      Add a physical font's EmbedFontInfo object. Not to be used for embedded fonts.
      Parameters:
      fontUrl - eg new java.net.URL("file:" + path)
    • addPhysicalFonts

      public static void addPhysicalFonts(String nameAsInFontTablePart, URI fontUrl)
      Add a physical font's EmbedFontInfo object. Not to be used for embedded fonts.
      Parameters:
      fontUrl - eg new java.net.URL("file:" + path)
    • getPhysicalFont

      public static List<PhysicalFont> getPhysicalFont(String nameAsInFontTablePart, URI fontUrl)
      Get a physical font's EmbedFontInfo object.
      Parameters:
      fontUrl - eg new java.net.URL("file:" + path)
    • getBoldForm

      public static PhysicalFont getBoldForm(PhysicalFont pf)
    • getBoldItalicForm

      public static PhysicalFont getBoldItalicForm(PhysicalFont pf)
    • getItalicForm

      public static PhysicalFont getItalicForm(PhysicalFont pf)
    • getPhysicalFont

      public static String getPhysicalFont(OpcPackage wmlPackage, String fontName)
    • main

      public static void main(String[] args) throws Exception
      Throws:
      Exception