Class BasicFontProvider

java.lang.Object
com.itextpdf.layout.font.FontProvider
com.itextpdf.styledxmlparser.resolver.font.BasicFontProvider

public class BasicFontProvider extends FontProvider
A basic FontProvider that allows configuring in the constructor which fonts are loaded by default.
  • Field Details

    • shippedFontResourcePath

      protected String shippedFontResourcePath
      The path to the shipped fonts.
    • shippedFontNames

      protected List<String> shippedFontNames
      The file names of the shipped fonts.
  • Constructor Details

    • BasicFontProvider

      public BasicFontProvider()
      Creates a new BasicFontProvider instance.
    • BasicFontProvider

      public BasicFontProvider (boolean registerStandardPdfFonts, boolean registerSystemFonts)
      Creates a new BasicFontProvider instance.
      Parameters:
      registerStandardPdfFonts - use true if you want to register the standard Type 1 fonts (can't be embedded)
      registerSystemFonts - use true if you want to register the system fonts (can require quite some resources)
    • BasicFontProvider

      public BasicFontProvider (boolean registerStandardPdfFonts, boolean registerShippedFonts, boolean registerSystemFonts)
      Creates a new BasicFontProvider instance.
      Parameters:
      registerStandardPdfFonts - use true if you want to register the standard Type 1 fonts (can't be embedded)
      registerShippedFonts - use true if you want to register the shipped fonts (can be embedded)
      registerSystemFonts - use true if you want to register the system fonts (can require quite some resources)
    • BasicFontProvider

      public BasicFontProvider (boolean registerStandardPdfFonts, boolean registerSystemFonts, String defaultFontFamily)
      Creates a new BasicFontProvider instance.
      Parameters:
      registerStandardPdfFonts - use true if you want to register the standard Type 1 fonts (can't be embedded)
      registerSystemFonts - use true if you want to register the system fonts (can require quite some resources)
      defaultFontFamily - default font family
    • BasicFontProvider

      public BasicFontProvider (boolean registerStandardPdfFonts, boolean registerShippedFonts, boolean registerSystemFonts, String defaultFontFamily)
      Creates a new BasicFontProvider instance.
      Parameters:
      registerStandardPdfFonts - use true if you want to register the standard Type 1 fonts (can't be embedded)
      registerShippedFonts - use true if you want to register the shipped fonts (can be embedded)
      registerSystemFonts - use true if you want to register the system fonts (can require quite some resources)
      defaultFontFamily - default font family
    • BasicFontProvider

      public BasicFontProvider (FontSet fontSet, String defaultFontFamily)
      Creates a new BasicFontProvider instance.
      Parameters:
      fontSet - predefined set of fonts, could be null.
      defaultFontFamily - default font family.
  • Method Details

    • addCalligraphFonts

      protected Range addCalligraphFonts()
      This method loads a list of noto fonts from pdfCalligraph (if it is present in the classpath) into FontProvider. The list is the following (each font is represented in regular and bold types): NotoSansArabic, NotoSansGurmukhi, NotoSansOriya, NotoSerifBengali, NotoSerifDevanagari, NotoSerifGujarati, NotoSerifHebrew, NotoSerifKannada, NotoSerifKhmer, NotoSerifMalayalam, NotoSerifTamil, NotoSerifTelugu, NotoSerifThai. If it's needed to have a BasicFontProvider without typography fonts loaded, create an extension of BasicFontProvider and override this method, so it does nothing and only returns null.
      Returns:
      a unicode Range that excludes the loaded from pdfCalligraph fonts, i.e. the unicode range that is to be rendered with any other font contained in this FontProvider
    • addShippedFonts

      protected void addShippedFonts (Range rangeToLoad)
      Adds fonts shipped with the font provider. For BasicFontProvider this method does nothing but can be overridden to load additional fonts.
      Parameters:
      rangeToLoad - a unicode Range to load characters
    • initShippedFontsResourcePath

      protected void initShippedFontsResourcePath()
      Initialize path to shipped fonts and list of font files.