[PATCH] Add Encapsulated PostScript API

Adrian Johnson ajohnson at redneon.com
Sat Sep 22 03:51:31 PDT 2007


---
 doc/public/cairo-sections.txt  |    2 +
 src/cairo-ps-surface-private.h |    2 +
 src/cairo-ps-surface.c         |   57 ++++++++++++++++++++++++++++++++++++++++
 src/cairo-ps.h                 |    7 +++++
 4 files changed, 68 insertions(+), 0 deletions(-)

diff --git a/doc/public/cairo-sections.txt b/doc/public/cairo-sections.txt
index 3bf8956..a06692e 100644
--- a/doc/public/cairo-sections.txt
+++ b/doc/public/cairo-sections.txt
@@ -58,6 +58,8 @@ cairo_surface_write_to_png_stream
 <TITLE>PostScript Surfaces</TITLE>
 cairo_ps_surface_create
 cairo_ps_surface_create_for_stream
+cairo_ps_surface_set_eps
+cairo_ps_surface_get_eps
 cairo_ps_surface_set_size
 cairo_ps_surface_dsc_begin_setup
 cairo_ps_surface_dsc_begin_page_setup
diff --git a/src/cairo-ps-surface-private.h b/src/cairo-ps-surface-private.h
index 3a23c21..9da058c 100644
--- a/src/cairo-ps-surface-private.h
+++ b/src/cairo-ps-surface-private.h
@@ -57,6 +57,8 @@ typedef struct cairo_ps_surface {
     FILE *tmpfile;
     cairo_output_stream_t *stream;
 
+    cairo_bool_t eps;
+
     double width;
     double height;
     double max_width;
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 83e5bbb..3e36268 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -957,6 +957,63 @@ _extract_ps_surface (cairo_surface_t	 *surface,
 }
 
 /**
+ * cairo_ps_surface_set_eps:
+ * @surface: a PostScript cairo_surface_t
+ * @eps: TRUE to output EPS format PostScript
+ *
+ * If @eps is TRUE, the PostScript surface will output Encapsulated
+ * PostScript.
+ *
+ * This function should only be called before any drawing operations
+ * have been performed on the current page. The simplest way to do
+ * this is to call this function immediately after creating the
+ * surface. An Encapsulated Postscript file should never contain more
+ * than one page.
+ *
+ * Since: 1.6
+ **/
+void
+cairo_ps_surface_set_eps (cairo_surface_t	*surface,
+			  cairo_bool_t           eps)
+{
+    cairo_ps_surface_t *ps_surface;
+    cairo_status_t status;
+
+    status = _extract_ps_surface (surface, &ps_surface);
+    if (status) {
+	_cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+	return;
+    }
+
+    ps_surface->eps = eps;
+}
+
+/**
+ * cairo_ps_surface_get_eps:
+ * @surface: a PostScript cairo_surface_t
+ *
+ * Check whether the PostScript surface will output Encapsulated PostScript.
+ *
+ * Return value: TRUE if the surface will output Encapsulated PostScript.
+ *
+ * Since: 1.6
+ **/
+cairo_public cairo_bool_t
+cairo_ps_surface_get_eps (cairo_surface_t	*surface)
+{
+    cairo_ps_surface_t *ps_surface;
+    cairo_status_t status;
+
+    status = _extract_ps_surface (surface, &ps_surface);
+    if (status) {
+	_cairo_surface_set_error (surface, CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
+	return FALSE;
+    }
+
+    return ps_surface->eps;
+}
+
+/**
  * cairo_ps_surface_set_size:
  * @surface: a PostScript cairo_surface_t
  * @width_in_points: new surface width, in points (1 point == 1/72.0 inch)
diff --git a/src/cairo-ps.h b/src/cairo-ps.h
index a61d12d..24dd9f6 100644
--- a/src/cairo-ps.h
+++ b/src/cairo-ps.h
@@ -59,6 +59,13 @@ cairo_ps_surface_create_for_stream (cairo_write_func_t	write_func,
 				    double		height_in_points);
 
 cairo_public void
+cairo_ps_surface_set_eps (cairo_surface_t	*surface,
+			  cairo_bool_t           eps);
+
+cairo_public cairo_bool_t
+cairo_ps_surface_get_eps (cairo_surface_t	*surface);
+
+cairo_public void
 cairo_ps_surface_set_size (cairo_surface_t	*surface,
 			   double		 width_in_points,
 			   double		 height_in_points);
-- 
1.5.2.4


--------------030208050802060806080009--


More information about the cairo mailing list