Package org.jpedal.fonts
Class FontMappings
java.lang.Object
org.jpedal.fonts.FontMappings
Holds Maps which are used to map font names onto actual fonts and files
-
Field Summary
Modifier and TypeFieldDescriptionstatic String
font to use in preference to SansSerifstatic String[]
put fonts in variable so can be altered if needed by Clienthold details of all fontsstatic boolean
ensure fonts setup only onceused to remap fonts onto truetype fonts (set internally)used to store number for subfonts in TTCused to remap fonts onto truetype fonts (set internally)used to remap fonts onto truetype fonts (set internally) -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addFallBackFont
(org.jpedal.parser.FallbackFont fallbackFont) static void
dispose()
static int
set mode to use when substituting fonts (default is to use Filename (ie arial.ttf) Options are SUBSTITUTE_* values from PdfDecoderstatic void
used internally to pick uo org.jpedal.fontmaps property and setstatic 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 SansSerif anyway)static void
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 settingsstatic void
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 PdfDecoderstatic 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 (names are case insensitive) -
String[] aliases={"arial","helvetica"}; FontMappings.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)
-
Field Details
-
fontsInitialised
public static boolean fontsInitialisedensure fonts setup only once -
defaultFont
font to use in preference to SansSerif -
fontSubstitutionTable
used to remap fonts onto truetype fonts (set internally) -
fontPropertiesTable
hold details of all fonts -
fontPropertiesTableType
-
fontPropertiesTablePath
-
fontSubstitutionFontID
used to store number for subfonts in TTC -
fontSubstitutionLocation
used to remap fonts onto truetype fonts (set internally) -
fontSubstitutionAliasTable
used to remap fonts onto truetype fonts (set internally) -
defaultFontDirs
put fonts in variable so can be altered if needed by Client
-
-
Method Details
-
initFonts
public static void initFonts()used internally to pick uo org.jpedal.fontmaps property and set -
addFallBackFont
public static void addFallBackFont(org.jpedal.parser.FallbackFont fallbackFont) -
setFontSubstitutionMode
public 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- Parameters:
mode
- the mode of substitution to use [ filename = 1, postscript name = 2, family name = 3, full font name = 4, postscript name or family name if duplicate = 5]
-
getFontSubstitutionMode
public static int getFontSubstitutionMode()set mode to use when substituting fonts (default is to use Filename (ie arial.ttf) Options are SUBSTITUTE_* values from PdfDecoder- Returns:
- the mode of substitution being used [ filename = 1, postscript name = 2, family name = 3, full font name = 4, postscript name or family name if duplicate = 5]
-
setSubstitutedFontAliases
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 (names are case insensitive) -
String[] aliases={"arial","helvetica"}; FontMappings.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)- Parameters:
fontFileName
- the name of the font file that we are replacing withaliases
- the fonts in the pdf that we are going to replace
-
dispose
public static void dispose() -
setFontReplacements
public 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. -
setFontDirs
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- Parameters:
fontDirs
- the directories containing the fonts
-
setDefaultDisplayFont
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 SansSerif anyway)- Parameters:
fontName
- the font name to set as default- Throws:
PdfFontException
- if specified font is not accessible
-