diff --git a/test/Makefile.am b/test/Makefile.am index 9554a2880..c2582230a 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -149,6 +149,10 @@ text-antialias-gray$(EXEEXT) \ text-antialias-none$(EXEEXT) \ text-antialias-subpixel$(EXEEXT) \ text-cache-crash$(EXEEXT) \ +text-lcd-filter-fir3$(EXEEXT) \ +text-lcd-filter-fir5$(EXEEXT) \ +text-lcd-filter-intra-pixel$(EXEEXT) \ +text-lcd-filter-none$(EXEEXT) \ text-pattern$(EXEEXT) \ text-rotate$(EXEEXT) \ text-transform$(EXEEXT) \ diff --git a/test/font-options.c b/test/font-options.c index b0e111ef6..3e5194c96 100644 --- a/test/font-options.c +++ b/test/font-options.c @@ -72,7 +72,11 @@ main (void) cairo_font_options_set_subpixel_order (NULL, CAIRO_SUBPIXEL_ORDER_DEFAULT); cairo_font_options_get_subpixel_order (NULL); - assert (cairo_font_options_get_subpixel_order (default_options) == CAIRO_SUBPIXEL_ORDER_DEFAULT); + assert (cairo_font_options_get_subpixel_order (default_options) == CAIRO_SUBPIXEL_ORDER_DEFAULT); + + cairo_font_options_set_lcd_filter (NULL, CAIRO_LCD_FILTER_DEFAULT); + cairo_font_options_get_lcd_filter (NULL); + assert (cairo_font_options_get_lcd_filter (default_options) == CAIRO_LCD_FILTER_DEFAULT); cairo_font_options_set_hint_style (NULL, CAIRO_HINT_STYLE_DEFAULT); cairo_font_options_get_hint_style (NULL); diff --git a/test/text-antialias-subpixel-ref.png b/test/text-antialias-subpixel-ref.png index 88f76c08e..2721a504f 100644 Binary files a/test/text-antialias-subpixel-ref.png and b/test/text-antialias-subpixel-ref.png differ diff --git a/test/text-antialias-subpixel.c b/test/text-antialias-subpixel.c index af0112a8f..440c3a3b9 100644 --- a/test/text-antialias-subpixel.c +++ b/test/text-antialias-subpixel.c @@ -57,6 +57,7 @@ draw (cairo_t *cr, int width, int height) cairo_get_font_options (cr, font_options); cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_SUBPIXEL); cairo_font_options_set_subpixel_order (font_options, CAIRO_SUBPIXEL_ORDER_RGB); + cairo_font_options_set_lcd_filter (font_options, CAIRO_LCD_FILTER_NONE); cairo_set_font_options (cr, font_options); cairo_font_options_destroy (font_options); diff --git a/test/text-lcd-filter-fir3-ref.png b/test/text-lcd-filter-fir3-ref.png new file mode 100644 index 000000000..3521e63a2 Binary files /dev/null and b/test/text-lcd-filter-fir3-ref.png differ diff --git a/test/text-lcd-filter-fir3.c b/test/text-lcd-filter-fir3.c new file mode 100644 index 000000000..a6445b51c --- /dev/null +++ b/test/text-lcd-filter-fir3.c @@ -0,0 +1,85 @@ +/* + * Copyright © 2005 Red Hat, Inc. + * + * 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. + * + * RED HAT, INC. 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: Carl D. Worth + */ + +#include "cairo-test.h" + +#define WIDTH 31 +#define HEIGHT 22 +#define TEXT_SIZE 12 + +static cairo_test_draw_function_t draw; + +cairo_test_t test = { + "text-lcd-filter-fir3", + "Tests text rendering with a 3x3 kernel FIR LCD filter", + WIDTH, HEIGHT, + draw +}; + +static cairo_test_status_t +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"; + + /* 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); + + cairo_select_font_face (cr, "Bitstream Vera Sans", + CAIRO_FONT_SLANT_NORMAL, + CAIRO_FONT_WEIGHT_NORMAL); + cairo_set_font_size (cr, TEXT_SIZE); + + font_options = cairo_font_options_create (); + cairo_get_font_options (cr, font_options); + cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_SUBPIXEL); + cairo_font_options_set_lcd_filter (font_options, CAIRO_LCD_FILTER_FIR3); + 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 + 1); + + 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); + + return CAIRO_TEST_SUCCESS; +} + +int +main (void) +{ + return cairo_test (&test); +} diff --git a/test/text-lcd-filter-fir5-ref.png b/test/text-lcd-filter-fir5-ref.png new file mode 100644 index 000000000..319cdc103 Binary files /dev/null and b/test/text-lcd-filter-fir5-ref.png differ diff --git a/test/text-lcd-filter-fir5.c b/test/text-lcd-filter-fir5.c new file mode 100644 index 000000000..54bee806a --- /dev/null +++ b/test/text-lcd-filter-fir5.c @@ -0,0 +1,85 @@ +/* + * Copyright © 2005 Red Hat, Inc. + * + * 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. + * + * RED HAT, INC. 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: Carl D. Worth + */ + +#include "cairo-test.h" + +#define WIDTH 31 +#define HEIGHT 22 +#define TEXT_SIZE 12 + +static cairo_test_draw_function_t draw; + +cairo_test_t test = { + "text-lcd-filter-fir5", + "Tests text rendering with a 5x5 kernel FIR LCD filter", + WIDTH, HEIGHT, + draw +}; + +static cairo_test_status_t +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"; + + /* 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); + + cairo_select_font_face (cr, "Bitstream Vera Sans", + CAIRO_FONT_SLANT_NORMAL, + CAIRO_FONT_WEIGHT_NORMAL); + cairo_set_font_size (cr, TEXT_SIZE); + + font_options = cairo_font_options_create (); + cairo_get_font_options (cr, font_options); + cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_SUBPIXEL); + cairo_font_options_set_lcd_filter (font_options, CAIRO_LCD_FILTER_FIR5); + 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 + 1); + + 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); + + return CAIRO_TEST_SUCCESS; +} + +int +main (void) +{ + return cairo_test (&test); +} diff --git a/test/text-lcd-filter-intra-pixel-ref.png b/test/text-lcd-filter-intra-pixel-ref.png new file mode 100644 index 000000000..03a8afa82 Binary files /dev/null and b/test/text-lcd-filter-intra-pixel-ref.png differ diff --git a/test/text-lcd-filter-intra-pixel.c b/test/text-lcd-filter-intra-pixel.c new file mode 100644 index 000000000..3f8b4863b --- /dev/null +++ b/test/text-lcd-filter-intra-pixel.c @@ -0,0 +1,85 @@ +/* + * Copyright © 2005 Red Hat, Inc. + * + * 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. + * + * RED HAT, INC. 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: Carl D. Worth + */ + +#include "cairo-test.h" + +#define WIDTH 31 +#define HEIGHT 22 +#define TEXT_SIZE 12 + +static cairo_test_draw_function_t draw; + +cairo_test_t test = { + "text-lcd-filter-intra-pixel", + "Tests text rendering with intra-pixel LCD filter", + WIDTH, HEIGHT, + draw +}; + +static cairo_test_status_t +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"; + + /* 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); + + cairo_select_font_face (cr, "Bitstream Vera Sans", + CAIRO_FONT_SLANT_NORMAL, + CAIRO_FONT_WEIGHT_NORMAL); + cairo_set_font_size (cr, TEXT_SIZE); + + font_options = cairo_font_options_create (); + cairo_get_font_options (cr, font_options); + cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_SUBPIXEL); + cairo_font_options_set_lcd_filter (font_options, CAIRO_LCD_FILTER_INTRA_PIXEL); + 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 + 1); + + 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); + + return CAIRO_TEST_SUCCESS; +} + +int +main (void) +{ + return cairo_test (&test); +} diff --git a/test/text-lcd-filter-none-ref.png b/test/text-lcd-filter-none-ref.png new file mode 100644 index 000000000..32138331e Binary files /dev/null and b/test/text-lcd-filter-none-ref.png differ diff --git a/test/text-lcd-filter-none.c b/test/text-lcd-filter-none.c new file mode 100644 index 000000000..87e358ab7 --- /dev/null +++ b/test/text-lcd-filter-none.c @@ -0,0 +1,85 @@ +/* + * Copyright © 2005 Red Hat, Inc. + * + * 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. + * + * RED HAT, INC. 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: Carl D. Worth + */ + +#include "cairo-test.h" + +#define WIDTH 31 +#define HEIGHT 22 +#define TEXT_SIZE 12 + +static cairo_test_draw_function_t draw; + +cairo_test_t test = { + "text-lcd-filter-none", + "Tests text rendering with no LCD filter", + WIDTH, HEIGHT, + draw +}; + +static cairo_test_status_t +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"; + + /* 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); + + cairo_select_font_face (cr, "Bitstream Vera Sans", + CAIRO_FONT_SLANT_NORMAL, + CAIRO_FONT_WEIGHT_NORMAL); + cairo_set_font_size (cr, TEXT_SIZE); + + font_options = cairo_font_options_create (); + cairo_get_font_options (cr, font_options); + cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_SUBPIXEL); + cairo_font_options_set_lcd_filter (font_options, CAIRO_LCD_FILTER_NONE); + 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 + 1); + + 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); + + return CAIRO_TEST_SUCCESS; +} + +int +main (void) +{ + return cairo_test (&test); +}