quarkusio/quarkus · error · FontFormatException

.pfa font files are not supported. Use TrueType fonts, i.e.

Error message

.pfa font files are not supported. Use TrueType fonts, i.e. .ttf files.

What it means

Quarkus AWT substitutes sun.font.Type1Font on native image and deliberately does not implement Type1 font verification/loading. Loading a .pfa font in native mode always throws FontFormatException with this message, steering users to TrueType (.ttf) fonts.

Source

Thrown at extensions/awt/runtime/src/main/java/io/quarkus/awt/runtime/JDKSubstitutions.java:32

import java.util.Properties;

import com.oracle.svm.core.annotate.Alias;
import com.oracle.svm.core.annotate.Substitute;
import com.oracle.svm.core.annotate.TargetClass;

import io.quarkus.runtime.util.IsLinux;
import io.quarkus.runtime.util.IsWindows;
import io.quarkus.runtime.util.JavaVersionLessThan25;

/**
 * Getting .pfb/.pfa files to work would require additional runtime re-init adjustments.
 * We are not doing that unless there is an explicit demand.
 */
@TargetClass(className = "sun.font.Type1Font")
final class Target_sun_font_Type1Font {
    @Substitute
    private void verifyPFA(ByteBuffer bb) throws FontFormatException {
        throw new FontFormatException(
                ".pfa font files are not supported. Use TrueType fonts, i.e. .ttf files.");
    }

    @Substitute
    private void verifyPFB(ByteBuffer bb) throws FontFormatException {
        throw new FontFormatException(
                ".pfb font files are not supported. Use TrueType fonts, i.e. .ttf files.");
    }
}

/**
 * AWT source code does not take into account a situation where "java.home" does not
 * exist. It looks for default fonts in conf/fonts and lib dirs. It is O.K. if there are
 * none as then system fonts are used instead. If the directory structure as such does not exist,
 * the code path fails though.
 *
 * We create a dummy "java.home" in "java.io.tmpdir" and we set it at a reasonable place via
 * substitution.

View on GitHub (pinned to e1c734241f)

Solutions

  1. Convert the .pfa font to TrueType (.ttf) using fontforge or a similar tool (pfa2ttf) and ship the .ttf instead
  2. Load only .ttf (or .otf) fonts in native mode
  3. If Type 1 support is essential, avoid native image or implement a custom substitution

Example fix

// before
Font font = Font.createFont(Font.TRUETYPE_FONT, getClass().getResourceAsStream("/fonts/My.pfa"));
// after (convert My.pfa -> My.ttf first)
Font font = Font.createFont(Font.TRUETYPE_FONT, getClass().getResourceAsStream("/fonts/My.ttf"));
Defensive patterns

Strategy: validation

Validate before calling

// reject unsupported font formats before loading in native mode
static void checkFont(String name) {
    String lower = name.toLowerCase(Locale.ROOT);
    if (lower.endsWith(".pfa") || lower.endsWith(".pfb")) {
        throw new IllegalArgumentException("Type 1 fonts unsupported in native mode, use .ttf: " + name);
    }
}

Try / catch

try {
    Font f = Font.createFont(Font.TRUETYPE_FONT, in);
} catch (FontFormatException e) {
    if (e.getMessage().contains(".pfa")) {
        log.error("Convert the font to TrueType (.ttf) for native image support");
    }
}

Prevention

When it happens

Trigger: Native-mode application calls Font.createFont(Font.TRUETYPE_FONT|TYPE1_FONT, stream) or GraphicsEnvironment.registerFont with a .pfa (PostScript ASCII) font file.

Common situations: JVM mode worked with .pfa fonts but native build fails; font assets bundled in resources are PostScript Type 1; UI/PDF-generation library config points at .pfa files.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/21637df895816461. Report an issue: GitHub.