diff options
author | Thomas White <taw@bitwiz.org.uk> | 2016-05-04 12:05:02 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2016-05-04 12:05:02 +0200 |
commit | 117237228b9c9171e184254fb0a4604c9f58673b (patch) | |
tree | 17a1cc6d170ff7dbb3ef6503a49040991ff0cef9 /src/render.c | |
parent | dbd5d93daad41fffd7a81bbe79712024f46f5257 (diff) |
Restore "Export PDF" and add initial printing stuff
Diffstat (limited to 'src/render.c')
-rw-r--r-- | src/render.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/render.c b/src/render.c index 8699ed8..a8ff7ea 100644 --- a/src/render.c +++ b/src/render.c @@ -226,7 +226,7 @@ struct frame *interp_and_shape(SCBlock *scblocks, SCBlock **stylesheets, } -static struct frame *render_sc_to_surface(SCBlock *scblocks, cairo_surface_t *surf, +static struct frame *render_sc_with_context(SCBlock *scblocks, cairo_t *cr, double log_w, double log_h, SCBlock **stylesheets, SCCallbackList *cbl, ImageStore *is, enum is_size isz, @@ -266,7 +266,7 @@ cairo_surface_t *render_sc(SCBlock *scblocks, int w, int h, cr = cairo_create(surf); pc = pango_cairo_create_context(cr); cairo_scale(cr, w/log_w, h/log_h); - top = render_sc_to_surface(scblocks, surf, cr, log_w, log_h, + top = render_sc_with_context(scblocks, cr, log_w, log_h, stylesheets, cbl, is, isz,slide_number, lang, pc); g_object_unref(pc); @@ -278,6 +278,14 @@ cairo_surface_t *render_sc(SCBlock *scblocks, int w, int h, } +static int safe_strcmp(const char *a, const char *b) +{ + if ( a == NULL ) return 1; + if ( b == NULL ) return 1; + return strcmp(a, b); +} + + int export_pdf(struct presentation *p, const char *filename) { double r; @@ -302,9 +310,10 @@ int export_pdf(struct presentation *p, const char *filename) pc = pango_cairo_create_context(cr); i = 1; + bl = p->scblocks; while ( bl != NULL ) { - if ( strcmp(sc_block_name(bl), "slide") != 0 ) { + if ( safe_strcmp(sc_block_name(bl), "slide") != 0 ) { bl = sc_block_next(bl); continue; } @@ -322,7 +331,7 @@ int export_pdf(struct presentation *p, const char *filename) cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); cairo_fill(cr); - render_sc_to_surface(sc_block_child(bl), surf, cr, p->slide_width, + render_sc_with_context(sc_block_child(bl), cr, p->slide_width, p->slide_height, stylesheets, NULL, p->is, ISZ_SLIDESHOW, i, p->lang, pc); |