prawn icon indicating copy to clipboard operation
prawn copied to clipboard

still getting "cannot extract font" issue on prawn generated PDFs

Open kevinchugh opened this issue 3 years ago • 3 comments

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:

image

Thanks for any advice on how to fix.

kevinchugh avatar May 21 '21 23:05 kevinchugh

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.

JuhaRomppainen avatar Jan 07 '22 09:01 JuhaRomppainen

@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?

gettalong avatar Feb 21 '23 08:02 gettalong

@kevinchugh @JuhaRomppainen Could you please try master branch Prawn, pdf-core, and TTFunk and let me know if the issue is fixed for you?

pointlessone avatar Feb 13 '24 14:02 pointlessone

I'll assume the issue has been resolved.

Feel free to reopen with more details if it's not.

pointlessone avatar Mar 04 '24 10:03 pointlessone

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.

acrobat-test-20240320-163458.pdf

tonymarklove avatar Mar 20 '24 16:03 tonymarklove

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.

tonymarklove avatar Mar 22 '24 11:03 tonymarklove

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.

tonymarklove avatar Mar 22 '24 14:03 tonymarklove