[
https://issues.apache.org/jira/browse/PDFBOX-6169?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18132737#comment-18132737
]
Andreas Lehmkühler edited comment on PDFBOX-6169 at 10/27/26, 7:13 AM:
-----------------------------------------------------------------------
I've optimized the stuff behind encode/getStringWidth and IMHO there is no
further caching needed, see PDFBOX-6287 for further details.
Here are the results from one of your benchmarks
{code}
Java: Amazon.com Inc. 17.0.10
OS: Linux 7.2.11-200.fc44.x86_64 (amd64), 12 cores
PDFBox: 3.0.9-SNAPSHOT
Rounds: 10 warmup + 15 measured, >= 200 ms each; median reported
| Font | Texts | Operation | PDFBox ns/str |
cached ns/str | speedup | PDFBox ns/char | cached ns/char |
|------------------------|-----------------|-----------------|--------------:|--------------:|--------:|---------------:|---------------:|
| Helvetica (Std14) | short (3-15) | encode(String) | 100.3 |
75.3 | 1.33x | 7.93 | 5.96 |
| Helvetica (Std14) | short (3-15) | getStringWidth | 38.5 |
35.5 | 1.08x | 3.04 | 2.81 |
| Helvetica (Std14) | lines (60-100) | encode(String) | 657.7 |
502.1 | 1.31x | 7.86 | 6.00 |
| Helvetica (Std14) | lines (60-100) | getStringWidth | 278.1 |
251.8 | 1.10x | 3.32 | 3.01 |
| Helvetica (Std14) | para (500-1000) | encode(String) | 5036.3 |
4363.0 | 1.15x | 6.80 | 5.89 |
| Helvetica (Std14) | para (500-1000) | getStringWidth | 2495.6 |
2300.1 | 1.09x | 3.37 | 3.10 |
| Times-Roman (Std14) | short (3-15) | encode(String) | 100.4 |
75.6 | 1.33x | 7.94 | 5.98 |
| Times-Roman (Std14) | short (3-15) | getStringWidth | 41.6 |
29.2 | 1.43x | 3.29 | 2.31 |
| Times-Roman (Std14) | lines (60-100) | encode(String) | 674.5 |
511.6 | 1.32x | 8.06 | 6.11 |
| Times-Roman (Std14) | lines (60-100) | getStringWidth | 289.1 |
257.4 | 1.12x | 3.45 | 3.07 |
| Times-Roman (Std14) | para (500-1000) | encode(String) | 5197.8 |
4491.8 | 1.16x | 7.02 | 6.06 |
| Times-Roman (Std14) | para (500-1000) | getStringWidth | 2490.4 |
2251.9 | 1.11x | 3.36 | 3.04 |
| LiberationSans (Type0) | short (3-15) | encode(String) | 123.6 |
79.1 | 1.56x | 9.78 | 6.25 |
| LiberationSans (Type0) | short (3-15) | getStringWidth | 37.5 |
28.7 | 1.31x | 2.96 | 2.27 |
| LiberationSans (Type0) | lines (60-100) | encode(String) | 601.5 |
537.4 | 1.12x | 7.18 | 6.42 |
| LiberationSans (Type0) | lines (60-100) | getStringWidth | 267.1 |
259.1 | 1.03x | 3.19 | 3.10 |
| LiberationSans (Type0) | para (500-1000) | encode(String) | 4761.0 |
4663.4 | 1.02x | 6.43 | 6.30 |
| LiberationSans (Type0) | para (500-1000) | getStringWidth | 2282.4 |
2297.7 | 0.99x | 3.08 | 3.10 |
(sink 13228411102972)
{code}
was (Author: lehmi):
I've optimized the stuff behind encode/getStringWidth and IMHO there is no
further caching needed, see PDFBOX-6287 for further details.
> 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
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]