public final class FontMappings extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
defaultFont
font to use in preference to Lucida
|
static String[] |
defaultFontDirs
put fonts in variable so can be altered if needed by Client
|
static boolean |
enforceFontSubstitution
flag to show if there must be a mapping value (program exits if none
found)
|
static Map<String,String> |
fontPossDuplicates
used to ensure substituted fonts unique
|
static Map<String,String> |
fontPropertiesTable
hold details of all fonts
|
static Map<String,String> |
fontPropertiesTablePath |
static Map<String,Integer> |
fontPropertiesTableType |
static boolean |
fontsInitialised
ensure fonts setup only once
|
static Map<String,String> |
fontSubstitutionAliasTable
used to remap fonts onto truetype fonts (set internally)
|
static Map<String,Integer> |
fontSubstitutionFontID
used to store number for subfonts in TTC
|
static Map<String,String> |
fontSubstitutionLocation
used to remap fonts onto truetype fonts (set internally)
|
static Map<String,String> |
fontSubstitutionTable
used to remap fonts onto truetype fonts (set internally)
|
| Modifier and Type | Method and Description |
|---|---|
static void |
addFontFile(String currentFont,
String fontPath)
method to add a single file to the PDF renderer
|
static String |
addFonts(String fontDirs,
String failed)
takes a comma separated list of font directories and add to substitution
|
static void |
addLiberationAsFallBackFont(String family,
String path) |
static boolean |
addSubstituteFonts(String fontPath,
boolean enforceMapping)
This routine allows the user to add truetype,
type1 or type1C fonts which will be used to disalay the fonts in PDF
rendering and substitution as if the fonts were embedded in the PDF
This is very useful for clients looking to keep down the size of PDFs transmitted and control display quality - Thanks to Peter for the idea/code - How to set it up - JPedal will look for the existence of the directory fontPath (ie com/myCompany/Fonts) - If this exists, Jpedal will look for 3 possible directories (tt,t1c,t1) and make a note of any fonts if these directories exist - When fonts are resolved, this option will be tested first and if a font if found, it will be used to display the font (the effect will be the same as if the font was embedded) - If the enforceMapping is true, JPedal assumes there must be a match and will throw a PdfFontException - Otherwise Jpedal will look in the java font path for a match or approximate with Lucida - The Format is defined as follows: - fontname = filename Type1/Type1C Font names exclude any prefix so /OEGPNB+FGHeavyItalic is resolved to FGHeavyItalic - Each font have the same name as the font it replaces (so Arial will require a font file such as Arial.ttf) and it must be unique (there cannot be an Arial font in each sub-directory) - So to use this functionality, place the fonts in a jar or add to the JPedal jar and call this method after instancing PdfDecoder - JPedal will do the rest |
static String |
addTTDir(String fontPath,
String failed)
add a truetype font directory and contents to substitution
|
static void |
dispose() |
static int |
getFontSubstitutionMode()
set mode to use when substituting fonts (default is to use Filename (ie arial.ttf)
Options are SUBSTITUTE_* values from PdfDecoder
|
static void |
initFonts()
used internally to pick uo org.jpedal.fontmaps property and set
|
static void |
setDefaultDisplayFont(String fontName)
set the font used for default from Java fonts on system - Java fonts are
case sensitive, but JPedal resolves this internally, so you could use
Webdings, webdings or webDings for Java font Webdings - checks if it is a
valid Java font (otherwise it will default to Lucida anyway)
|
static String |
setFontDirs(String[] fontDirs)
takes a String[] of font directories and adds to substitution - Can just
be called for each JVM - Should be called before file opened - this
offers an alternative to the call -DFontDirs - Passing a null value
flushes all settings
|
static void |
setFontReplacements()
add a list of settings to map common fonts which can be substituted onto correct platform settings for Windows/MAC/Linux so JPedal
will try to use the fonts on the computer if possible to produce most accurate display.
|
static void |
setFontSubstitutionMode(int mode)
set mode to use when substituting fonts (default is to use Filename (ie arial.ttf)
Options are SUBSTITUTE_* values from PdfDecoder
|
static void |
setSubstitutedFontAliases(String fontFileName,
String[] aliases)
allows a number of fonts to be mapped onto an actual font and provides a
way around slightly differing font naming when substituting fonts - So if
arialMT existed on the target machine and the PDF contained arial and
helvetica (which you wished to replace with arialmt), you would use the
following code -
String[] aliases={"arial","helvetica"}; currentPdfDecoder.setSubstitutedFontAliases("arialmt",aliases); - comparison is case-insensitive and file type/ending should not be included - For use in conjunction with -Dorg.jpedal.fontdirs options which allows user to pass a set of comma separated directories with Truetype fonts (directories do not need to exist so can be multi-platform setting) |
public static boolean fontsInitialised
public static String defaultFont
public static boolean enforceFontSubstitution
public static Map<String,String> fontSubstitutionTable
public static Map<String,String> fontPossDuplicates
public static Map<String,Integer> fontSubstitutionFontID
public static Map<String,String> fontSubstitutionLocation
public static Map<String,String> fontSubstitutionAliasTable
public static String[] defaultFontDirs
public static void initFonts()
public static void addLiberationAsFallBackFont(String family, String path) throws IOException
IOExceptionpublic static void setFontSubstitutionMode(int mode)
public static int getFontSubstitutionMode()
public static void setSubstitutedFontAliases(String fontFileName, String[] aliases)
public static String addFonts(String fontDirs, String failed)
public static void dispose()
public static String addTTDir(String fontPath, String failed)
public static void setFontReplacements()
public static String setFontDirs(String[] fontDirs)
public static boolean addSubstituteFonts(String fontPath, boolean enforceMapping)
fontPath - -
root directory for fontsenforceMapping - -
tell JPedal if all fonts should be in this directorypublic static void addFontFile(String currentFont, String fontPath)
currentFont - - actual font name we use to identifyfontPath - - full path to font file used for this fontpublic static void setDefaultDisplayFont(String fontName) throws PdfFontException
PdfFontExceptionCopyright © 2017. All rights reserved.