Package org.docx4j.fonts
Class PhysicalFonts
java.lang.Object
org.docx4j.fonts.PhysicalFonts
The fonts which are physically installed on the system.
They can be discovered automatically, or you can
just add specific fonts.
Since 11.5.8 you can discover fonts in jars on your classpath
using method discoverJarFonts
Do NOT add fonts embedded in a docx to physicalFontMap!
- Author:
- jharrop
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddPhysicalFont(URI fontUrl) Add a physical font's EmbedFontInfo object.static voidaddPhysicalFonts(String nameAsInFontTablePart, URI fontUrl) Add a physical font's EmbedFontInfo object.static final intDetect fonts available in jars on classpath.static final intdiscoverJarFonts(String pathPrefix) Detect fonts available in jars on classpath.static final voidAutodetect fonts available on the system.static PhysicalFontGet a PhysicalFont by case-insensitive name.static PhysicalFontstatic PhysicalFontstatic PhysicalFontstatic List<PhysicalFont>getPhysicalFont(String nameAsInFontTablePart, URI fontUrl) Get a physical font's EmbedFontInfo object.static List<PhysicalFont>getPhysicalFont(String nameAsInFontTablePart, URI fontUrl, InternalResourceResolver fontResolver) Get a physical font's EmbedFontInfo object.static StringgetPhysicalFont(OpcPackage wmlPackage, String fontName) static Map<String,PhysicalFont> Deprecated.static StringgetRegex()static PhysicalFontFor XSL FO output of Symbol font, substitute a font known to contain the appropriate glyphs (if font is present).static PhysicalFontFor XSL FO output of Webdings and the Wingdings fonts, substitute a font known to contain the appropriate glyphs (if font is present).static PhysicalFontFor XSL FO output of Webdings and the Wingdings fonts, most are in Noto Sans Symbols 2 Regular, but some ranges are not.static voidstatic voidput(String key, PhysicalFont pf) Put a PhysicalFont by case-insensitive name.static voidputPhysicalFonts(String nameAsInFontTablePart, List<PhysicalFont> physicalFonts) static voidSet a regex to limit to the common fonts in order to lower memory use.
-
Field Details
-
log
protected static org.slf4j.Logger log -
fontCache
-
-
Constructor Details
-
PhysicalFonts
public PhysicalFonts()
-
-
Method Details
-
getPhysicalFonts
Deprecated. -
get
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
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
-
setRegex
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
Autodetect fonts available on the system.- Throws:
Exception
-
addPhysicalFont
Add a physical font's EmbedFontInfo object. Not to be used for embedded fonts.- Parameters:
fontUrl- eg new java.net.URL("file:" + path)
-
addPhysicalFonts
Add a physical font's EmbedFontInfo object. Not to be used for embedded fonts.- Parameters:
fontUrl- eg new java.net.URL("file:" + path)
-
putPhysicalFonts
- Parameters:
nameAsInFontTablePart-physicalFonts-- Since:
- 11.5.8
-
getPhysicalFont
Get a physical font's EmbedFontInfo object.- Parameters:
fontUrl- eg new java.net.URL("file:" + path)
-
getPhysicalFont
public static List<PhysicalFont> getPhysicalFont(String nameAsInFontTablePart, URI fontUrl, InternalResourceResolver fontResolver) Get a physical font's EmbedFontInfo object.- Parameters:
fontUrl- eg new java.net.URL("file:" + path)- Since:
- 11.5.8
-
getBoldForm
-
getBoldItalicForm
-
getItalicForm
-
getPhysicalFont
-
getWDingsFont
For XSL FO output of Webdings and the Wingdings fonts, substitute a font known to contain the appropriate glyphs (if font is present).- Returns:
-
getWDingsFont2
For XSL FO output of Webdings and the Wingdings fonts, most are in Noto Sans Symbols 2 Regular, but some ranges are not. This returns the font containing the remainder.- Returns:
-
getSymbolFont
For XSL FO output of Symbol font, substitute a font known to contain the appropriate glyphs (if font is present).- Returns:
-
main
- Throws:
Exception
-
discoverJarFonts
Detect fonts available in jars on classpath. You need to invoke this specifically if you want to do this.- Throws:
FOPExceptionURISyntaxExceptionIOException- Since:
- 11.5.8
-
discoverJarFonts
Detect fonts available in jars on classpath. You need to invoke this specifically if you want to do this.- Throws:
FOPExceptionURISyntaxException- Since:
- 11.5.8
-