prawn icon indicating copy to clipboard operation
prawn copied to clipboard

Embedding TTF fonts doesn't seem to work in Adobe Reader

Open Xac opened this issue 14 years ago • 7 comments

When embedding the standard Arial.tff font, it's not correctly rendering in Adobe Reader 8/9. I have tried the same document in Preview in OS X and it works fine.

I get this error when the document is opened in Adobe Reader: Cannot extract the embedded font 'AAAAAC+ArialMT'. Some characters may not display or print correctly.

The code I'm using to embed the font is standard: font("/path/to/Arial.ttf") do text "TEST" end

Xac avatar Mar 04 '10 19:03 Xac

There may have been a regression, can you build from the stable branch and see if it fixes the problem?

-greg

practicingruby avatar Mar 04 '10 19:03 practicingruby

You are correct. This feature works as expected in 0.8.4. Thanks.

Xac avatar Mar 04 '10 19:03 Xac

Actually, it works in Adobe Reader when generated on my local machine after updating, but when I move it to our production server (Windows) and generate it, even on Prawn 0.8.4 I get the same thing.

Xac avatar Mar 04 '10 20:03 Xac

Check to make sure your versions match on your production machine. Then try the latest stable branch code here on github, then try a different font. If you still end up with a failure, provide us with a font we can download and test with.

practicingruby avatar Mar 04 '10 20:03 practicingruby

I can be sure that the versions do match. The gems are vendored in a Rails project and there is no local installed copy. I'll give the stable a shot tomorrow along with a different font.

Xac avatar Mar 04 '10 20:03 Xac

I got the exact same issue.

Preconditions:

OS: OSX 10.3.2 ruby: 2.5.0 prawn: 2.2.2

Code:

    def pdf_document
      doc = Prawn::Document.new(page_size: 'A4')
      font_prefix = Rails.root.join('lib/pdf_exporter/fonts')

      doc.font_families.update("Avenir Next W1G" => {
        :normal => "#{font_prefix}/AvenirNextW1G-Regular.ttf",
        :italic => "#{font_prefix}/AvenirNextW1G-Italic.ttf",
        :bold => "#{font_prefix}/AvenirNextW1G-Bold.ttf",
      })
      doc.font "Avenir Next W1G"
      doc
    end

While generating file in Mac (dev or production environments), the file is opened both in mac's Preview app and Adobe Reader without any issues. While generated on production server (dockerized ubuntu/alpine linux) the file is opening with no issues in mac's Preview app but with default fonts and corrupted when opened using Adobe Reader:

Cannot extract the embedded font 'fd3e38+AvenirNextW1G-Bold'. Some characters may not display or print correctly.

I have tried using github gem instead of Rubygems, have tried to rename and move files across the project directory, converting to other formats - nothing helps.

juanpedrojose avatar Feb 14 '18 18:02 juanpedrojose

Random thing to check: is the font file available on production server?

Could you please attach a sample pdf so someone could examine it?

pointlessone avatar Feb 14 '18 19:02 pointlessone

It's hard to tell what the original issue was. Since it was reported quite a few similar issue has been fixed both in Prawn and TTFunk. I'm closing this issue assuming the original issue might've been fixed. If you're having an issue please open an new issue with more details.

pointlessone avatar Jan 17 '24 10:01 pointlessone