[cairo-commit] test/.gitignore test/Makefile.am test/README test/text-transform.c test/text-transform-pdf-ref.png test/text-transform-ps-ref.png test/text-transform-ref.png
Carl Worth
cworth at kemper.freedesktop.org
Mon Mar 24 16:26:40 PDT 2008
test/.gitignore | 1
test/Makefile.am | 1
test/README | 1
test/text-transform-pdf-ref.png |binary
test/text-transform-ps-ref.png |binary
test/text-transform-ref.png |binary
test/text-transform.c | 113 ++++++++++++++++++++++++++++++++++++++++
7 files changed, 116 insertions(+)
New commits:
commit ee3981fb92ee5fa9b049dae32421cc0015fd4bf6
Author: Carl Worth <cworth at cworth.org>
Date: Mon Mar 24 16:24:36 2008 -0700
Add new text-transform test
Previously, the test suite wasn't supplying any coverage of transformed
text rendering.
diff --git a/test/.gitignore b/test/.gitignore
index 3f7b2af..ab211ee 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -177,6 +177,7 @@ text-cache-crash
text-glyph-range
text-pattern
text-rotate
+text-transform
text-zero-len
transforms
translate-show-surface
diff --git a/test/Makefile.am b/test/Makefile.am
index 675c6b1..069ce1e 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -133,6 +133,7 @@ text-antialias-subpixel$(EXEEXT) \
text-cache-crash$(EXEEXT) \
text-pattern$(EXEEXT) \
text-rotate$(EXEEXT) \
+text-transform$(EXEEXT) \
text-zero-len$(EXEEXT) \
transforms$(EXEEXT) \
translate-show-surface$(EXEEXT) \
diff --git a/test/README b/test/README
index e21ba72..a241d8a 100644
--- a/test/README
+++ b/test/README
@@ -220,6 +220,7 @@ Poppler renders patterned text as black
https://bugs.freedesktop.org/show_bug.cgi?id=14577
--------------------------------------------------
text-pattern
+text-transform
Poppler should paint images with CAIRO_EXTEND_PAD
https://bugs.freedesktop.org/show_bug.cgi?id=14578
diff --git a/test/text-transform-pdf-ref.png b/test/text-transform-pdf-ref.png
new file mode 100644
index 0000000..46076bd
Binary files /dev/null and b/test/text-transform-pdf-ref.png differ
diff --git a/test/text-transform-ps-ref.png b/test/text-transform-ps-ref.png
new file mode 100644
index 0000000..6f33fb6
Binary files /dev/null and b/test/text-transform-ps-ref.png differ
diff --git a/test/text-transform-ref.png b/test/text-transform-ref.png
new file mode 100644
index 0000000..6f36b9d
Binary files /dev/null and b/test/text-transform-ref.png differ
diff --git a/test/text-transform.c b/test/text-transform.c
new file mode 100644
index 0000000..0a886db
--- /dev/null
+++ b/test/text-transform.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright © 2006 Mozilla Corporation
+ *
+ * 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
+ * Mozilla Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Mozilla Corporation makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * MOZILLA CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL MOZILLA CORPORATION 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: Vladimir Vukicevic <vladimir at pobox.com>
+ */
+
+#include "cairo-test.h"
+
+static cairo_test_draw_function_t draw;
+
+#define SIZE 100
+#define PAD 5
+
+#define FONT_SIZE 32.0
+
+const char png_filename[] = "romedalen.png";
+
+cairo_test_t test = {
+ "text-transform",
+ "Test various applications of the font matrix",
+ SIZE, SIZE,
+ draw
+};
+
+void draw_text (cairo_t *cr);
+
+void
+draw_text (cairo_t *cr)
+{
+ cairo_matrix_t tm;
+
+ /* skew */
+ cairo_matrix_init (&tm, 1, 0,
+ -0.25, 1,
+ 0, 0);
+ cairo_matrix_scale (&tm, FONT_SIZE, FONT_SIZE);
+ cairo_set_font_matrix (cr, &tm);
+
+ cairo_new_path (cr);
+ cairo_move_to (cr, 50, SIZE-PAD);
+ cairo_show_text (cr, "A");
+
+ /* rotate and scale */
+ cairo_matrix_init_rotate (&tm, M_PI / 2);
+ cairo_matrix_scale (&tm, FONT_SIZE, FONT_SIZE * 2.0);
+ cairo_set_font_matrix (cr, &tm);
+
+ cairo_new_path (cr);
+ cairo_move_to (cr, PAD, PAD + 25);
+ cairo_show_text (cr, "A");
+
+ cairo_matrix_init_rotate (&tm, M_PI / 2);
+ cairo_matrix_scale (&tm, FONT_SIZE * 2.0, FONT_SIZE);
+ cairo_set_font_matrix (cr, &tm);
+
+ cairo_new_path (cr);
+ cairo_move_to (cr, PAD, PAD + 50);
+ cairo_show_text (cr, "A");
+}
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_pattern_t *pattern;
+
+ pattern = cairo_test_create_pattern_from_png (png_filename);
+ cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
+
+ cairo_set_source_rgb (cr, 1., 1., 1.);
+ cairo_paint (cr);
+
+ cairo_set_source_rgb (cr, 0., 0., 0.);
+
+ cairo_select_font_face (cr, "Bitstream Vera Sans",
+ CAIRO_FONT_SLANT_NORMAL,
+ CAIRO_FONT_WEIGHT_NORMAL);
+
+ draw_text (cr);
+
+ cairo_translate (cr, SIZE, SIZE);
+ cairo_rotate (cr, M_PI);
+
+ cairo_set_source (cr, pattern);
+
+ draw_text (cr);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test);
+}
More information about the cairo-commit
mailing list