9626a9dd2e16090b4facefc7eedafbb59a95ae8d
[framework/graphics/cairo.git] / test / large-twin-antialias-mixed.c
1 /*
2  * Copyright 2009 Chris Wilson
3  *
4  * Permission to use, copy, modify, distribute, and sell this software
5  * and its documentation for any purpose is hereby granted without
6  * fee, provided that the above copyright notice appear in all copies
7  * and that both that copyright notice and this permission notice
8  * appear in supporting documentation, and that the name of
9  * Chris Wilson not be used in advertising or publicity pertaining to
10  * distribution of the software without specific, written prior
11  * permission. Chris Wilson makes no representations about the
12  * suitability of this software for any purpose.  It is provided "as
13  * is" without express or implied warranty.
14  *
15  * CHRIS WILSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
16  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17  * FITNESS, IN NO EVENT SHALL CHRIS WILSON BE LIABLE FOR ANY SPECIAL,
18  * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
19  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
21  * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22  *
23  * Author: Chris Wilson <chris@chris-wilson.co.uk>
24  */
25
26 #include "cairo-test.h"
27
28 static cairo_scaled_font_t *
29 create_twin (cairo_t *cr, cairo_antialias_t antialias)
30 {
31     cairo_font_options_t *options;
32
33     cairo_select_font_face (cr,
34                             "@cairo:",
35                             CAIRO_FONT_SLANT_NORMAL,
36                             CAIRO_FONT_WEIGHT_NORMAL);
37
38     options = cairo_font_options_create ();
39     cairo_font_options_set_antialias (options, antialias);
40     cairo_set_font_options (cr, options);
41     cairo_font_options_destroy (options);
42
43     return cairo_scaled_font_reference (cairo_get_scaled_font (cr));
44 }
45
46
47 static cairo_test_status_t
48 draw (cairo_t *cr, int width, int height)
49 {
50     cairo_scaled_font_t *subpixel, *gray, *none;
51
52     cairo_set_source_rgb (cr, 1, 1, 1);
53     cairo_paint (cr);
54     cairo_set_source_rgb (cr, 0, 0, 0);
55
56     cairo_set_font_size (cr, 64);
57     subpixel = create_twin (cr, CAIRO_ANTIALIAS_SUBPIXEL);
58     gray = create_twin (cr, CAIRO_ANTIALIAS_GRAY);
59     none = create_twin (cr, CAIRO_ANTIALIAS_NONE);
60
61     cairo_move_to (cr, 4, 64);
62     cairo_set_scaled_font (cr, subpixel);
63     cairo_show_text (cr, "Is cairo's");
64     cairo_set_scaled_font (cr, gray);
65     cairo_show_text (cr, " twin");
66     cairo_set_scaled_font (cr, none);
67     cairo_show_text (cr, " giza?");
68
69     cairo_move_to (cr, 4, 128+16);
70     cairo_set_scaled_font (cr, gray);
71     cairo_show_text (cr, "Is cairo's");
72     cairo_set_scaled_font (cr, none);
73     cairo_show_text (cr, " twin");
74     cairo_set_scaled_font (cr, subpixel);
75     cairo_show_text (cr, " giza?");
76
77     cairo_move_to (cr, 4, 192+32);
78     cairo_set_scaled_font (cr, none);
79     cairo_show_text (cr, "Is cairo's");
80     cairo_set_scaled_font (cr, gray);
81     cairo_show_text (cr, " twin");
82     cairo_set_scaled_font (cr, subpixel);
83     cairo_show_text (cr, " giza?");
84
85     cairo_scaled_font_destroy (none);
86     cairo_scaled_font_destroy (gray);
87     cairo_scaled_font_destroy (subpixel);
88
89     return CAIRO_TEST_SUCCESS;
90 }
91
92 CAIRO_TEST (large_twin_antialias_mixed,
93             "Tests the internal font (with intermixed antialiasing)",
94             "twin, font", /* keywords */
95             "target=raster", /* requirements */
96             524, 240,
97             NULL, draw)