From c7ea92907a7eaaf62136755d0b6c60da913d1057 Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Fri, 9 Dec 2011 23:52:00 +1030 Subject: ps: simplify the EPS save and restore userdict is not permitted in EPS files. Since the PS surface does not leave extra operators or dictionaries on the stack the EPS prolog and trailer can be reduced to: save 50 dict begin .... end restore The save/restore pair is required to remove fonts and restore the graphics state. As "restore" does not restore the dictionary stack, using a new current dictionary for the EPS file allows the cairo dict entries to be cleaned up at the end the EPS. Bug 43634 --- src/cairo-ps-surface.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c index f206adcf..9dfd9d0e 100644 --- a/src/cairo-ps-surface.c +++ b/src/cairo-ps-surface.c @@ -268,10 +268,8 @@ _cairo_ps_surface_emit_header (cairo_ps_surface_t *surface) if (surface->eps) { _cairo_output_stream_printf (surface->final_stream, - "/cairo_eps_state save def\n" - "/dict_count countdictstack def\n" - "/op_count count 1 sub def\n" - "userdict begin\n"); + "save\n" + "50 dict begin\n"); } else { _cairo_output_stream_printf (surface->final_stream, "/languagelevel where\n" @@ -807,9 +805,7 @@ _cairo_ps_surface_emit_footer (cairo_ps_surface_t *surface) if (surface->eps) { _cairo_output_stream_printf (surface->final_stream, - "count op_count sub {pop} repeat\n" - "countdictstack dict_count sub {end} repeat\n" - "cairo_eps_state restore\n"); + "end restore\n"); } _cairo_output_stream_printf (surface->final_stream, -- cgit v1.2.3