test/text-antialias-subpixel: Modify to demonstrate problem with subpixel BGR and VRGB

This commit is contained in:
Frederic Crozat 2006-02-23 16:44:19 -08:00 committed by Carl Worth
parent 886bc4ddb0
commit 540c10f3fb
2 changed files with 22 additions and 16 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View file

@ -26,7 +26,7 @@
#include "cairo-test.h"
#define WIDTH 31
#define HEIGHT 20
#define HEIGHT 90
#define TEXT_SIZE 12
cairo_test_t test = {
@ -41,6 +41,7 @@ draw (cairo_t *cr, int width, int height)
cairo_text_extents_t extents;
cairo_font_options_t *font_options;
static char black[] = "black", blue[] = "blue";
cairo_subpixel_order_t order;
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
cairo_paint (cr);
@ -54,24 +55,29 @@ draw (cairo_t *cr, int width, int height)
* (bad color fringing). The reason we turn off hints here is to
* try to get repeatable glyph shapes on multiple systems, not for
* any aesthetic reason. */
font_options = cairo_font_options_create ();
cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_NONE);
cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_SUBPIXEL);
cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_RGB);
cairo_set_font_options (cr, font_options);
cairo_font_options_destroy (font_options);
for (order = CAIRO_SUBPIXEL_ORDER_RGB ; order < CAIRO_SUBPIXEL_ORDER_VBGR+1 ; order++) {
cairo_set_source_rgb (cr, 0, 0, 0); /* black */
cairo_text_extents (cr, black, &extents);
cairo_move_to (cr, -extents.x_bearing, -extents.y_bearing);
cairo_show_text (cr, black);
cairo_translate (cr, 0, -extents.y_bearing + 1);
font_options = cairo_font_options_create ();
cairo_set_source_rgb (cr, 0, 0, 1); /* blue */
cairo_text_extents (cr, blue, &extents);
cairo_move_to (cr, -extents.x_bearing, -extents.y_bearing);
cairo_show_text (cr, blue);
cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_NONE);
cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_SUBPIXEL);
cairo_font_options_set_subpixel_order (font_options, order);
cairo_set_font_options (cr, font_options);
cairo_font_options_destroy (font_options);
cairo_set_source_rgb (cr, 0, 0, 0); /* black */
cairo_text_extents (cr, black, &extents);
cairo_move_to (cr, -extents.x_bearing, -extents.y_bearing);
cairo_show_text (cr, black);
cairo_translate (cr, 0, -extents.y_bearing + 2);
cairo_set_source_rgb (cr, 0, 0, 1); /* blue */
cairo_text_extents (cr, blue, &extents);
cairo_move_to (cr, -extents.x_bearing, -extents.y_bearing);
cairo_show_text (cr, blue);
cairo_translate (cr, 0, -extents.y_bearing + 2);
}
return CAIRO_TEST_SUCCESS;
}