[cairo-commit] test/ft-text-vertical-layout.c test/ft-text-vertical-layout-pdf-argb32-ref.png test/ft-text-vertical-layout-ps-argb32-ref.png test/ft-text-vertical-layout-ref.png test/ft-text-vertical-layout-svg-ref.png test/ft-text-vertical-layout-type1.c test/ft-text-vertical-layout-type1-ref.png test/ft-text-vertical-layout-type1-svg-ref.png test/.gitignore test/Makefile.am

Behdad Esfahbod behdad at kemper.freedesktop.org
Wed Aug 16 11:27:47 PDT 2006


 dev/null                                        |binary
 test/.gitignore                                 |    5 +--
 test/Makefile.am                                |   15 ++++++---
 test/ft-text-vertical-layout-pdf-argb32-ref.png |    0 
 test/ft-text-vertical-layout-ps-argb32-ref.png  |    0 
 test/ft-text-vertical-layout-ref.png            |    0 
 test/ft-text-vertical-layout-svg-ref.png        |    0 
 test/ft-text-vertical-layout-type1-ref.png      |binary
 test/ft-text-vertical-layout-type1-svg-ref.png  |binary
 test/ft-text-vertical-layout-type1.c            |   40 +++++++++++++++++-------
 10 files changed, 42 insertions(+), 18 deletions(-)

New commits:
diff-tree cbcf1ddd646cfe9a9f7b993d2b69ca1faa353f45 (from c385922c198012c46f0c7638ce0ac36a41b9a014)
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Aug 16 14:27:40 2006 -0400

    [test] New torture tests ft-text-vertical-layout-truetype/type1
    that combine vertical layout with font_matrix rotation and translation.
    Currently Type3 and Type1 font paths both show broken behavior.
    The type1 test uses "Nimbus Sans L" as the font.

diff --git a/test/.gitignore b/test/.gitignore
index 8206bbb..440bd2a 100644
--- a/test/.gitignore
+++ b/test/.gitignore
@@ -43,9 +43,10 @@ fill-and-stroke-alpha
 fill-and-stroke-alpha-add
 fill-rule
 filter-nearest-offset
-ft-font-create-for-ft-face
-ft-text-vertical-layout
 ft-text-antialias-none
+ft-font-create-for-ft-face
+ft-text-vertical-layout-truetype
+ft-text-vertical-layout-type1
 font-face-get-type
 font-matrix-translation
 get-and-set
diff --git a/test/Makefile.am b/test/Makefile.am
index e2e5f4f..eac3f29 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -94,7 +94,8 @@ endif
 if CAIRO_HAS_FT_FONT
 TESTS += bitmap-font
 TESTS += ft-font-create-for-ft-face
-TESTS += ft-text-vertical-layout
+TESTS += ft-text-vertical-layout-truetype
+TESTS += ft-text-vertical-layout-type1
 TESTS += ft-text-antialias-none
 endif
 
@@ -208,10 +209,14 @@ fill-rule-ps-argb32-ref.png				\
 filter-nearest-offset-ref.png				\
 ft-text-antialias-none-ref.png				\
 ft-text-antialias-none-ps-argb32-ref.png		\
-ft-text-vertical-layout-ref.png				\
-ft-text-vertical-layout-pdf-argb32-ref.png		\
-ft-text-vertical-layout-ps-argb32-ref.png		\
-ft-text-vertical-layout-svg-ref.png			\
+ft-text-vertical-layout-truetype-ref.png		\
+ft-text-vertical-layout-truetype-pdf-argb32-ref.png	\
+ft-text-vertical-layout-truetype-ps-argb32-ref.png	\
+ft-text-vertical-layout-truetype-svg-ref.png		\
+ft-text-vertical-layout-type1-ref.png			\
+ft-text-vertical-layout-type1-pdf-argb32-ref.png	\
+ft-text-vertical-layout-type1-ps-argb32-ref.png		\
+ft-text-vertical-layout-type1-svg-ref.png		\
 font-matrix-translation-ref.png				\
 font-matrix-translation-ps-argb32-ref.png		\
 font-matrix-translation-svg-ref.png			\
diff --git a/test/ft-text-vertical-layout-pdf-argb32-ref.png b/test/ft-text-vertical-layout-pdf-argb32-ref.png
deleted file mode 100644
index f991c64..0000000
Binary files a/test/ft-text-vertical-layout-pdf-argb32-ref.png and /dev/null differ
diff --git a/test/ft-text-vertical-layout-ps-argb32-ref.png b/test/ft-text-vertical-layout-ps-argb32-ref.png
deleted file mode 100644
index 34fd856..0000000
Binary files a/test/ft-text-vertical-layout-ps-argb32-ref.png and /dev/null differ
diff --git a/test/ft-text-vertical-layout-ref.png b/test/ft-text-vertical-layout-ref.png
deleted file mode 100644
index 9510906..0000000
Binary files a/test/ft-text-vertical-layout-ref.png and /dev/null differ
diff --git a/test/ft-text-vertical-layout-svg-ref.png b/test/ft-text-vertical-layout-svg-ref.png
deleted file mode 100644
index e65fadb..0000000
Binary files a/test/ft-text-vertical-layout-svg-ref.png and /dev/null differ
diff --git a/test/ft-text-vertical-layout-type1-ref.png b/test/ft-text-vertical-layout-type1-ref.png
new file mode 100644
index 0000000..7a81d7f
Binary files /dev/null and b/test/ft-text-vertical-layout-type1-ref.png differ
diff --git a/test/ft-text-vertical-layout-type1-svg-ref.png b/test/ft-text-vertical-layout-type1-svg-ref.png
new file mode 100644
index 0000000..13e0792
Binary files /dev/null and b/test/ft-text-vertical-layout-type1-svg-ref.png differ
diff --git a/test/ft-text-vertical-layout-type1.c b/test/ft-text-vertical-layout-type1.c
new file mode 100644
index 0000000..be5fe33
--- /dev/null
+++ b/test/ft-text-vertical-layout-type1.c
@@ -0,0 +1,154 @@
+/*
+ * Copyright © 2006 Jinghua Luo
+ *
+ * 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.
+ *
+ * JINGHUA LUO 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: Jinghua Luo <sunmoon1997 at gmail.com>
+ * Derived from:
+ *  text-antialias-none.c,
+ *  ft-font-create-for-ft-face.c.
+ * Original Author: Carl D. Worth <cworth at cworth.org>
+ */
+#include "cairo-test.h"
+#include <cairo-ft.h>
+
+#define WIDTH  80
+#define HEIGHT 240
+#define TEXT_SIZE 30
+
+static cairo_test_draw_function_t draw;
+
+cairo_test_t test = {
+    "ft-text-vertical-layout-type1",
+    "Tests text rendering for vertical layout with TrueType fonts",
+    WIDTH, HEIGHT,
+    draw
+};
+
+static cairo_scaled_font_t *
+create_scaled_font (cairo_t * cr)
+{
+    FcPattern *pattern, *resolved;
+    FcResult result;
+    cairo_font_face_t *font_face;
+    cairo_scaled_font_t *scaled_font;
+    cairo_font_options_t *font_options;
+    cairo_matrix_t font_matrix, ctm;
+    double pixel_size;
+
+    font_options = cairo_font_options_create ();
+
+    cairo_get_font_options (cr, font_options);
+
+    pattern = FcPatternCreate ();
+
+    FcPatternAddString (pattern, FC_FAMILY, (FcChar8 *)"Nimbus Sans L");
+    FcPatternAddDouble (pattern, FC_PIXEL_SIZE, TEXT_SIZE);
+    FcConfigSubstitute (NULL, pattern, FcMatchPattern);
+
+    cairo_ft_font_options_substitute (font_options, pattern);
+
+    FcDefaultSubstitute (pattern);
+    resolved = FcFontMatch (NULL, pattern, &result);
+
+    /* set layout to vertical */
+    FcPatternDel (resolved, FC_VERTICAL_LAYOUT);
+    FcPatternAddBool (resolved, FC_VERTICAL_LAYOUT, FcTrue);
+
+    FcPatternGetDouble (resolved, FC_PIXEL_SIZE, 0, &pixel_size);
+
+    font_face = cairo_ft_font_face_create_for_pattern (resolved);
+
+    cairo_matrix_init_translate (&font_matrix, 10, 30);
+    cairo_matrix_rotate (&font_matrix, M_PI_2/3);
+    cairo_matrix_scale (&font_matrix, pixel_size, pixel_size);
+
+    cairo_get_matrix (cr, &ctm);
+
+    scaled_font = cairo_scaled_font_create (font_face,
+					    &font_matrix,
+					    &ctm,
+					    font_options);
+
+    cairo_font_options_destroy (font_options);
+    cairo_font_face_destroy (font_face);
+    FcPatternDestroy (pattern);
+    FcPatternDestroy (resolved);
+
+    return scaled_font;
+}
+
+static cairo_test_status_t
+draw (cairo_t *cr, int width, int height)
+{
+    cairo_text_extents_t extents;
+    cairo_scaled_font_t * scaled_font;
+    static char text[] = "i-W";
+    double line_width, x, y;
+
+    line_width = cairo_get_line_width (cr);
+
+    /* We draw in the default black, so paint white first. */
+    cairo_save (cr);
+    cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */
+    cairo_paint (cr);
+    cairo_restore (cr);
+
+    scaled_font = create_scaled_font (cr);
+    cairo_set_scaled_font (cr, scaled_font);
+
+    cairo_set_line_width (cr, 1.0);
+    cairo_set_source_rgb (cr, 0, 0, 0); /* black */
+    cairo_text_extents (cr, text, &extents);
+    x = width  - (extents.width  + extents.x_bearing) - 5;
+    y = height - (extents.height + extents.y_bearing) - 5;
+    cairo_move_to (cr, x, y);
+    cairo_show_text (cr, text);
+    cairo_rectangle (cr,
+		     x + extents.x_bearing - line_width / 2,
+		     y + extents.y_bearing - line_width / 2,
+		     extents.width  + line_width,
+		     extents.height + line_width);
+    cairo_stroke (cr);
+
+    cairo_set_source_rgb (cr, 0, 0, 1); /* blue */
+    cairo_text_extents (cr, text, &extents);
+    x = -extents.x_bearing + 5;
+    y = -extents.y_bearing + 5;
+    cairo_move_to (cr, x, y);
+    cairo_text_path (cr, text);
+    cairo_fill (cr);
+    cairo_rectangle (cr,
+		     x + extents.x_bearing - line_width / 2,
+		     y + extents.y_bearing - line_width / 2,
+		     extents.width  + line_width,
+		     extents.height + line_width);
+    cairo_stroke (cr);
+
+    cairo_scaled_font_destroy (scaled_font);
+
+    return CAIRO_TEST_SUCCESS;
+}
+
+int
+main (void)
+{
+    return cairo_test (&test);
+}
diff --git a/test/ft-text-vertical-layout.c b/test/ft-text-vertical-layout.c
deleted file mode 100644
index 9f2e98f..0000000
--- a/test/ft-text-vertical-layout.c
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright © 2006 Jinghua Luo
- *
- * 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.
- *
- * JINGHUA LUO 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: Jinghua Luo <sunmoon1997 at gmail.com>
- * Derived from:
- *  text-antialias-none.c,
- *  ft-font-create-for-ft-face.c.
- * Original Author: Carl D. Worth <cworth at cworth.org>
- */
-#include "cairo-test.h"
-#include <cairo-ft.h>
-
-#define WIDTH  40
-#define HEIGHT 40
-#define TEXT_SIZE 12
-
-static cairo_test_draw_function_t draw;
-
-cairo_test_t test = {
-    "ft-text-vertical-layout",
-    "Tests text rendering for vertical layout",
-    WIDTH, HEIGHT,
-    draw
-};
-
-static cairo_scaled_font_t *
-create_scaled_font (cairo_t * cr)
-{
-    FcPattern *pattern, *resolved;
-    FcResult result;
-    cairo_font_face_t *font_face;
-    cairo_scaled_font_t *scaled_font;
-    cairo_font_options_t *font_options;
-    cairo_matrix_t font_matrix, ctm;
-    double pixel_size;
-
-    font_options = cairo_font_options_create ();
-
-    cairo_get_font_options (cr, font_options);
-
-    pattern = FcPatternCreate ();
-
-    FcPatternAddString (pattern, FC_FAMILY, (FcChar8 *)"Bitstream Vera Sans");
-    FcPatternAddDouble (pattern, FC_PIXEL_SIZE, TEXT_SIZE);
-    FcConfigSubstitute (NULL, pattern, FcMatchPattern);
-
-    cairo_ft_font_options_substitute (font_options, pattern);
-
-    FcDefaultSubstitute (pattern);
-    resolved = FcFontMatch (NULL, pattern, &result);
-
-    /* set layout to vertical */
-    FcPatternDel (resolved, FC_VERTICAL_LAYOUT);
-    FcPatternAddBool (resolved, FC_VERTICAL_LAYOUT, FcTrue);
-
-    FcPatternGetDouble (resolved, FC_PIXEL_SIZE, 0, &pixel_size);
-
-    font_face = cairo_ft_font_face_create_for_pattern (resolved);
-
-    cairo_matrix_init_identity (&font_matrix);
-    cairo_matrix_scale (&font_matrix, pixel_size, pixel_size);
-
-    cairo_get_matrix (cr, &ctm);
-
-    scaled_font = cairo_scaled_font_create (font_face,
-					    &font_matrix,
-					    &ctm,
-					    font_options);
-
-    cairo_font_options_destroy (font_options);
-    cairo_font_face_destroy (font_face);
-    FcPatternDestroy (pattern);
-    FcPatternDestroy (resolved);
-
-    return scaled_font;
-}
-
-static cairo_test_status_t
-draw (cairo_t *cr, int width, int height)
-{
-    cairo_text_extents_t extents;
-    cairo_scaled_font_t * scaled_font;
-    static char text[] = "i-W";
-
-    /* We draw in the default black, so paint white first. */
-    cairo_save (cr);
-    cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */
-    cairo_paint (cr);
-    cairo_restore (cr);
-
-    scaled_font = create_scaled_font (cr);
-    cairo_set_scaled_font (cr, scaled_font);
-
-    cairo_set_line_width (cr, 1.0);
-    cairo_set_source_rgb (cr, 0, 0, 0); /* black */
-    cairo_text_extents (cr, text, &extents);
-    cairo_move_to (cr,
-                   width - (extents.width + extents.x_bearing),
-                   -extents.y_bearing);
-    cairo_show_text (cr, text);
-
-    cairo_set_source_rgb (cr, 0, 0, 1); /* blue */
-    cairo_text_extents (cr, text, &extents);
-    cairo_move_to (cr, -extents.x_bearing, -extents.y_bearing);
-    cairo_text_path (cr, text);
-    cairo_stroke (cr);
-
-    cairo_scaled_font_destroy (scaled_font);
-
-    return CAIRO_TEST_SUCCESS;
-}
-
-int
-main (void)
-{
-    return cairo_test (&test);
-}


More information about the cairo-commit mailing list