SwissQRBill icon indicating copy to clipboard operation
SwissQRBill copied to clipboard

Prepackaged fonts are not used?

Open rajmondx opened this issue 1 year ago • 2 comments

I'm not sure if I'm using the library incorrectly, but I assumed that the fonts in [/generator/src/main/resources/fonts](https://github.com/manuelbl/SwissQRBill/tree/c2dd1b8d31575e9f3a62144d8dc131f8b23a7c92/generator/src/main/resources/fonts) are always available.

I see that the default font configuration is already defined as:
fontFamily = "Helvetica, Arial, \"Liberation Sans\"";

However, to be certain, I'm using only "Liberation Sans", yet the font is not being loaded.

Could the issue be that fonts should be located in src/main/resources/static/fonts/ instead of src/main/resources/fonts/?

I appreciate your time and effort.

rajmondx avatar Mar 12 '25 13:03 rajmondx

The pre-packaged fonts should be used if:

  • PDF output is generated
  • The bill's character set is either EXTENDED_LATIN or FULL_UNICODE (see https://javadoc.io/static/net.codecrete.qrbill/qrbill-generator/3.3.1/net/codecrete/qrbill/generator/Bill.html#setCharacterSet(net.codecrete.qrbill.generator.SPSCharacterSet)

I do not recommend using these character sets yet unless you validate yourself that the bill data does not include characters that won't be allowed until November 2025.

Another way to force it is to create the PDFCanvas instance manually, something like:

try (var canvas = new PDFCanvas(drawingWidth, drawingHeight, PDFFontSettings.embeddedLiberationSans())) {
    QRBill.draw(bill, canvas);
    var pdfBytes = canvas.toByteArray();
}

For SVG output, Helvetica, Arial, "Liberation Sans" is added to the SVG verbatim. For PNG output, the library relies on the native fonts installed by the underlying operating system.

manuelbl avatar Mar 12 '25 15:03 manuelbl

Thank you. Yes, we are (afaik) using PNG output but the OS doesn't include the required fonts so we just gonna add them.

Again, thanks for your time. Feel free to close this issue.

rajmondx avatar Mar 12 '25 16:03 rajmondx