manuelbl / SwissQRBill

Java library for Swiss QR bill payment slips (aka QR-Rechnung)
https://www.codecrete.net/qrbill
MIT License
155 stars 37 forks source link

Unsupported system font triggers IOException #92

Closed franck102 closed 3 months ago

franck102 commented 3 months ago

On a MacOS Sonoma 14.1.2 machine the library fails with the exception below. I checked the Apache fontbox project which explicitly state that they don't support (and cannot and won't support) all type 1 PDF fonts, is there a way to set up QR Bill so that pdfBox doesn't try to scan all fonts in the system?

The library version is

            <dependency>
                <groupId>net.codecrete.qrbill</groupId>
                <artifactId>qrbill-generator</artifactId>
                <version>[3.0.0,3.999999]</version>
            </dependency>
09:44:31 [totem] WARN  [or.ap.pd.pd.fo.FileSystemFontProvider] (vert.x-worker-thread-1) Could not load font file: /System/Library/Fonts/LastResort.otf: java.io.IOException: Invalid character code 0xD800
    at org.apache.fontbox.ttf.CmapSubtable.processSubtype13(CmapSubtable.java:320)
    at org.apache.fontbox.ttf.CmapSubtable.initSubtable(CmapSubtable.java:113)
    at org.apache.fontbox.ttf.CmapTable.read(CmapTable.java:87)
    at org.apache.fontbox.ttf.TrueTypeFont.readTable(TrueTypeFont.java:365)
    at org.apache.fontbox.ttf.TTFParser.parseTables(TTFParser.java:165)
    at org.apache.fontbox.ttf.TTFParser.parse(TTFParser.java:144)
    at org.apache.fontbox.ttf.OTFParser.parse(OTFParser.java:56)
    at org.apache.fontbox.ttf.OTFParser.parse(OTFParser.java:27)
    at org.apache.fontbox.ttf.TTFParser.parse(TTFParser.java:66)
    at org.apache.fontbox.ttf.OTFParser.parse(OTFParser.java:50)
    at org.apache.pdfbox.pdmodel.font.FileSystemFontProvider.addTrueTypeFont(FileSystemFontProvider.java:684)
    at org.apache.pdfbox.pdmodel.font.FileSystemFontProvider.scanFonts(FileSystemFontProvider.java:390)
    at org.apache.pdfbox.pdmodel.font.FileSystemFontProvider.<init>(FileSystemFontProvider.java:365)
    at org.apache.pdfbox.pdmodel.font.FontMapperImpl$DefaultFontProvider.<clinit>(FontMapperImpl.java:139)
    at org.apache.pdfbox.pdmodel.font.FontMapperImpl.getProvider(FontMapperImpl.java:158)
    at org.apache.pdfbox.pdmodel.font.FontMapperImpl.findFont(FontMapperImpl.java:410)
    at org.apache.pdfbox.pdmodel.font.FontMapperImpl.findFontBoxFont(FontMapperImpl.java:373)
    at org.apache.pdfbox.pdmodel.font.FontMapperImpl.getFontBoxFont(FontMapperImpl.java:347)
    at org.apache.pdfbox.pdmodel.font.PDType1Font.<init>(PDType1Font.java:127)
    at net.codecrete.qrbill.canvas.PDFCanvas.configureFonts(PDFCanvas.java:344)
    at net.codecrete.qrbill.canvas.PDFCanvas.<init>(PDFCanvas.java:168)
    at net.codecrete.qrbill.canvas.PDFCanvas.<init>(PDFCanvas.java:137)
    at com.easypass.register.service.SwissQRService.generateQRCode(SwissQRService.java:78)
franck102 commented 3 months ago

My bad, fontbox only generates a warning, my problem lies elsewhere...