[PATCH] [test/text-path] Check equivalence of text_path(); fill() and show_text().
Chris Wilson
chris at chris-wilson.co.uk
Thu Sep 27 07:50:14 PDT 2007
If indeed
cairo_show_text (cr, "cairo");
and
cairo_text_path (cr, "cairo");
cairo_fill (cr);
generate identical output, then one should be able to use the text_path()
to completely clear the show_text() and vice versa.
---
test/Makefile.am | 2 +
test/text-path-ref.png | Bin 0 -> 133 bytes
test/text-path.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 82 insertions(+), 0 deletions(-)
create mode 100644 test/text-path-ref.png
create mode 100644 test/text-path.c
diff --git a/test/Makefile.am b/test/Makefile.am
index e08f61c..ce5931c 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -106,6 +106,7 @@ text-antialias-gray \
text-antialias-none \
text-antialias-subpixel \
text-cache-crash \
+text-path \
text-pattern \
text-rotate \
text-zero-len \
@@ -401,6 +402,7 @@ REFERENCE_IMAGES = \
text-antialias-subpixel-ref.png \
text-glyph-range-ref.png \
text-glyph-range-rgb24-ref.png \
+ text-path-ref.png \
text-pattern-ref.png \
text-pattern-rgb24-ref.png \
text-pattern-svg-argb32-ref.png \
diff --git a/test/text-path-ref.png b/test/text-path-ref.png
new file mode 100644
index 0000000000000000000000000000000000000000..0a2939d2f1409ed04f8498c0499b6b2308969d8f
GIT binary patch
literal 133
zc%17D at N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=Y)RhkE)4%caKYZ?lYt`aC7!;n
z?AJM^`II&HCw;pQ6jJweaSW-L^Y$PkFOYX=!FT^$KJx_(sGy;o*};K<vH#P_KoHl{
L)z4*}Q$iB}UQr=q
literal 0
Hc$@<O00001
diff --git a/test/text-path.c b/test/text-path.c
new file mode 100644
index 0000000..8691a70
--- /dev/null
+++ b/test/text-path.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright © 2007 Chris Wilson
+ *
+ * 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
+ * Chris Wilson not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Chris Wilson makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * CHRIS WILSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL CHRIS WILSON 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: Chris Wilson <chris at chris-wilson.co.uk>
+ */
+
+#include "cairo-test.h"
+
+#define IMAGE_WIDTH 64
+#define IMAGE_HEIGHT 64
+
+static cairo_test_draw_function_t draw;
+
+cairo_test_t test = {
+ "text-path",
+ "Text path\n"
+ "Comparing cairo_text_path(); cairo_fill(); with cairo_show_text()",
+ IMAGE_WIDTH, IMAGE_HEIGHT,
+ draw
+};
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+ cairo_scale (cr, width, height);
+ cairo_set_source_rgb (cr, 0., 0., 1.);
+
+ cairo_select_font_face (cr,
+ "Bitstream Vera Sans",
+ CAIRO_FONT_SLANT_NORMAL,
+ CAIRO_FONT_WEIGHT_NORMAL);
+ cairo_set_font_size (cr, 0.4);
+
+ /* check that the text_path() overlays show_text() */
+ cairo_save (cr);
+ cairo_move_to (cr, 0.05, 0.4);
+ cairo_show_text (cr, "cairo");
+ cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
+ cairo_move_to (cr, 0.05, 0.4);
+ cairo_text_path (cr, "cairo");
+ cairo_fill (cr);
+ cairo_restore (cr);
+
+ /* and that the show_text() overlays the text_path() */
+ cairo_save (cr);
+ cairo_move_to (cr, 0.05, 0.9);
+ cairo_text_path (cr, "cairo");
+ cairo_fill (cr);
+ cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
+ cairo_move_to (cr, 0.05, 0.4);
+ cairo_show_text (cr, "cairo");
+ cairo_restore (cr);
+
+ return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+ return cairo_test (&test);
+}
--
1.5.2.5
--K1SnTjlYS/YgcDEx--
More information about the cairo
mailing list