Class PDFFontSettings

java.lang.Object
net.codecrete.qrbill.canvas.PDFFontSettings

public class PDFFontSettings extends Object
Sets the font to use for a PDF canvas.

To render a QR bill to a PDF document, a regular and a bold font face are needed. According to the Swiss QR bill specification, only the non-serif fonts Helvetica, Arial, Liberation Sans and Frutiger are allowed.

There are three options for fonts:

  • Use the standard Helvetica font. It does not need to be embedded in the PDF document as it is supported by all PDF viewers. However, it only covers the WinANSI character set. This is sufficient for the Latin 1 Subset character set but not for the Extended Latin character set.
  • Use the Liberation Sans font that comes with this library. It covers a wide range of characters and is sufficient for the Extended Latin character set. The subset of used characters will be embedded in the PDF document. The font has been published under SIL OPEN FONT LICENSE Version 1.1 and is free for use.
  • Provide paths to a regular and bold font face in TrueType format. The subset of the used characters will be embedded in the PDF document.
  • Method Details

    • standardHelvetica

      public static PDFFontSettings standardHelvetica()
      Creates a font settings instance for the standard Helvetica font.
      Returns:
      font settings instance
    • embeddedLiberationSans

      public static PDFFontSettings embeddedLiberationSans()
      Creates a font settings instance for the Liberation Sans font.
      Returns:
      font settings instance
    • embeddedCustomFont

      public static PDFFontSettings embeddedCustomFont(String fontFamily, Path regularFontPath, Path boldFontPath)
      Creates a font settings instance for a custom font.

      The font family name is used to determine what font information to use for calculating line breaks.

      Parameters:
      fontFamily - font family name
      regularFontPath - path to the regular font face in TrueType format
      boldFontPath - path to the bold font face in TrueType format
      Returns:
      font settings instance
    • getFontEmbedding

      public PDFFontSettings.FontEmbedding getFontEmbedding()
      Gets the font embedding.
      Returns:
      font embedding option
    • getFontFamily

      public String getFontFamily()
      Gets the font family name relevant for calculating line breaks.
      Returns:
      font family name
    • getRegularFontPath

      public Path getRegularFontPath()
      Gets the path to the regular font face in TrueType format.
      Returns:
      font path
    • getBoldFontPath

      public Path getBoldFontPath()
      Gets the path to the bold font face in TrueType format.
      Returns:
      font path