quarkiverse / quarkus-poi

Apache POI is an API to access Microsoft Office files. This extension provides integration with Apache POI
https://poi.apache.org/
Apache License 2.0
12 stars 3 forks source link

Request for information: Fontconfig head is null, check your fonts or fonts configuration #101

Closed argenstijn closed 7 months ago

argenstijn commented 8 months ago

Do you happen what i can do to fix this issue below?

exception": { "refId": 1, "exceptionType": "java.lang.RuntimeException", "message": "Fontconfig head is null, check your fonts or fonts configuration", "frames": [ { "class": "sun.awt.FontConfiguration", "method": "getVersion", "line": 1263 }, { "class": "sun.awt.FontConfiguration", "method": "readFontConfigFile", "line": 221 }, { "class": "sun.awt.FontConfiguration", "method": "init", "line": 105 }, { "class": "sun.awt.X11FontManager", "method": "createFontConfiguration", "line": 696 }, { "class": "sun.font.SunFontManager$2", "method": "run", "line": 352 }, { "class": "sun.font.SunFontManager$2", "method": "run", "line": 309 }, { "class": "java.security.AccessController", "method": "executePrivileged", "line": 129 }, { "class": "java.security.AccessController", "method": "doPrivileged", "line": 319 }, { "class": "sun.font.SunFontManager", "method": "", "line": 309 }, { "class": "sun.awt.FcFontManager", "method": "", "line": 35 }, { "class": "sun.awt.X11FontManager", "method": "", "line": 55 }, { "class": "sun.font.PlatformFontInfo", "method": "createFontManager", "line": 37 }, { "class": "sun.font.FontManagerFactory", "method": "getInstance", "line": 51 }, { "class": "java.awt.Font", "method": "getFont2D", "line": 526 }, { "class": "java.awt.Font", "method": "canDisplayUpTo", "line": 2278 }, { "class": "java.awt.font.TextLayout", "method": "singleFont", "line": 469 }, { "class": "java.awt.font.TextLayout", "method": "", "line": 530 }, { "class": "org.apache.poi.ss.util.SheetUtil", "method": "getDefaultCharWidthAsFloat", "line": 352 }, { "class": "org.apache.poi.ss.util.SheetUtil", "method": "getColumnWidth", "line": 310 }, { "class": "org.apache.poi.ss.util.SheetUtil", "method": "getColumnWidth", "line": 294 }, { "class": "org.apache.poi.xssf.usermodel.XSSFSheet", "method": "autoSizeColumn", "line": 497 }, { "class": "org.apache.poi.xssf.usermodel.XSSFSheet", "method": "autoSizeColumn", "line": 479 }, { "class": "com.nn.aav.insurance.business.reporting.control.ExcelSupport", "method": "createExcelColumns", "line": 91 }, { "class": "com.nn.aav.insurance.business.reporting.control.ExcelSupport", "method": "csvToExcelReport", "line": 60 }, { "class": "com.nn.aav.insurance.business.reporting.control.IndependerReportRepository", "method": "createReportForSource", "line": 85 }, { "class": "com.nn.aav.insurance.business.reporting.control.IndependerReportRepository", "method": "createReportForSourceIfNotComplete", "line": 73 }, { "class": "com.nn.aav.insurance.business.reporting.boundary.IndependerInsuranceRequestResultReporter", "method": "lambda$handleRequest$0", "line": 35 }, { "class": "java.lang.Iterable", "method": "forEach", "line": 75 }, { "class": "com.nn.aav.insurance.business.reporting.boundary.IndependerInsuranceRequestResultReporter", "method": "handleRequest", "line": 32 }, { "class": "com.nn.aav.insurance.business.reporting.boundary.IndependerInsuranceRequestResultReporter", "method": "handleRequest", "line": 17 }, { "class": "io.quarkus.amazon.lambda.runtime.AmazonLambdaRecorder$1", "method": "processRequest", "line": 167 }, { "class": "io.quarkus.amazon.lambda.runtime.AbstractLambdaPollLoop$1", "method": "run", "line": 142 }, { "class": "java.lang.Thread", "method": "runWith", "line": 1596 }, { "class": "java.lang.Thread", "method": "run", "line": 1583 }, { "class": "com.oracle.svm.core.thread.PlatformThreads", "method": "threadStartRoutine", "line": 833 }, { "class": "com.oracle.svm.core.posix.thread.PosixPlatformThreads", "method": "pthreadStartRoutine", "line": 211 } ] } }

This in a native quarkus application using version 3.8.2. It's running in AWS as lambda using the latest runtime. I am using Java 21!. I think the latest runtime in AWS does not support fonts anymore.

I will try to set system prop: org.apache.poi.ss.ignoreMissingFontSystem

If this prop works can this also be added as configuration option for quarkus-poi?

argenstijn commented 8 months ago

It works in Amazon linux 2 but not when you use Amazone Linix 2023 as lambda provider

argenstijn commented 8 months ago

Setting org.apache.poi.ss.ignoreMissingFontSystem does not work in my situation!

argenstijn commented 8 months ago

Interesting:

Quarkus or quarkus-awt is now throwing a RuntimeException. But in the code of apache

@Internal
    public static float getDefaultCharWidthAsFloat(final Workbook wb) {
        Font defaultFont = wb.getFontAt( 0);

        AttributedString str = new AttributedString(String.valueOf(defaultChar));
        copyAttributes(defaultFont, str, 0, 1);
        try {
            TextLayout layout = new TextLayout(str.getIterator(), fontRenderContext);
            return layout.getAdvance();
        } catch (Throwable t) {
            // ignore exception and return a default char width if
            // the ignore-feature is enabled and the exception indicates that
            // the underlying font system is not available
            if (ignoreMissingFontSystem && (
                    // the three types of exception usually indicate here that the font
                    // system is not fully installed, i.e. system libraries missing or
                    // some JDK classes cannot be loaded
                    t instanceof UnsatisfiedLinkError ||
                    t instanceof NoClassDefFoundError ||
                    t instanceof InternalError  ||
                    // other fatal exceptions will always be rethrown
                    !ExceptionUtil.isFatal(t))) {
                return DEFAULT_CHAR_WIDTH;
            }

            throw t;
        }
    }

So the property does not work because awt/quarkus throws a runtime exception. Do you also agree with this?

melloware commented 8 months ago

See #95

Quarkus Issue: https://github.com/quarkusio/quarkus/issues/38412

melloware commented 7 months ago

I updated the Native build instructions for how to include .so files in the native build. Will close for now.