prawn
prawn copied to clipboard
still getting "cannot extract font" issue on prawn generated PDFs
Hi, we are getting this error when we generate PDFs with Prawn and use Adobe Acrobat to read (works fine in chrome). Google searches point to a fix where 1.62 of ttfunk fixed it, but we cannot get it to work even if we use 1.7 or 1.5, this is the message:
Thanks for any advice on how to fix.
I am still having exactly same issue. Using prawn 2.4.0 and ttfunk 1.7 or even older version with ttfunk 1.5 not working. I am currently forcing the encoding to Windows-1252 for all texts so that generating pdf don't crash since usually only few characters are special but still not ideal solution.
@kevinchugh @JuhaRomppainen Could you please provide a small example script to reproduce the problem? Together with the versions of prawn, pdf-core and ttfunk you are using?
@kevinchugh @JuhaRomppainen Could you please try master branch Prawn, pdf-core, and TTFunk and let me know if the issue is fixed for you?
I'll assume the issue has been resolved.
Feel free to reopen with more details if it's not.
The project I am working on just hit this same issue.
We are using prawn (2.5.0)
and ttfunk (1.8.0)
.
I have attached a small example PDF that displays the problem. The file loads fine in Chrome, Firefox, and Mac Preview, but there is a warning when opened in Adobe Reader.
In particular, the problem happens with the letter ä
, with an umlaut.
I have reproduced this down to a small example. Strangely, adding a single "s" into the text causes the error to disappear (see commented-out line below).
require 'prawn'
pdf = Prawn::Document.new
font_settings = {
"Barlow Semi Condensed" => {
# File downloaded from: https://github.com/jpt/barlow/blob/main/fonts/ttf/BarlowSemiCondensed-ExtraBoldItalic.ttf
extrabold_italic: "./BarlowSemiCondensed-ExtraBoldItalic.ttf"
}
}
pdf.font_families.update(font_settings)
pdf.font("Barlow Semi Condensed", style: :extrabold_italic, size: 24)
pdf.text('läuft') # This line causes the error
# pdf.text('läufts') # This line works fine
pdf.render_file('prawn-font-error.pdf')
In addition, We have seen a similar issue with an "@" symbol, when using the Graphik font. So it is not entirely isolated to the Barlow font in particular.
After some further debugging, I discovered that rolling-back to Prawn 2.4.0
was not enough to fix the problem, I needed to roll-back TTFunk as well. The breaking change, for my example, appears to come in the TTFunk 1.8.0
release.