From b2c9bd0324003ad3e2b7d33c179049b2c0b0ebb2 Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Fri, 9 Dec 2011 23:52:00 +1030 Subject: [PATCH] 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 and the end the the EPS. Bug 43634 --- src/cairo-ps-surface.c | 10 +++------- 1 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c index f206adc..9dfd9d0 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, -- 1.7.5.4