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
9
create_twin (cairo_t *cr, cairo_antialias_t antialias)
30
{
31
    cairo_font_options_t *options;
32

            
33
9
    cairo_select_font_face (cr,
34
			    "@cairo:",
35
			    CAIRO_FONT_SLANT_NORMAL,
36
			    CAIRO_FONT_WEIGHT_NORMAL);
37

            
38
9
    options = cairo_font_options_create ();
39
9
    cairo_font_options_set_antialias (options, antialias);
40
9
    cairo_set_font_options (cr, options);
41
9
    cairo_font_options_destroy (options);
42

            
43
9
    return cairo_scaled_font_reference (cairo_get_scaled_font (cr));
44
}
45

            
46

            
47
static cairo_test_status_t
48
3
draw (cairo_t *cr, int width, int height)
49
{
50
    cairo_scaled_font_t *subpixel, *gray, *none;
51

            
52
3
    cairo_set_source_rgb (cr, 1, 1, 1);
53
3
    cairo_paint (cr);
54
3
    cairo_set_source_rgb (cr, 0, 0, 0);
55

            
56
3
    cairo_set_font_size (cr, 16);
57
3
    subpixel = create_twin (cr, CAIRO_ANTIALIAS_SUBPIXEL);
58
3
    gray = create_twin (cr, CAIRO_ANTIALIAS_GRAY);
59
3
    none = create_twin (cr, CAIRO_ANTIALIAS_NONE);
60

            
61
3
    cairo_move_to (cr, 4, 14);
62
3
    cairo_set_scaled_font (cr, subpixel);
63
3
    cairo_show_text (cr, "Is cairo's");
64
3
    cairo_set_scaled_font (cr, gray);
65
3
    cairo_show_text (cr, " twin");
66
3
    cairo_set_scaled_font (cr, none);
67
3
    cairo_show_text (cr, " giza?");
68

            
69
3
    cairo_move_to (cr, 4, 34);
70
3
    cairo_set_scaled_font (cr, gray);
71
3
    cairo_show_text (cr, "Is cairo's");
72
3
    cairo_set_scaled_font (cr, none);
73
3
    cairo_show_text (cr, " twin");
74
3
    cairo_set_scaled_font (cr, subpixel);
75
3
    cairo_show_text (cr, " giza?");
76

            
77
3
    cairo_move_to (cr, 4, 54);
78
3
    cairo_set_scaled_font (cr, none);
79
3
    cairo_show_text (cr, "Is cairo's");
80
3
    cairo_set_scaled_font (cr, gray);
81
3
    cairo_show_text (cr, " twin");
82
3
    cairo_set_scaled_font (cr, subpixel);
83
3
    cairo_show_text (cr, " giza?");
84

            
85
3
    cairo_scaled_font_destroy (none);
86
3
    cairo_scaled_font_destroy (gray);
87
3
    cairo_scaled_font_destroy (subpixel);
88

            
89
3
    return CAIRO_TEST_SUCCESS;
90
}
91

            
92
1
CAIRO_TEST (twin_antialias_mixed,
93
	    "Tests the internal font (with intermixed antialiasing)",
94
	    "twin, font", /* keywords */
95
	    "target=raster", /* requirements */
96
	    140, 60,
97
	    NULL, draw)