Package org.docx4j.fonts
Class PhysicalFonts
java.lang.Object
org.docx4j.fonts.PhysicalFonts
public class PhysicalFonts
extends java.lang.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 Summary
-
Constructor Summary
Constructors Constructor Description PhysicalFonts() -
Method Summary
Modifier and Type Method Description static voidaddPhysicalFont(java.net.URL fontUrl)Add a physical font's EmbedFontInfo object.static voidaddPhysicalFonts(java.lang.String nameAsInFontTablePart, java.net.URL fontUrl)Add a physical font's EmbedFontInfo object.static voiddiscoverPhysicalFonts()Autodetect fonts available on the system.static PhysicalFontget(java.lang.String key)Get a PhysicalFont by case-insensitive name.static PhysicalFontgetBoldForm(PhysicalFont pf)static PhysicalFontgetBoldItalicForm(PhysicalFont pf)static PhysicalFontgetItalicForm(PhysicalFont pf)static java.util.List<PhysicalFont>getPhysicalFont(java.lang.String nameAsInFontTablePart, java.net.URL fontUrl)Get a physical font's EmbedFontInfo object.static java.lang.StringgetPhysicalFont(OpcPackage wmlPackage, java.lang.String fontName)static java.util.Map<java.lang.String,PhysicalFont>getPhysicalFonts()Deprecated.static java.lang.StringgetRegex()static voidmain(java.lang.String[] args)static voidput(java.lang.String key, PhysicalFont pf)Put a PhysicalFont by case-insensitive name.static voidsetRegex(java.lang.String regex)Set a regex to limit to the common fonts in order to lower memory use.
-
Field Details
-
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
public static java.lang.String getRegex() -
setRegex
public static void setRegex(java.lang.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 java.lang.ExceptionAutodetect fonts available on the system.- Throws:
java.lang.Exception
-
addPhysicalFont
public static void addPhysicalFont(java.net.URL 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(java.lang.String nameAsInFontTablePart, java.net.URL 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 java.util.List<PhysicalFont> getPhysicalFont(java.lang.String nameAsInFontTablePart, java.net.URL fontUrl)Get a physical font's EmbedFontInfo object.- Parameters:
fontUrl- eg new java.net.URL("file:" + path)
-
getBoldForm
-
getBoldItalicForm
-
getItalicForm
-
getPhysicalFont
-
main
public static void main(java.lang.String[] args) throws java.lang.Exception- Throws:
java.lang.Exception
-