After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 681895 - PDF export does not save fonts properly
PDF export does not save fonts properly
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Plugins
git master
Other All
: Normal normal
: 2.8
Assigned To: GIMP Bugs
GIMP Bugs
: 708207 739186 744715 764499 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2012-08-15 07:54 UTC by Priit Laes (IRC: plaes)
Modified: 2017-10-31 23:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
original-xcf.png (98.42 KB, image/png)
2012-08-15 07:55 UTC, Priit Laes (IRC: plaes)
  Details
pdf-export.png (47.25 KB, image/png)
2012-08-15 07:57 UTC, Priit Laes (IRC: plaes)
  Details
quick hack (866 bytes, patch)
2015-01-09 12:35 UTC, Massimo
none Details | Review
quick hack (1.31 KB, patch)
2015-01-09 14:37 UTC, Massimo
none Details | Review
proposed patch (870 bytes, patch)
2015-01-13 15:08 UTC, Massimo
none Details | Review
proposed patch (2.25 KB, patch)
2015-01-28 11:42 UTC, Massimo
none Details | Review

Description Priit Laes (IRC: plaes) 2012-08-15 07:54:24 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+)
Comment 1 Priit Laes (IRC: plaes) 2012-08-15 07:55:06 UTC
Created attachment 221234 [details]
original-xcf.png

Fragment of an original file, in gimp and saved as xcf.
Comment 2 Priit Laes (IRC: plaes) 2012-08-15 07:57:50 UTC
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".
Comment 3 Priit Laes (IRC: plaes) 2012-08-15 07:58:48 UTC
These issues are also present in 2.8.0 so this apparently isn't regression between 2.8.0 and master.
Comment 4 Priit Laes (IRC: plaes) 2012-08-15 08:51:04 UTC
Noticed also one extra issue: when opening .xcf that contains font that's missing from your system, it's not properly exported to PDF.
Comment 5 Michael Schumacher 2014-12-26 00:37:45 UTC
*** Bug 708207 has been marked as a duplicate of this bug. ***
Comment 6 Michael Natterer 2015-01-08 22:52:23 UTC
*** Bug 739186 has been marked as a duplicate of this bug. ***
Comment 7 Massimo 2015-01-09 12:35:21 UTC
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
Comment 8 Massimo 2015-01-09 14:37:58 UTC
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.
Comment 9 Michael Natterer 2015-01-10 19:05:47 UTC
If this fixes the font sizes, please push.
Comment 10 Massimo 2015-01-13 15:08:48 UTC
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 ...
Comment 11 Massimo 2015-01-28 11:42:11 UTC
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.
Comment 12 Massimo 2015-01-28 19:13:16 UTC
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
Comment 13 Michael Schumacher 2016-10-09 17:56:13 UTC
*** Bug 764499 has been marked as a duplicate of this bug. ***
Comment 14 Michael Schumacher 2017-10-31 23:37:34 UTC
*** Bug 744715 has been marked as a duplicate of this bug. ***