diff options
author | Thomas White <taw@physics.org> | 2018-01-25 22:55:30 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2018-01-25 22:55:30 +0100 |
commit | c94b682595a495e29c0c7b2d264745aa91c13599 (patch) | |
tree | b5ffb9cc812354be16c6e8b90df275729377a3f4 /src | |
parent | b65b9df823e597187db25fc52ec70ab3d1acb280 (diff) |
Fix slide size in slide only print
Diffstat (limited to 'src')
-rw-r--r-- | src/print.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/print.c b/src/print.c index 8ae0a7a..acc44dd 100644 --- a/src/print.c +++ b/src/print.c @@ -107,6 +107,9 @@ static void print_slide_only(GtkPrintOperation *op, GtkPrintContext *ctx, double w, h; SCBlock *stylesheets[2]; struct frame *top; + const double sw = ps->p->slide_width; + const double sh = ps->p->slide_height; + double slide_width, slide_height; cr = gtk_print_context_get_cairo_context(ctx); pc = gtk_print_context_create_pango_context(ctx); @@ -120,14 +123,25 @@ static void print_slide_only(GtkPrintOperation *op, GtkPrintContext *ctx, cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); cairo_fill(cr); + if ( sw/sh > w/h ) { + /* Slide is too wide. Letterboxing top/bottom */ + slide_width = w; + slide_height = w * sh/sw; + } else { + /* Letterboxing at sides */ + slide_width = h * sw/sh; + slide_height = h; + } + + printf("%f x %f ---> %f x %f\n", w, h, slide_width, slide_height); + top = interp_and_shape(sc_block_child(ps->slide), stylesheets, NULL, - ps->p->is, - page+1, pc, - ps->p->slide_width, ps->p->slide_height, - ps->p->lang); + ps->p->is, page+1, pc, sw, sh, ps->p->lang); recursive_wrap(top, pc); + cairo_scale(cr, slide_width/sw, slide_width/sw); + recursive_draw(top, cr, ps->p->is, 0.0, ps->p->slide_height); |