Class FontMappings

java.lang.Object
org.jpedal.fonts.FontMappings

public final class FontMappings extends Object
Holds Maps which are used to map font names onto actual fonts and files
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static String
    font to use in preference to SansSerif
    static String[]
    put fonts in variable so can be altered if needed by Client
    static Map<String,String>
    hold details of all fonts
    static Map<String,String>
     
     
    static boolean
    ensure fonts setup only once
    static Map<String,String>
    used to remap fonts onto truetype fonts (set internally)
    used to store number for subfonts in TTC
    static Map<String,String>
    used to remap fonts onto truetype fonts (set internally)
    static Map<String,String>
    used to remap fonts onto truetype fonts (set internally)
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addFallBackFont(org.jpedal.parser.FallbackFont fallbackFont)
     
    static void
     
    static int
    set mode to use when substituting fonts (default is to use Filename (ie arial.ttf) Options are SUBSTITUTE_* values from PdfDecoder
    static void
    used internally to pick uo org.jpedal.fontmaps property and set
    static void
    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 settings
    static 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
    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 (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)

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • fontsInitialised

      public static boolean fontsInitialised
      ensure fonts setup only once
    • defaultFont

      public static String defaultFont
      font to use in preference to SansSerif
    • fontSubstitutionTable

      public static Map<String,String> fontSubstitutionTable
      used to remap fonts onto truetype fonts (set internally)
    • fontPropertiesTable

      public static Map<String,String> fontPropertiesTable
      hold details of all fonts
    • fontPropertiesTableType

      public static Map<String,Integer> fontPropertiesTableType
    • fontPropertiesTablePath

      public static Map<String,String> fontPropertiesTablePath
    • fontSubstitutionFontID

      public static Map<String,Integer> fontSubstitutionFontID
      used to store number for subfonts in TTC
    • fontSubstitutionLocation

      public static Map<String,String> fontSubstitutionLocation
      used to remap fonts onto truetype fonts (set internally)
    • fontSubstitutionAliasTable

      public static Map<String,String> fontSubstitutionAliasTable
      used to remap fonts onto truetype fonts (set internally)
    • defaultFontDirs

      public static String[] 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

      public 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 (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 with
      aliases - 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

      public 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 settings
      Parameters:
      fontDirs - the directories containing the fonts
    • setDefaultDisplayFont

      public static void setDefaultDisplayFont(String fontName) throws PdfFontException
      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