Class FontRegisterProvider

java.lang.Object
com.itextpdf.io.font.FontRegisterProvider

class FontRegisterProvider extends Object
If you are using True Type fonts, you can declare the paths of the different ttf- and ttc-files to this class first and then create fonts in your code using one of the getFont method without having to enter a path as parameter.
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • fontNames

      private final Map<String,String> fontNames
      This is a map of postscriptfontnames of fonts and the path of their font file.
    • fontFamilies

      private final Map<String,List<String>> fontFamilies
      This is a map of fontfamilies.
  • Constructor Details

    • FontRegisterProvider

      FontRegisterProvider()
      Creates new FontRegisterProvider
  • Method Details

    • getFont

      FontProgram getFont(String fontName, int style) throws IOException
      Constructs a Font-object.
      Parameters:
      fontName - the name of the font
      style - the style of this font
      Returns:
      the Font constructed based on the parameters
      Throws:
      IOException
    • getFont

      FontProgram getFont(String fontName, int style, boolean cached) throws IOException
      Constructs a Font-object.
      Parameters:
      fontName - the name of the font
      style - the style of this font
      cached - true if the font comes from the cache or is added to the cache if new, false if the font is always created new
      Returns:
      the Font constructed based on the parameters
      Throws:
      IOException
    • registerStandardFonts

      protected void registerStandardFonts()
    • registerStandardFontFamilies

      protected void registerStandardFontFamilies()
    • getFontProgram

      protected FontProgram getFontProgram(String fontName, boolean cached) throws IOException
      Throws:
      IOException
    • registerFontFamily

      void registerFontFamily(String familyName, String fullName, String path)
      Register a font by giving explicitly the font family and name.
      Parameters:
      familyName - the font family
      fullName - the font name
      path - the font path
    • registerFont

      void registerFont(String path)
      Register a font file, either .ttf or .otf, .afm or a font from TrueType Collection. If a TrueType Collection is registered, an additional index of the font program can be specified
      Parameters:
      path - the path to a ttf- or ttc-file
    • registerFont

      void registerFont(String path, String alias)
      Register a font file and use an alias for the font contained in it.
      Parameters:
      path - the path to a font file
      alias - the alias you want to use for the font
    • saveCopyOfRegularFont

      boolean saveCopyOfRegularFont(String regularFontName, String path)
    • registerFontDirectory

      int registerFontDirectory(String dir)
      Register all the fonts in a directory.
      Parameters:
      dir - the directory
      Returns:
      the number of fonts registered
    • registerFontDirectory

      int registerFontDirectory(String dir, boolean scanSubdirectories)
      Register all the fonts in a directory and possibly its subdirectories.
      Parameters:
      dir - the directory
      scanSubdirectories - recursively scan subdirectories if true
      Returns:
      the number of fonts registered
    • registerSystemFontDirectories

      int registerSystemFontDirectories()
      Register fonts in some probable directories. It usually works in Windows, Linux and Solaris.
      Returns:
      the number of fonts registered
    • getRegisteredFonts

      Set<String> getRegisteredFonts()
      Gets a set of registered font names.
      Returns:
      a set of registered fonts
    • getRegisteredFontFamilies

      Set<String> getRegisteredFontFamilies()
      Gets a set of registered font names.
      Returns:
      a set of registered font families
    • isRegisteredFont

      boolean isRegisteredFont(String fontname)
      Checks if a certain font is registered.
      Parameters:
      fontname - the name of the font that has to be checked.
      Returns:
      true if the font is found
    • clearRegisteredFonts

      public void clearRegisteredFonts()
    • clearRegisteredFontFamilies

      public void clearRegisteredFontFamilies()