Hi,
It doesn't happen with 3.0.5 either, here's the exact code I used:
try (PDDocument doc = new PDDocument())
{
File fontFile = new File("XXX/Inter.ttc");
TrueTypeCollection ttc = new TrueTypeCollection(fontFile);
var regularFont = PDType0Font.load(doc,
ttc.getFontByName("Inter-Regular"), true);
PDPage page = new PDPage();
doc.addPage(page);
try (PDPageContentStream cs = new PDPageContentStream(doc,
page))
{
cs.beginText();
cs.newLineAtOffset(10, 500);
cs.setFont(regularFont, 12);
cs.showText("This an example of sentence containing
spaces");
cs.endText();
}
doc.save("XXXX/Inter.pdf");
}
Tilman
On 26.05.2025 22:24, Maxime WIEWIORA wrote:
Hi,
Sorry, I effectively wanted to say since 3.0.3 (I also got the error with
3.0.4 and 3.0.5, but indeed, it works with 3.0.2).
The font I use is the one provided in the download page you mentioned.
When using Helvetica font, the issue is not present.
The difference is the "Inter" font has GSubData named "LATIN". In this case
a gSubWorker is defined and the execution
of PDAbstractContentStream.showTextInternal(String) is different because
the method PDAbstractContentStream.encodeForGsub(), calling the tokenize
method into which there is the infinite loop, is called.
Using an alternative font such as Helvetica could be a workaround, but this
means we need to ensure the used font (if it is not a very standard font)
doesn't contain any GSubData.
Regards,
Maxime
On 2025/05/26 19:18:39 Tilman Hausherr wrote:
Hi,
Can you tell where to find this font, or can you reproduce it with a
different (more ordinary) font?
I tried with the font on https://rsms.me/inter/download/ and no problem
with the file Inter.ttc in the zip file. I tried it with 3.0.6
(unreleased), but it also worked with 3.0.2.
Tilman
On 26.05.2025 20:55, Maxime WIEWIORA wrote:
Here is an example of code causing the error:
File fontFile = new File(ttcUrl.getFile());
TrueTypeCollection ttc = new TrueTypeCollection(fontFile);
var regularFont = PDType0Font.load(doc,
ttc.getFontByName("Inter-Regular"),
true);
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org