Change user-font-image test to use a pattern

This can be used to expose a bug in _cairo_rectangle_intersect() by
changing:

  fixed_scale = 1024 to 1 in cairo-user-font.c

and

cairo_matrix_translate (&matrix, 0, -8) to (&matrix, 0, -9) in
user-font-image.c

This will cause cairo_text_extents (cr, text, &extents) in
user-font-image.c to return a height of 8388683.
This commit is contained in:
Adrian Johnson 2008-10-27 23:04:16 +10:30
parent cdacf55e1b
commit 670d942fe3
2 changed files with 11 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

View file

@ -116,6 +116,8 @@ test_scaled_font_render_glyph (cairo_scaled_font_t *scaled_font,
int i;
unsigned char *data;
cairo_surface_t *image;
cairo_pattern_t *pattern;
cairo_matrix_t matrix;
uint8_t byte;
/* FIXME: We simply crash on out-of-bound glyph indices */
@ -130,8 +132,15 @@ test_scaled_font_render_glyph (cairo_scaled_font_t *scaled_font,
data += cairo_image_surface_get_stride (image);
}
cairo_scale (cr, 1.0/8.0, 1.0/8.0);
cairo_mask_surface (cr, image, 0, -8);
pattern = cairo_pattern_create_for_surface (image);
cairo_matrix_init_identity (&matrix);
cairo_matrix_scale (&matrix, 1.0/8.0, 1.0/8.0);
cairo_matrix_translate (&matrix, 0, -8);
cairo_matrix_invert (&matrix);
cairo_pattern_set_matrix (pattern, &matrix);
cairo_set_source (cr, pattern);
cairo_mask (cr, pattern);
cairo_pattern_destroy (pattern);
cairo_surface_destroy (image);
return CAIRO_STATUS_SUCCESS;