[gimp] plug-ins: fix comment explaining cairo_save().



commit e2d1a57ebdc0716b30d88279a671618ae7262681
Author: Jehan <jehan girinstud io>
Date:   Mon Jun 19 23:46:46 2017 +0200

    plug-ins: fix comment explaining cairo_save().
    
    Current comment was implying that PDF had some kind of fixed PPI, or
    that a 72 PPI was hardcoded in cairo. This is not at all what this is
    about. Cairo simply has a concept of user-space coordinates, and from
    what I gather, it seems that this is set as "point", the typographical
    unit of measure (not as a screen point). In such context, cairo_scale()
    is used to update the transformation matrix (which will transform from
    user to device units, i.e. pixels) so that we can draw with pixels. In
    other words, both the user and device units will be pixels in subsequent
    calls.
    It turns out that 1 inch == 72 points. This is not a PPI/DPI at all and
    the comment was completely misleading.

 plug-ins/common/file-pdf-save.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/plug-ins/common/file-pdf-save.c b/plug-ins/common/file-pdf-save.c
index 3c22113..2fb77aa 100644
--- a/plug-ins/common/file-pdf-save.c
+++ b/plug-ins/common/file-pdf-save.c
@@ -542,8 +542,12 @@ run (const gchar      *name,
        */
       cairo_surface_set_fallback_resolution (pdf_file, x_res, y_res);
 
-      /* PDF is usually 72 points per inch. If we have a different resolution,
-       * we will need this to fit our drawings
+      /* Cairo has a concept of user-space vs device-space units.
+       * From what I understand, by default the user-space unit is the
+       * typographical "point". Since we work mostly with pixels, not
+       * points, the following call simply scales the transformation
+       * matrix from points to pixels, relatively to the image
+       * resolution, knowing that 1 typographical point == 1/72 inch.
        */
       cairo_scale (cr, x_scale, y_scale);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]