aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2017-11-26 14:58:30 +0100
committerThomas White <taw@physics.org>2017-11-26 14:58:30 +0100
commitafa0a93f42bb7f1a4b66ae8ee48ca72e5afc48c0 (patch)
tree2b8396db1ed22dc92b1cbeef0c7d2eb9f1c9eda7
parentb8e76f3ff822d68f3189006ade57b92cca8e0298 (diff)
Render callbacks with higher resolution when writing to PDF
-rw-r--r--src/frame.c13
-rw-r--r--src/print.c1
2 files changed, 12 insertions, 2 deletions
diff --git a/src/frame.c b/src/frame.c
index 23e45ee..56c0bcf 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -591,6 +591,7 @@ static void render_from_surf(cairo_surface_t *surf, cairo_t *cr,
sw = cairo_image_surface_get_width(surf);
sh = cairo_image_surface_get_height(surf);
+ cairo_save(cr);
cairo_scale(cr, w/sw, h/sh);
cairo_new_path(cr);
cairo_rectangle(cr, x, y, sw, sh);
@@ -599,6 +600,7 @@ static void render_from_surf(cairo_surface_t *surf, cairo_t *cr,
cairo_pattern_set_extend(patt, CAIRO_EXTEND_PAD);
cairo_pattern_set_filter(patt, CAIRO_FILTER_BEST);
cairo_fill(cr);
+ cairo_restore(cr);
if ( border ) {
cairo_new_path(cr);
@@ -613,10 +615,13 @@ static void render_from_surf(cairo_surface_t *surf, cairo_t *cr,
void render_paragraph(cairo_t *cr, Paragraph *para, ImageStore *is)
{
cairo_surface_t *surf;
+ cairo_surface_type_t type;
double w, h;
cairo_translate(cr, para->space[0], para->space[2]);
+ type = cairo_surface_get_type(cairo_get_target(cr));
+
switch ( para->type ) {
case PARA_TYPE_TEXT :
@@ -635,7 +640,13 @@ void render_paragraph(cairo_t *cr, Paragraph *para, ImageStore *is)
break;
case PARA_TYPE_CALLBACK :
- surf = para->draw_func(para->cb_w, para->cb_h,
+ w = para->cb_w;
+ h = para->cb_h;
+ cairo_user_to_device_distance(cr, &w, &h);
+ if ( type == CAIRO_SURFACE_TYPE_PDF ) {
+ w *= 6; h *= 6;
+ }
+ surf = para->draw_func(w, h,
para->bvp, para->vp);
render_from_surf(surf, cr, para->cb_w, para->cb_h, 1);
cairo_surface_destroy(surf); /* FIXME: Cache like crazy */
diff --git a/src/print.c b/src/print.c
index 2a3ca68..e33bc39 100644
--- a/src/print.c
+++ b/src/print.c
@@ -232,7 +232,6 @@ static void print_narrative(GtkPrintOperation *op, GtkPrintContext *ctx,
int i;
double h, page_height;
cairo_t *cr;
- printf("printing page %i\n", page);
page_height = gtk_print_context_get_height(ctx);
cr = gtk_print_context_get_cairo_context(ctx);