ObjectProfile / Roassal3Exporters

PDF Exporter for Roassal3
MIT License
8 stars 3 forks source link

PNG and PDF exporters problem with non-ASCII filenames #29

Closed JanBliznicenko closed 1 year ago

JanBliznicenko commented 1 year ago

PNG and PDF exporters do not handle non-ASCII filenames very well. A user of OpenPonk reported that in his case the export did not happen at all and in my case (Windows 10) the resulting file name is complete garbage. Probably some encoding issue along the way of ffi calls.

SVG export works well.

The issue is in Roassal2 as well, that's why I know it (OpenPonk uses Roassal2).

How to reproduce:

RSCanvas new pngExporter fileName: 'ěščřžýáíéůúňďťĚŠČŘŽÝÁÍÉŮÚŇĎŤ.png'; export.
RSCanvas new pdfExporter fileName: 'ěščřžýáíéůúňďťĚŠČŘŽÝÁÍÉŮÚŇĎŤ.pdf'; export.

obrazek

akevalion commented 1 year ago

Thank you I will review it

akevalion commented 1 year ago

I have tried on macOs(ventura) and I did not found an error. I will try it on windows

JanBliznicenko commented 1 year ago

You are right, it is Windows-only problem. It seems to work on Debian as well.

akevalion commented 1 year ago

Hello I have test it on windows, I yes I got the error, at this moment for png or pdf export Roassal uses AthensCairoPDFSurface for pdf and method writeToPng: probably the error is present on windows because of the encoding of the name

JanBliznicenko commented 1 year ago

The resulting string seems to be equal to when you try to decode UTF-8 encoded string with Windows-1250 decoder (so UTF-8 string is being put somewhere where it expects Windows-1250)

JanBliznicenko commented 1 year ago

According to this: https://bugs.freedesktop.org/show_bug.cgi?id=103536 it seems cairo lib used to expect native encoding for each platform in version 1.14 (and older), but since 1.15.10, it works with UTF-8 on all platforms, incl. Windows: https://cairographics.org/releases/ChangeLog.cairo-1.15.10 (search for "UTF"). Pharo VM for Windows, unfortunately, is shipped with 1.14.12.

akevalion commented 1 year ago

Thank you for this information, Yes I have tried utf8 on windows but the result is the same.

RSPNGExporter >> #exportToFile: file
    | morph |
    morph := self morph.
    self cameraSetter set: [
        | surface |
        surface := AthensCairoSurface extent: morph extent asIntegerPoint.
        surface drawDuring: [ :can | morph fullDrawOnAthensCanvas: can ].
        surface writeToPng: file pathString utf8Encoded.
        surface flush.

        "The following may fail when the VM is run in the headless mode"
        [ surface finish ] on: Error do: [ :ex  | "Do nothing" ]. 
         ]

Maybe this is an issue then for pharo to update the current version of cairo, also @tinchodias, told me that new cairo supports new features.

akevalion commented 1 year ago

We have talk with Pablo Tesone and next week we will update cairo version in pharo11

tinchodias commented 1 year ago

The new VM will probably come with Cairo 1.17.4

akevalion commented 1 year ago

@JanBliznicenko I check it on windows and it is fixed, you can download the new vm and that will include the new version of cairo

JanBliznicenko commented 1 year ago

Thank you, @akevalion Is it the VM marked as stable (that is downloaded by Pharo Launcher) or does it need to be latest?

akevalion commented 1 year ago

In my case remove my last vm and the PharoLauncher downloaded the new vm.

JanBliznicenko commented 1 year ago

Indeed, it works now. And not just in Pharo 11, but also 10 and 9, awesome!