2

I've been using PDFBox instead of iText 7 for a few days now, and it's given me a bunch of new freedoms, but the main reason I changed was so I could enable ligatures in my PDF documents (for free).

I've already managed to enable oldstyle numerals and the likes (though the constant warning messages are starting to get on my nerves), but the liga feature doesn't seem to work (which was probably just getting my hopes up a little too high). I've tested the code below with a variety of fonts, including Minion Pro, EB Garamond and Alegreya.

TrueTypeFont font = new TTFParser().parse(file);
font.enableGsubFeature("onum"); // complains, but works: "WARNING: Trying to un-substitute a never-before-seen gid: ..."
font.enableGsubFeature("liga"); // has no effect

return PDType0Font.load(doc, font, false);

So instead, I've decided it'd be enough for me to just get access to e.g. a list of the font's supported ligatures and their mappings (probably to the Private Use Area), so I can just substitute ligatures manually (not caring about toUnicode for the moment). Problem is, I can't seem to find a way of doing that. Any ideas? (also for other approaches, this just currently seems to me the most likely one to work)

I'd say this isn't a duplicate of pdfbox - How to join glyphs into ligatures in rendered pdf, as the person there asked for built-in support, whereas I'm attempting to manually apply ligatures using FontBox.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
linux_user36
  • 113
  • 1
  • 8
  • It's not implemented in PDFBox. There's still a lot of work to do. – Tilman Hausherr May 07 '23 at 04:56
  • You can also use the unicode directly, like "affluent", this does work for Arial. (copy character from https://www.compart.com/de/unicode/U+FB04 ) – Tilman Hausherr May 08 '23 at 07:49
  • So I'd support "ff", "fi", "fl", "ffi" and "ffl" out of the box, and then ask the user for codepoints of additional ligatures if they wish for them? Thanks for bringing that idea to my attention! – linux_user36 May 08 '23 at 16:04
  • Your text made me look again at some code I had and this time I got it to work, see https://issues.apache.org/jira/browse/PDFBOX-5599 . This will be available only in 3.0 and for now only in a snapshot build (in a few hours) https://repository.apache.org/content/groups/snapshots/org/apache/pdfbox/pdfbox-app/3.0.0-SNAPSHOT/ – Tilman Hausherr May 11 '23 at 18:36

0 Answers0