[jira] [Commented] (FOP-3313) Multi-threaded FOP usage breaks FontLoader
"Simon Steiner (Jira)" <[email protected]> Mon, 1 Jun 2026 10:14:00 +0000 (UTC)
| Newsgroups | gmane.text.xml.fop.devel |
|---|---|
| Message-ID | <[email protected]> |
[ https://issues.apache.org/jira/browse/FOP-3313?page=3Dcom.atlassian.j=
ira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D180851=
81#comment-18085181 ]=20
Simon Steiner commented on FOP-3313:
------------------------------------
This error "Unsupported TrueType font: No Unicode or Symbol cmap table not =
present. Aborting"
seems like you are trying to use a font we dont support, rather than a issu=
e with multithreading
> Multi-threaded FOP usage breaks FontLoader
> ------------------------------------------
>
> Key: FOP-3313
> URL: https://issues.apache.org/jira/browse/FOP-3313
> Project: FOP
> Issue Type: Bug
> Components: font/unqualified, renderer/pdf
> Affects Versions: 2.4
> Reporter: Ben
> Priority: Major
>
> I'm trying to convert our usage of Apache FOP from a single-threaded impl=
ementation to a multi-threaded one.
> We have a process that generates PDF documents for every item in a large =
dataset, and this is creating a performance bottleneck: each item takes abo=
ut 200ms to generate using FOP in out single-threaded implementation.
> The wrapper class by which we use FOP, FopConfiguration, declares a {{Fop=
Factory}}=C2=A0field. I've now converted it to a {{{}private ThreadLocal<Fo=
pFactory> factory{}}}.
> I have a font directory that the FOP factory needs to load custom fonts f=
rom. This directory is initialised once, and then passed to the code that i=
nstantiates the ThreadLocal.
> I would expect switching to ThreadLocal for the FopFactory would be suffi=
cient, but what I'm instead seeing is that when {{agent.newFop}} is called,=
it's causing {{org.apache.fop.fonts.FontLoader#read}} to be called within =
that thread.
> There seems to be some resource contention within that method, because in=
contrast to the single-threaded wrapper, the multi-threaded wrapper is fai=
ling at {{OpenFont.readCMAP}} with the following error:
> Unsupported TrueType font: No Unicode or Symbol cmap table not present. A=
borting
> So it seems like the FOP agent is lazy-loading some fonts, and doing so i=
sn't thread-safe?
> =C2=A0
> {code:java}
> at org.apache.fop.fonts.truetype.OpenFont.readCMAP(OpenFont.java:443)
> at org.apache.fop.fonts.truetype.OpenFont.readFont(OpenFont.java:846)
> at org.apache.fop.fonts.truetype.OFFontLoader.read(OFFontLoader.java:117)
> at org.apache.fop.fonts.truetype.OFFontLoader.read(OFFontLoader.java:101)
> at org.apache.fop.fonts.FontLoader.getFont(FontLoader.java:126)
> at org.apache.fop.fonts.autodetect.FontInfoFinder.find(FontInfoFinder.jav=
a:227)
> at org.apache.fop.fonts.FontAdder.add(FontAdder.java:63)
> at org.apache.fop.fonts.FontDetectorFactory$DefaultFontDetector.detect(Fo=
ntDetectorFactory.java:105)
> at org.apache.fop.fonts.FontManager.autoDetectFonts(FontManager.java:229)
> at org.apache.fop.fonts.DefaultFontConfigurator.configure(DefaultFontConf=
igurator.java:82)
> at org.apache.fop.render.PrintRendererConfigurator.getCustomFontCollectio=
n(PrintRendererConfigurator.java:147)
> at org.apache.fop.render.PrintRendererConfigurator.setupFontInfo(PrintRen=
dererConfigurator.java:127)
> at org.apache.fop.render.intermediate.IFUtil.setupFonts(IFUtil.java:170)
> at org.apache.fop.render.intermediate.IFRenderer.setupFontInfo(IFRenderer=
.java:187)
> at org.apache.fop.area.RenderPagesModel.<init>(RenderPagesModel.java:75)
> at org.apache.fop.area.AreaTreeHandler.setupModel(AreaTreeHandler.java:13=
5)
> at org.apache.fop.area.AreaTreeHandler.<init>(AreaTreeHandler.java:105)
> at org.apache.fop.render.RendererFactory.createFOEventHandler(RendererFac=
tory.java:363)
> at org.apache.fop.fo.FOTreeBuilder.<init>(FOTreeBuilder.java:107)
> at org.apache.fop.apps.Fop.createDefaultHandler(Fop.java:104)
> at org.apache.fop.apps.Fop.<init>(Fop.java:78)
> at org.apache.fop.apps.FOUserAgent.newFop(FOUserAgent.java:183)
> {code}
> =C2=A0
> =C2=A0
> =C2=A0
--
This message was sent by Atlassian Jira
(v8.20.10#820010)