Package net.codecrete.qrbill.canvas
Class PDFFontSettings
java.lang.Object
net.codecrete.qrbill.canvas.PDFFontSettings
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Font embedding options. -
Method Summary
Modifier and TypeMethodDescriptionstatic PDFFontSettings
embeddedCustomFont
(String fontFamily, Path regularFontPath, Path boldFontPath) Creates a font settings instance for a custom font.static PDFFontSettings
Creates a font settings instance for the Liberation Sans font.Gets the path to the bold font face in TrueType format.Gets the font embedding.Gets the font family name relevant for calculating line breaks.Gets the path to the regular font face in TrueType format.static PDFFontSettings
Creates a font settings instance for the standard Helvetica font.
-
Method Details
-
standardHelvetica
Creates a font settings instance for the standard Helvetica font.- Returns:
- font settings instance
-
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 nameregularFontPath
- path to the regular font face in TrueType formatboldFontPath
- path to the bold font face in TrueType format- Returns:
- font settings instance
-
getFontEmbedding
Gets the font embedding.- Returns:
- font embedding option
-
getFontFamily
Gets the font family name relevant for calculating line breaks.- Returns:
- font family name
-
getRegularFontPath
Gets the path to the regular font face in TrueType format.- Returns:
- font path
-
getBoldFontPath
Gets the path to the bold font face in TrueType format.- Returns:
- font path
-