From 5f9212b9af772575bd3026ca9643684ce6493b3c Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 23 Jun 2014 22:22:25 -0700 Subject: [PATCH] cairo: Use same scale factor as Pango, for precision and speed. By setting XR_POINT to PANGO_SCALE (1024), we can avoid the need for expensive conversions that lose accuracy. --- src/output/cairo.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/output/cairo.c b/src/output/cairo.c index 19a3678cc1..e29e6583c5 100644 --- a/src/output/cairo.c +++ b/src/output/cairo.c @@ -65,8 +65,8 @@ #define H TABLE_HORZ #define V TABLE_VERT -/* Measurements as we present to the rest of PSPP. */ -#define XR_POINT 1000 +/* The unit used for internal measurements is inch/(72 * XR_POINT). */ +#define XR_POINT PANGO_SCALE /* Conversions to and from points. */ static double @@ -315,13 +315,17 @@ xr_allocate (const char *name, int device_type, struct string_map *o) static int pango_to_xr (int pango) { - return ceil (pango * (1. * XR_POINT / PANGO_SCALE)); + return (XR_POINT != PANGO_SCALE + ? ceil (pango * (1. * XR_POINT / PANGO_SCALE)) + : pango); } static int xr_to_pango (int xr) { - return ceil (xr * (1. / XR_POINT * PANGO_SCALE)); + return (XR_POINT != PANGO_SCALE + ? ceil (xr * (1. / XR_POINT * PANGO_SCALE)) + : xr); } static bool -- 2.30.2