[cairo-commit] 3 commits - ROADMAP test/.gitignore test/Makefile.am
test/pdf2svg.c test/pdf-features.c
Carl Worth
cworth at kemper.freedesktop.org
Wed May 3 13:23:45 PDT 2006
ROADMAP | 14 ++--
test/.gitignore | 1
test/Makefile.am | 5 +
test/pdf-features.c | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++
test/pdf2svg.c | 101 +++++++++++++++++++++++++++++++++++
5 files changed, 265 insertions(+), 6 deletions(-)
New commits:
diff-tree 8a174a11395af97bf1bffeca7a6ee8e5c1d50281 (from 7c825797c85fca79ea1229d49cf3ae1b24b6daf2)
Author: Carl Worth <cworth at cworth.org>
Date: Wed May 3 13:20:07 2006 -0700
Add test/pdf-features.c missing from an earlier commit
diff --git a/test/pdf-features.c b/test/pdf-features.c
new file mode 100644
index 0000000..aad4456
--- /dev/null
+++ b/test/pdf-features.c
@@ -0,0 +1,150 @@
+/*
+ * Copyright © 2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#include <stdio.h>
+#include <cairo.h>
+#include <cairo-pdf.h>
+#if HAVE_FCFINI
+#include <fontconfig/fontconfig.h>
+#endif
+
+#include "cairo-test.h"
+
+/* This test exists to test the various features of cairo-pdf.h.
+ *
+ * Currently, this test exercises the following function calls:
+ *
+ * cairo_pdf_surface_set_size
+ */
+
+#define INCHES_TO_POINTS(in) ((in) * 72.0)
+#define MM_TO_POINTS(mm) ((mm) / 25.4 * 72.0)
+#define TEXT_SIZE 12
+
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))
+
+struct {
+ const char *page_size;
+ const char *page_size_alias;
+ const char *orientation;
+ double width_in_points;
+ double height_in_points;
+} pages[] = {
+ {"na_letter_8.5x11in", "letter", "portrait",
+ INCHES_TO_POINTS(8.5), INCHES_TO_POINTS(11)},
+ {"na_letter_8.5x11in", "letter", "landscape",
+ INCHES_TO_POINTS(11), INCHES_TO_POINTS(8.5)},
+ {"iso_a4_210x297mm", "a4", "portrait",
+ MM_TO_POINTS(210), MM_TO_POINTS(297)},
+ {"iso_a4_210x297mm", "a4", "landscape",
+ MM_TO_POINTS(297), MM_TO_POINTS(210)},
+ {"iso_a5_148x210mm", "a5", "portrait",
+ MM_TO_POINTS(148), MM_TO_POINTS(210)},
+ {"iso_a5_148x210mm", "a5", "landscape",
+ MM_TO_POINTS(210), MM_TO_POINTS(148)},
+ {"iso_a6_105x148mm", "a6", "portrait",
+ MM_TO_POINTS(105), MM_TO_POINTS(148)},
+ {"iso_a6_105x148mm", "a6", "landscape",
+ MM_TO_POINTS(148), MM_TO_POINTS(105)},
+ {"iso_a7_74x105mm", "a7", "portrait",
+ MM_TO_POINTS(74), MM_TO_POINTS(105)},
+ {"iso_a7_74x105mm", "a7", "landscape",
+ MM_TO_POINTS(105), MM_TO_POINTS(74)},
+ {"iso_a8_52x74mm", "a8", "portrait",
+ MM_TO_POINTS(52), MM_TO_POINTS(74)},
+ {"iso_a8_52x74mm", "a8", "landscape",
+ MM_TO_POINTS(74), MM_TO_POINTS(52)},
+ {"iso_a9_37x52mm", "a9", "portrait",
+ MM_TO_POINTS(37), MM_TO_POINTS(52)},
+ {"iso_a9_37x52mm", "a9", "landscape",
+ MM_TO_POINTS(52), MM_TO_POINTS(37)},
+ {"iso_a10_26x37mm", "a10", "portrait",
+ MM_TO_POINTS(26), MM_TO_POINTS(37)},
+ {"iso_a10_26x37mm", "a10", "landscape",
+ MM_TO_POINTS(37), MM_TO_POINTS(26)}
+};
+
+int
+main (void)
+{
+ cairo_surface_t *surface;
+ cairo_t *cr;
+ cairo_status_t status;
+ char *filename;
+ int i;
+
+ printf("\n");
+
+ filename = "pdf-features.pdf";
+
+ /* The initial size passes here is the default size that will be
+ * inheritable by each page. That is, any page for which this
+ * initial size applies will not have its owne /MediaBox entry in
+ * its dictionary. */
+ surface = cairo_pdf_surface_create (filename,
+ INCHES_TO_POINTS(8.5),
+ INCHES_TO_POINTS(11));
+
+ cr = cairo_create (surface);
+
+ cairo_select_font_face (cr, "Bitstream Vera Sans",
+ CAIRO_FONT_SLANT_NORMAL,
+ CAIRO_FONT_WEIGHT_NORMAL);
+ cairo_set_font_size (cr, TEXT_SIZE);
+
+ for (i=0; i < ARRAY_SIZE(pages); i++)
+ {
+ cairo_pdf_surface_set_size (surface,
+ pages[i].width_in_points,
+ pages[i].height_in_points);
+
+ cairo_move_to (cr, TEXT_SIZE, TEXT_SIZE);
+ cairo_show_text (cr, pages[i].page_size);
+ cairo_show_text (cr, " - ");
+ cairo_show_text (cr, pages[i].orientation);
+ cairo_show_page (cr);
+ }
+
+ status = cairo_status (cr);
+
+ cairo_destroy (cr);
+ cairo_surface_destroy (surface);
+
+ if (status) {
+ cairo_test_log ("Failed to create pdf surface for file %s: %s\n",
+ filename, cairo_status_to_string (status));
+ return CAIRO_TEST_FAILURE;
+ }
+
+ printf ("pdf-features: Please check %s to ensure it looks/prints correctly.\n", filename);
+
+ cairo_debug_reset_static_data ();
+
+#if HAVE_FCFINI
+ FcFini ();
+#endif
+
+ return CAIRO_TEST_SUCCESS;
+}
diff-tree 7c825797c85fca79ea1229d49cf3ae1b24b6daf2 (from 6f9aa014aeee03bd6acc31124de05cfd931a88e1)
Author: Carl Worth <cworth at cworth.org>
Date: Wed May 3 13:18:40 2006 -0700
Add pdf2svg utility for manual testing (not used in test suite)
diff --git a/test/.gitignore b/test/.gitignore
index eb16e4f..3f3c582 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -52,6 +52,7 @@ paint-with-alpha
path-data
pattern-get-type
pdf2png
+pdf2svg
pdf-features
pdf-features.pdf
png-flatten
diff --git a/test/Makefile.am b/test/Makefile.am
index 4c17064..1a4a15c 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -325,6 +325,11 @@ if CAIRO_CAN_TEST_SVG_SURFACE
noinst_PROGRAMS += svg2png
svg2png_CFLAGS = $(LIBRSVG_CFLAGS)
svg2png_LDADD = $(LIBRSVG_LIBS)
+if CAIRO_CAN_TEST_PDF_SURFACE
+noinst_PROGRAMS += pdf2svg
+pdf2svg_CFLAGS = $(POPPLER_CFLAGS)
+pdf2svg_LDADD = $(LDADD) $(POPPLER_LIBS)
+endif
endif
CLEANFILES = \
diff --git a/test/pdf2svg.c b/test/pdf2svg.c
new file mode 100644
index 0000000..7aa057e
--- /dev/null
+++ b/test/pdf2svg.c
@@ -0,0 +1,101 @@
+/*
+ * Copyright © 2005 Red Hat, Inc.
+ * Copyright © 2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authors: Kristian Høgsberg <krh at redhat.com>
+ * Carl Worth <cworth at redhat.com>
+ */
+
+#include <stdlib.h>
+#include <poppler.h>
+
+#include <cairo-svg.h>
+
+#define FAIL(msg) \
+ do { fprintf (stderr, "FAIL: %s\n", msg); exit (-1); } while (0)
+
+#define PIXELS_PER_POINT 1
+
+int main (int argc, char *argv[])
+{
+ PopplerDocument *document;
+ PopplerPage *page;
+ double width, height;
+ GError *error;
+ const char *filename = argv[1];
+ const char *output_filename = argv[2];
+ const char *page_label = argv[3];
+ gchar *absolute, *uri;
+ cairo_surface_t *surface;
+ cairo_t *cr;
+ cairo_status_t status;
+
+ if (argc != 4)
+ FAIL ("usage: pdf2svg input_file.pdf output_file.svg page");
+
+ g_type_init ();
+
+ error = NULL;
+
+ if (g_path_is_absolute(filename)) {
+ absolute = g_strdup (filename);
+ } else {
+ gchar *dir = g_get_current_dir ();
+ absolute = g_build_filename (dir, filename, (gchar *) 0);
+ free (dir);
+ }
+
+ uri = g_filename_to_uri (absolute, NULL, &error);
+ free (absolute);
+ if (uri == NULL)
+ FAIL (error->message);
+
+ document = poppler_document_new_from_file (uri, NULL, &error);
+ if (document == NULL)
+ FAIL (error->message);
+
+ page = poppler_document_get_page_by_label (document, page_label);
+ if (page == NULL)
+ FAIL ("page not found");
+
+ poppler_page_get_size (page, &width, &height);
+
+ surface = cairo_svg_surface_create (output_filename, width, height);
+ cr = cairo_create (surface);
+
+ /* Clear background */
+ cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */
+ cairo_paint (cr);
+
+ poppler_page_render (page, cr);
+
+ cairo_show_page (cr);
+
+ status = cairo_status (cr);
+ if (status)
+ FAIL (cairo_status_to_string (status));
+
+ cairo_destroy (cr);
+ cairo_surface_destroy (surface);
+
+ return 0;
+}
diff-tree 6f9aa014aeee03bd6acc31124de05cfd931a88e1 (from c35bfffa1057cfe2aeca6fe681ea59aa628f5315)
Author: Carl Worth <cworth at cworth.org>
Date: Wed May 3 13:13:10 2006 -0700
ROADMAP: Note that PDF per-page size setting is done. Sort things that appear in 1.1.4
diff --git a/ROADMAP b/ROADMAP
index 59df210..cff0490 100644
--- a/ROADMAP
+++ b/ROADMAP
@@ -67,12 +67,8 @@ We don't expect to release without these
âc. Translucent objects (using OVER) are also native
d. Text output uses PDF font features
-âPrinting-oriented API (PostScript)
- â1. Per-page settings (paper size, layout, anything else?)
- â2. Document metadata
-
- Printing-oriented API (PDF)
- 1. Per-page size settings
+âPrinting-oriented API (PDF)
+ â1. Per-page size settings
Mozilla needs
1. Device-offset rework
@@ -97,6 +93,12 @@ We don't expect to release without these
âa. Better software gradients
b. Use X server gradients when available
+ cairo 1.1.4 snapshot includes everything below here (and cairo 1.1.2 some of these)
+ -----------------------------------------------------------------------------------
+âPrinting-oriented API (PostScript)
+ â1. Per-page settings (paper size, layout, anything else?)
+ â2. Document metadata
+
âPS backend
â1. Mark PS backend as supported:
âa. Incorporate into test suite
More information about the cairo-commit
mailing list