From: Ben Pfaff Date: Tue, 24 Jun 2014 05:22:25 +0000 (-0700) Subject: cairo: Use same scale factor as Pango, for precision and speed. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp;a=commitdiff_plain;h=5f9212b9af772575bd3026ca9643684ce6493b3c 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. --- 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