prawnpdf / ttfunk

Font Metrics Parser for Prawn
http://prawnpdf.org
Other
125 stars 75 forks source link

Font problems in PDFs with version 1.6.* #72

Closed georf closed 4 years ago

georf commented 4 years ago

Yesterday I updated my Rails project to ttfunk 1.6.0. My users have problems with embedded fonts in Adobe Acrobat. German Umlauts are not displayed anymore. Adobe shows the German error: "Die eingebettete Schrift "815ef7+DejaVuSans" konnte nicht entnommen werden. Einige Zeichen werden u. U. nicht korrekt angezeigt bzw. gedruckt."

Today I updated to 1.6.1 and now all chars are not displayed with Adobe.

On my Linux System with xreader I have no problems. In Firefox I got the following errors, but there I see the Umlaut chars:

PDF 509a1cc8bc45a172ea4317787b03c5fd [1.7 itext-paulo-155 (itextpdf.sf.net-lowagie.com) / pdftk 2.02 - www.pdftk.com] (PDF.js: 2.4.43) viewer.js:1228:15
Warning: AcroForm/XFA is not supported viewer.js:1250:17
downloadable font: maxp: Bad maxZones: 0 (font-family: "g_d0_f1" style:normal weight:400 stretch:100 src index:0) source: (invalid URI)
downloadable font: maxp: Bad maxZones: 0 (font-family: "g_d0_f2" style:normal weight:400 stretch:100 src index:0) source: (invalid URI)
downloadable font: OS/2: Error reading more basic table fields (font-family: "g_d0_f2" style:normal weight:400 stretch:100 src index:0) source: (invalid URI)
downloadable font: OS/2: Failed to parse table (font-family: "g_d0_f2" style:normal weight:400 stretch:100 src index:0) source: (invalid URI)
downloadable font: rejected by sanitizer (font-family: "g_d0_f2" style:normal weight:400 stretch:100 src index:0) source: (invalid URI)
downloadable font: font load failed (font-family: "g_d0_f2" style:normal weight:400 stretch:100 src index:0) source: (invalid URI)
Warning: Failed to load font 'g_d0_f2': 'SyntaxError: An invalid or illegal string was specified'. pdf.js:537:13
downloadable font: maxp: Bad maxZones: 0 (font-family: "g_d0_f3" style:normal weight:400 stretch:100 src index:0) source: (invalid URI)

For now I use version 1.5.1 for my project, but I hope you understand the problem. My knowledge of PDF and TTF is not deep enough for this problem.

mojavelinux commented 4 years ago

This could be the same issue as is being discussed here: https://github.com/prawnpdf/ttfunk/issues/53#issuecomment-570890100

pointlessone commented 4 years ago

@georf Could you please translate the error message you get in Acrobat to English?

mech commented 4 years ago

Having some issues with certain font hiding a numeric number when rendered. Specifically the figure "8" is hidden when I used a certain font like "Anonymous Pro" for displaying numeric currency. It does not happen in 1.5.1 though. The figure will disappear visually but when using cursor to select the text and re-paste it elsewhere it will appear. Very strange issues.

georf commented 4 years ago

I found the official translation at google:

Cannot extract the embedded font "815ef7+DejaVuSans". Some characters may not display or print correctly.

mech commented 4 years ago

This is essentially what I am getting also. When open in Preview macOS, it appear fine. But when opening in Adobe Acrobat, an error message like that pop out. Does not matter which font. Some works, some don't.

pointlessone commented 4 years ago

Could someone please post a short script reproducing the issue? The one Dan posted doesn't result in an error message in Acrobat for me.

Mazwak commented 4 years ago

Here is a script which does not work

# frozen_string_literal: true

gem 'ttfunk', '= 1.6.1'
require 'ttfunk'
require 'prawn'

Prawn::Document.generate('embedded_font.pdf') do
  font_families.update('LiberationSans' => {
                         normal: '../ressources/LiberationSans-Regular.ttf',
                         bold: '../ressources/LiberationSans-Bold.ttf',
                         italic: '../ressources/LiberationSans-Italic.ttf',
                         bold_italic: '../ressources/LiberationSans-BoldItalic.ttf'
                       })
  font 'LiberationSans'
  font_size 8
  text 'Hello World!'
end

If I force 1.5.1 or 1.6.0, it works.

ruby 2.6.5p114 (2019-10-01 revision 67812) [x64-mingw32]

Mazwak commented 4 years ago

I tried with the string : Hellö Wòrld!

1.5.1 : All good 1.6.0 : No errors, but special chars not showing 1.6.1 : Error, and all chars not showing

Mazwak commented 4 years ago

Forgot to say I test with adobe acrobat reader DC 2019.021.20061

georf commented 4 years ago

Do you can fix it?

pointlessone commented 4 years ago

This issue should be fixed in TTFunk 1.6.2. Please upgrade and report any issues you have. Thank you for patience.

rvfx commented 5 months ago

The problem was reintroduced in TTFunk 1.8.0.