[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.
This commit is contained in:
Behdad Esfahbod 2006-08-16 14:27:40 -04:00
parent c385922c19
commit cbcf1ddd64
9 changed files with 42 additions and 18 deletions

5
test/.gitignore vendored
View file

@ -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

View file

@ -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 \

Binary file not shown.

Before

Width:  |  Height:  |  Size: 715 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 611 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 829 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 770 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

View file

@ -29,15 +29,15 @@
#include "cairo-test.h"
#include <cairo-ft.h>
#define WIDTH 40
#define HEIGHT 40
#define TEXT_SIZE 12
#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",
"Tests text rendering for vertical layout",
"ft-text-vertical-layout-type1",
"Tests text rendering for vertical layout with TrueType fonts",
WIDTH, HEIGHT,
draw
};
@ -59,7 +59,7 @@ create_scaled_font (cairo_t * cr)
pattern = FcPatternCreate ();
FcPatternAddString (pattern, FC_FAMILY, (FcChar8 *)"Bitstream Vera Sans");
FcPatternAddString (pattern, FC_FAMILY, (FcChar8 *)"Nimbus Sans L");
FcPatternAddDouble (pattern, FC_PIXEL_SIZE, TEXT_SIZE);
FcConfigSubstitute (NULL, pattern, FcMatchPattern);
@ -76,7 +76,8 @@ create_scaled_font (cairo_t * cr)
font_face = cairo_ft_font_face_create_for_pattern (resolved);
cairo_matrix_init_identity (&font_matrix);
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);
@ -100,6 +101,9 @@ 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);
@ -113,15 +117,29 @@ draw (cairo_t *cr, int width, int height)
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);
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);
cairo_move_to (cr, -extents.x_bearing, -extents.y_bearing);
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);