Blame test/culled-glyphs.c

Packit 324a5c
/*
Packit 324a5c
 * Copyright 2008 Chris Wilson
Packit 324a5c
 *
Packit 324a5c
 * Permission to use, copy, modify, distribute, and sell this software
Packit 324a5c
 * and its documentation for any purpose is hereby granted without
Packit 324a5c
 * fee, provided that the above copyright notice appear in all copies
Packit 324a5c
 * and that both that copyright notice and this permission notice
Packit 324a5c
 * appear in supporting documentation, and that the name of
Packit 324a5c
 * Chris Wilson not be used in advertising or publicity pertaining to
Packit 324a5c
 * distribution of the software without specific, written prior
Packit 324a5c
 * permission. Chris Wilson makes no representations about the
Packit 324a5c
 * suitability of this software for any purpose.  It is provided "as
Packit 324a5c
 * is" without express or implied warranty.
Packit 324a5c
 *
Packit 324a5c
 * CHRIS WILSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
Packit 324a5c
 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
Packit 324a5c
 * FITNESS, IN NO EVENT SHALL CHRIS WILSON BE LIABLE FOR ANY SPECIAL,
Packit 324a5c
 * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
Packit 324a5c
 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
Packit 324a5c
 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
Packit 324a5c
 * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Packit 324a5c
 *
Packit 324a5c
 * Author: Chris Wilson <chris@chris-wilson.co.uk>
Packit 324a5c
 */
Packit 324a5c
Packit 324a5c
#include "cairo-test.h"
Packit 324a5c
Packit 324a5c
static cairo_test_status_t
Packit 324a5c
draw (cairo_t *cr, int width, int height)
Packit 324a5c
{
Packit 324a5c
    const char *text =
Packit 324a5c
"This needs to be a very long string, wider than the surface, and yet wider."
Packit 324a5c
"Ideally it should overflow the stack buffers, but do you really want to read "
Packit 324a5c
"a message that long. No. So we compromise with around 300 glyphs that is "
Packit 324a5c
"long enough to trigger the conditions as stated in "
Packit 324a5c
"http://lists.cairographics.org/archives/cairo/2008-December/015976.html. "
Packit 324a5c
"Happy now?";
Packit 324a5c
    cairo_text_extents_t extents;
Packit 324a5c
Packit 324a5c
    cairo_set_source_rgb (cr, 1, 1, 1);
Packit 324a5c
    cairo_paint (cr);
Packit 324a5c
    cairo_set_source_rgb (cr, 0, 0, 0);
Packit 324a5c
Packit 324a5c
    cairo_set_font_size (cr, 16);
Packit 324a5c
    cairo_text_extents (cr, text, &extents);
Packit 324a5c
    cairo_move_to (cr, -extents.width/2, 18);
Packit 324a5c
    cairo_show_text (cr, text);
Packit 324a5c
Packit 324a5c
    /* XXX we should exercise cairo_show_text_glyphs() as well,
Packit 324a5c
     * and CAIRO_TEXT_CLUSTER_BACKWARDS
Packit 324a5c
     */
Packit 324a5c
Packit 324a5c
    return CAIRO_TEST_SUCCESS;
Packit 324a5c
}
Packit 324a5c
Packit 324a5c
CAIRO_TEST (culled_glyphs,
Packit 324a5c
	    "Tests culling of glyphs and text clusters",
Packit 324a5c
	    "glyphs", /* keywords */
Packit 324a5c
	    NULL, /* requirements */
Packit 324a5c
	    20, 20,
Packit 324a5c
	    NULL, draw)
Packit 324a5c