quarkusio/quarkus · error · FontFormatException

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

Error message

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

What it means

Companion to the .pfa substitution: Quarkus AWT also does not support Type 1 .pfb (PostScript Binary) fonts in native mode. verifyPFB is substituted to always throw FontFormatException with this message.

Source

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

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.
 */
@TargetClass(className = "sun.awt.FontConfiguration", onlyWith = IsLinux.class)
final class Target_sun_awt_FontConfiguration_Linux {
    @Alias
    protected static String osVersion;
    @Alias

View on GitHub (pinned to e1c734241f)

Solutions

  1. Convert the .pfb font to .ttf (fontforge, pfb2ttf) and use the TrueType file
  2. Remove .pfb entries from font registration/config and use .ttf/.otf only
  3. Avoid native image if Type 1 fonts are strictly required

Example fix

// before
registerFont("fonts/My.pfb");
// after (convert My.pfb -> My.ttf)
registerFont("fonts/My.ttf");
Defensive patterns

Strategy: validation

Validate before calling

static void checkFont(String name) {
    String lower = name.toLowerCase(Locale.ROOT);
    if (lower.endsWith(".pfb") || lower.endsWith(".pfa")) {
        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(".pfb")) {
        log.error("Use the TrueType (.ttf) variant of this font in native mode");
    }
}

Prevention

When it happens

Trigger: Native-mode application registers or loads a .pfb font file via Font.createFont or GraphicsEnvironment.registerFont.

Common situations: Font bundles containing .pfb companions (common with PostScript font families); config pointing at the .pfb instead of the .ttf; worked in JVM mode, fails in native.

Related errors


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