summaryrefslogtreecommitdiff
path: root/gfx
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-23 19:43:31 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-23 19:43:31 -0300
commit715d3642b9cec177dc8c18a468417e6ea1b700e2 (patch)
tree097885a4c729665238086f81f3a386172c1e4195 /gfx
parentff75c07423e278ae0e2c6effe4bde1a4fc19965f (diff)
downloadeeshow-715d3642b9cec177dc8c18a468417e6ea1b700e2.tar.gz
eeshow-715d3642b9cec177dc8c18a468417e6ea1b700e2.tar.bz2
eeshow-715d3642b9cec177dc8c18a468417e6ea1b700e2.zip
gfx/cro.c: go back to integers, but scale PDF coordinates by 16
Floating-point produced small pixel variations that confused diff mode. We fix the PDF rounding problem by scaling the coordinate system by 16.
Diffstat (limited to 'gfx')
-rw-r--r--gfx/cro.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/gfx/cro.c b/gfx/cro.c
index 903126d..54b08a3 100644
--- a/gfx/cro.c
+++ b/gfx/cro.c
@@ -75,13 +75,13 @@ static inline double dc(const struct cro_ctx *cc, double x)
}
-static inline double cx(const struct cro_ctx *cc, int x)
+static inline int cx(const struct cro_ctx *cc, int x)
{
return cc->xo + x * cc->scale;
}
-static inline double cy(const struct cro_ctx *cc, int y)
+static inline int cy(const struct cro_ctx *cc, int y)
{
return cc->yo + y * cc->scale;
}
@@ -381,6 +381,8 @@ static void *cr_pdf_init(int argc, char *const *argv)
cc = init_common(argc, argv);
+ cc->scale *= 16;
+
/* cr_text_width needs *something* to work with */
cc->s = cairo_pdf_surface_create(NULL, 16, 16);
@@ -421,6 +423,9 @@ static void cr_pdf_end(void *ctx)
end_common(cc, &w, &h, NULL, NULL);
+ w = (w + 15) >> 4;
+ h = (h + 15) >> 4;
+
if (cc->toc)
cc->s = cairo_pdf_surface_create_for_stream(stream_to_pdftoc,
cc, w, h);
@@ -431,6 +436,7 @@ static void cr_pdf_end(void *ctx)
NULL, w, h);
cc->cr = cairo_create(cc->s);
+ cairo_scale(cc->cr, 1.0 / 16.0, 1.0 / 16);
cairo_select_font_face(cc->cr, "Helvetica", CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_BOLD);
cairo_set_line_width(cc->cr, 0.5 * cc->scale);