[
https://issues.apache.org/jira/browse/PDFBOX-6220?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18097041#comment-18097041
]
Tilman Hausherr edited comment on PDFBOX-6220 at 7/18/26 11:35 AM:
-------------------------------------------------------------------
It turns out that I misunderstood the idea, what he suggested is to directly
cache the {color:#222233}GlyphArraySplitter {color}objects.
Current idea: add
private Map<String,GlyphArraySplitter> map = new WeakHashMap<>();
...
GlyphArraySplitter glyphArraySplitter =
map.computeIfAbsent(scriptFeature.getName(), (__) -> new
GlyphArraySplitterRegexImpl(allGlyphIdsForSubstitution));
was (Author: tilman):
It turns out that I misunderstood the idea, what he suggested is to directly
cache the {color:#222233}GlyphArraySplitter {color}objects.
> Cache gsubworker to avoid GSUB splitter rebuilt on every showText
> -----------------------------------------------------------------
>
> Key: PDFBOX-6220
> URL: https://issues.apache.org/jira/browse/PDFBOX-6220
> Project: PDFBox
> Issue Type: Improvement
> Affects Versions: 3.0.8 PDFBox
> Reporter: Tilman Hausherr
> Assignee: Tilman Hausherr
> Priority: Major
> Fix For: 3.0.9 PDFBox, 4.0.0
>
>
> {quote}Profiling PDF text rendering with openhtmltopdf (PDFBox 3.0.4, but I
> also
> checked 3.0.8 and trunk), I found that GsubWorkerForLatin.applyGsubFeature
> builds a new GlyphArraySplitterRegexImpl on every call. That regex depends
> only on the font, not on the text, but it gets rebuilt on every showText
> call, because PDAbstractContentStream recreates the GsubWorker in setFont
> on every call instead of keeping the one already cached in gsubWorkers.
> In our specific case, on a 14-page PDF, using a font with a ccmp feature
> (Inter), this rebuilding represents most of the time spent drawing text.
> Caching the splitter regex per font (local test with patched PDFBox) saves
> about 250 ms. The output is unchanged.{quote}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]