[
https://issues.apache.org/jira/browse/PDFBOX-6169?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18122094#comment-18122094
]
Philip Helger commented on PDFBOX-6169:
---------------------------------------
[~lehmi] thanks for asking. I took the liberty to provide a small performance
comparison as a standalone benchmark (based on PDFBox 3.0.8) in the GitHub
repo:
[https://github.com/phax/ph-pdf-layout/tree/master/ph-pdf-layout/src/test/java/org/apache/pdfbox/pdmodel/font]
There are 3 different versions of the benchmark that I just created to find the
best combo. The plain benchmark is pure JDK + PDFBox.
It compares PDFont.encode(String) / PDFont.getStringWidth(String) against a
simple per-code-point cache built on the protected PDFont.encode(int) - which
is what ph-pdf-layout does. Both variants are verified to produce identical
bytes and widths before timing.
Additionally I added the benchmark results from my machine (in battery mode) as
text files - all 3 benchmarks ran with Java 17 and Java 25 - but I don't see a
significant improvement.
Basically your cache for string width works very well in the meantime, but the
string width implementation could clearly benefit from a cache as well.
However, it doesn't show the fallback code which you can easily see in
[https://github.com/phax/ph-pdf-layout/blob/master/ph-pdf-layout/src/main/java/com/helger/pdflayout/spec/LoadedFont.java#L184-L215]
(under the assumption that there is always a fallback present).
hth
> Request to make PDFont.encode public
> ------------------------------------
>
> Key: PDFBOX-6169
> URL: https://issues.apache.org/jira/browse/PDFBOX-6169
> Project: PDFBox
> Issue Type: Improvement
> Components: PDModel
> Affects Versions: 3.0.6 PDFBox
> Reporter: Philip Helger
> Priority: Major
>
> Please make the following methods public:
> protected abstract byte[] encode(int unicode) throws IOException;
> I am using it in ph-pdf-layout for more efficient text rendering.
> To make sure the library works in a module-based environment, I need to get
> rid of the package-private override:
> [https://github.com/phax/ph-pdf-layout/issues/62]
> Thanks, Philip
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]