GNOME Bugzilla – Bug 681895
PDF export does not save fonts properly
Last modified: 2017-10-31 23:37:34 UTC
I created a poster in GIMP that uses multiple text objects and when exporting it as PDF, font type and size are not set properly. Fonts themselves are present in PDF file. Using gimp master 276b5072855de5e57fb4a83cfdb0e628eee2a473 (2.9+)
Created attachment 221234 [details] original-xcf.png Fragment of an original file, in gimp and saved as xcf.
Created attachment 221235 [details] pdf-export.png Example of an exported PDF file with botched fonts. There's also an artifact encircled with green that apparently occurs when merging multiple layers of images. Background layer has white background, and there's a layer on top with the "bottle image".
These issues are also present in 2.8.0 so this apparently isn't regression between 2.8.0 and master.
Noticed also one extra issue: when opening .xcf that contains font that's missing from your system, it's not properly exported to PDF.
*** Bug 708207 has been marked as a duplicate of this bug. ***
*** Bug 739186 has been marked as a duplicate of this bug. ***
Created attachment 294154 [details] [review] quick hack It seems that when a text layer is saved the context has a transformation matrix that is only valid for the layer position that in GIMP is expressed always in pixels. Font sizes are in PANGO_SCALE * pts and should not be rescaled
Created attachment 294158 [details] [review] quick hack Well, when setting the markup the code uses relative sizes whereas when setting the text it uses absolute sizes. So this patch is a better solution.
If this fixes the font sizes, please push.
Created attachment 294440 [details] [review] proposed patch No the patch above was not correct. Regarding font-sizes the attached patch should add the missing function call. Unfortunately reloading a pdf exported by GIMP still shows differences compared to the original xcf. The most evident is when a text layer uses a 'dynamic' 'box-mode' and GIMP does not force a layout-width, but the plug-in sets it always to the drawable width and this often causes wrapping the text on more lines. Probably there should be a new procedure get_box_mode or get_layout_width/height (returning -1 when it's unset) or ...
Created attachment 295642 [details] [review] proposed patch Better matching the plug-in code to GIMP core results in an acceptable export/import as layer round trip (I tested the xcf attached to bug #739186). GIMP sets the resolution of the PangoFontMap from which the PangoContext is created, sets cairo font options only on the PangoContext, explicitely sets the layout wrap mode and does not force a layout height. There is probably still a difference because GIMP translates and scales (for non square resolution) the cairo context, but I think that the code in GIMP is wrong (it should call pango_cairo_update_layout). If there is no objection, I'll push this patch later.
fixed in master and gimp-2-8: commit cca7f6f8a3ca04dae46adbe9858ad377dde113fd Author: Massimo Valentini <mvalentini@src.gnome.org> Date: Wed Jan 28 19:31:32 2015 +0100 Bug 681895: PDF export does not save fonts properly Set the resolution of the PangoFontMap from which the PangoContext is created, set cairo font options only on the PangoContext, explicitely set wrap mode and do not force a layout height. (cherry picked from commit a215fbda56381db42730d70d809628c86adc3711) Conflicts: plug-ins/common/file-pdf-save.c
*** Bug 764499 has been marked as a duplicate of this bug. ***
*** Bug 744715 has been marked as a duplicate of this bug. ***