pharo-graphics / RoassalExporters

MIT License
0 stars 3 forks source link

PDFs with text generated on Windows cannot be opened #6

Open JanBliznicenko opened 1 month ago

JanBliznicenko commented 1 month ago

Exporting any canvas containing any label to PDF in Windows causes the PDF to be invalid.

As a result, most of PDF tools cannot open the file. Adobe Reader shows error 135.

Output from an online validation tool:

The "endobj" keyword is missing. The key FirstChar is required but missing. The key LastChar is required but missing. The key Widths is required but missing. The key FontDescriptor is required but missing. The document does not conform to the requested standard. The file format (header, trailer, objects, xref, streams) is corrupted. The document doesn't conform to the PDF reference (missing required entries, wrong value types, etc.). The document does not conform to the PDF 1.5 standard.

The issue is not present on Linux.

Sample code:

c := RSCanvas new.

c add: (RSLabel new text: 'A'; yourself).

c exportToPDF

Tested with latest release and latest master of both Roassal and RoassalExporters, with Pharo 11 and 13 on Windows 11 (and on Debian 12 where it works).

Ducasse commented 1 month ago

Thanks Jan. This is strange because roassal uses the cairo back-end for this. I tried in Mac and it works. 3905409273136084.pdf

JanBliznicenko commented 1 month ago

Thanks Jan. This is strange because roassal uses the cairo back-end for this. I tried in Mac and it works. 3905409273136084.pdf

This is actually not the only problem I am having on specific platforms with Roassal/Cairo. On Linux, italic and bold emphasis for RSLabel does not work: https://github.com/pharo-graphics/Roassal/issues/71

tinchodias commented 1 month ago

Hello. It is possible to try a more recent version of cairo. A procedure to do it is described for Alexandire in this document.

JanBliznicenko commented 1 month ago

Hello. It is possible to try a more recent version of cairo. A procedure to do it is described for Alexandire in this document.

Hello, thank you, problem is indeed in the specific version of Cairo/FreeType used by Pharo, updating the libs fixes both issues (this and https://github.com/pharo-graphics/Roassal/issues/71).

On Ubuntu 24, it updates to: Cairo 1.18.0 FreeType 2.13.2 HarfBuzz 8.3.0

On Windows, libs from https://github.com/harfbuzz/harfbuzz/releases did not work for me, so I used ones from Inkscape 1.4rc1: Cairo 1.18.0 FreeType 2.13.2 Harfbuzz 9.0.0

and both issues got fixed by it (well, one test fails now, but it still would be worth pursuing).

Original versions (with those issues) are: Cairo 1.17.4 FreeType 2.12.1 HarfBuzz 5.3.1

EDIT: found the issue in Cairo's GitLab: https://gitlab.freedesktop.org/cairo/cairo/-/issues/449 It was fixed in 1.18.0.

tinchodias commented 1 month ago

Oh, I see Harfbuzz has now 10.0.1. The expert in updating the vm's libs is @tesonep, it's not easy task at all!

JanBliznicenko commented 3 weeks ago

Oh, I see Harfbuzz has now 10.0.1. The expert in updating the vm's libs is @tesonep, it's not easy task at all!

Sure, I can image it can cause more problems than it solves. For example, in version 1.18.0 do not work italics on Mac (in our 1.17.4 it is on Linux) and in 1.18.2 PDF export does not work on any platform... (https://gitlab.freedesktop.org/cairo/cairo/-/issues/870)