diff --git a/perf/Makefile.am b/perf/Makefile.am index 3ac13a6f1..daec8e4ef 100644 --- a/perf/Makefile.am +++ b/perf/Makefile.am @@ -35,6 +35,7 @@ cairo_perf_SOURCES = \ subimage_copy.c \ tessellate.c \ text.c \ + twin.c \ unaligned-clip.c \ world-map.c \ world-map.h \ diff --git a/perf/cairo-perf.c b/perf/cairo-perf.c index 613d15cf9..a6d59a579 100644 --- a/perf/cairo-perf.c +++ b/perf/cairo-perf.c @@ -458,5 +458,6 @@ const cairo_perf_case_t perf_cases[] = { { rounded_rectangles, 512, 512}, { long_dashed_lines, 512, 512}, { composite_checker, 16, 512}, + { twin, 800, 800}, { NULL } }; diff --git a/perf/cairo-perf.h b/perf/cairo-perf.h index 57fe85f11..0cedb6913 100644 --- a/perf/cairo-perf.h +++ b/perf/cairo-perf.h @@ -172,5 +172,6 @@ CAIRO_PERF_DECL (rectangles); CAIRO_PERF_DECL (rounded_rectangles); CAIRO_PERF_DECL (long_dashed_lines); CAIRO_PERF_DECL (composite_checker); +CAIRO_PERF_DECL (twin); #endif diff --git a/perf/twin.c b/perf/twin.c new file mode 100644 index 000000000..adedb25f6 --- /dev/null +++ b/perf/twin.c @@ -0,0 +1,50 @@ +#define WIDTH 1350 +#define HEIGHT 900 + +#include "cairo-perf.h" + +static cairo_perf_ticks_t +do_twin (cairo_t *cr, + int width, + int height) +{ + int i, j, h; + unsigned char s[2] = {0, 0}; + + cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */ + cairo_paint (cr); + cairo_set_source_rgb (cr, 0, 0, 0); + + cairo_perf_timer_start (); + + cairo_select_font_face (cr, + "", + CAIRO_FONT_SLANT_NORMAL, + CAIRO_FONT_WEIGHT_NORMAL); + + h = 2; + for (i = 8; i < 48; i >= 24 ? i+=3 : i++) { + cairo_set_font_size (cr, i); + for (j = 33; j < 128; j++) { + if (j == 33 || (j == 80 && i > 24)) { + h += i + 2; + cairo_move_to (cr, 10, h); + } + s[0] = j; + cairo_text_path (cr, (const char *) s); + } + } + cairo_fill (cr); + + cairo_perf_timer_stop (); + return cairo_perf_timer_elapsed (); +} + +void +twin (cairo_perf_t *perf, + cairo_t *cr, + int width, + int height) +{ + cairo_perf_run (perf, "twin", do_twin); +} diff --git a/src/cairo-font-face.c b/src/cairo-font-face.c index 30c8d9fb3..6cea39585 100644 --- a/src/cairo-font-face.c +++ b/src/cairo-font-face.c @@ -578,7 +578,8 @@ _cairo_toy_font_face_scaled_font_get_implementation (void *abstra if (font_face->base.status) return font_face->base.status; - if (CAIRO_SCALED_FONT_BACKEND_DEFAULT != &_cairo_user_scaled_font_backend) + if (CAIRO_SCALED_FONT_BACKEND_DEFAULT != &_cairo_user_scaled_font_backend && + 0 != strcmp (font_face->family, CAIRO_USER_FONT_FAMILY_DEFAULT)) { const cairo_scaled_font_backend_t * backend = CAIRO_SCALED_FONT_BACKEND_DEFAULT; @@ -617,7 +618,8 @@ _cairo_toy_font_face_scaled_font_create (void *abstract_font_face if (status) return status; - if (CAIRO_SCALED_FONT_BACKEND_DEFAULT != &_cairo_user_scaled_font_backend) + if (CAIRO_SCALED_FONT_BACKEND_DEFAULT != &_cairo_user_scaled_font_backend && + 0 != strcmp (font_face->family, CAIRO_USER_FONT_FAMILY_DEFAULT)) { const cairo_scaled_font_backend_t * backend = CAIRO_SCALED_FONT_BACKEND_DEFAULT; diff --git a/src/cairoint.h b/src/cairoint.h index 281034835..f94e68214 100644 --- a/src/cairoint.h +++ b/src/cairoint.h @@ -938,6 +938,7 @@ typedef struct _cairo_traps { #define CAIRO_WIN32_FONT_FAMILY_DEFAULT "Arial" #define CAIRO_QUARTZ_FONT_FAMILY_DEFAULT "Helvetica" #define CAIRO_FT_FONT_FAMILY_DEFAULT "" +#define CAIRO_USER_FONT_FAMILY_DEFAULT "" #if CAIRO_HAS_WIN32_FONT diff --git a/test/.gitignore b/test/.gitignore index 8da34a007..675315a69 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -233,6 +233,7 @@ transforms translate-show-surface trap-clip truetype-tables +twin unantialiased-shapes unbounded-operator user-data diff --git a/test/Makefile.am b/test/Makefile.am index 887bd73aa..026ce9a50 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -180,6 +180,7 @@ transforms$(EXEEXT) \ translate-show-surface$(EXEEXT) \ trap-clip$(EXEEXT) \ truetype-tables$(EXEEXT) \ +twin$(EXEEXT) \ unantialiased-shapes$(EXEEXT) \ unbounded-operator$(EXEEXT) \ user-data$(EXEEXT) \ @@ -929,6 +930,11 @@ REFERENCE_IMAGES = \ trap-clip-pdf-rgb24-ref.png \ trap-clip-ps2-argb32-ref.png \ trap-clip-ps2-rgb24-ref.png \ + twin-ref.png \ + twin-ps2-ref.png \ + twin-ps3-ref.png \ + twin-svg11-ref.png \ + twin-svg12-ref.png \ unantialiased-shapes-ref.png \ unantialiased-shapes-quartz-ref.png \ unbounded-operator-ref.png \ diff --git a/test/twin-ps2-ref.png b/test/twin-ps2-ref.png new file mode 100644 index 000000000..a58dc5b63 Binary files /dev/null and b/test/twin-ps2-ref.png differ diff --git a/test/twin-ps3-ref.png b/test/twin-ps3-ref.png new file mode 100644 index 000000000..a58dc5b63 Binary files /dev/null and b/test/twin-ps3-ref.png differ diff --git a/test/twin-ref.png b/test/twin-ref.png new file mode 100644 index 000000000..f2a5636de Binary files /dev/null and b/test/twin-ref.png differ diff --git a/test/twin-svg11-ref.png b/test/twin-svg11-ref.png new file mode 100644 index 000000000..5b7d67d42 Binary files /dev/null and b/test/twin-svg11-ref.png differ diff --git a/test/twin-svg12-ref.png b/test/twin-svg12-ref.png new file mode 100644 index 000000000..5b7d67d42 Binary files /dev/null and b/test/twin-svg12-ref.png differ diff --git a/test/twin.c b/test/twin.c new file mode 100644 index 000000000..ec004db16 --- /dev/null +++ b/test/twin.c @@ -0,0 +1,60 @@ +/* + * Copyright 2008 Chris Wilson + * + * 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 + * Chris Wilson not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior + * permission. Chris Wilson makes no representations about the + * suitability of this software for any purpose. It is provided "as + * is" without express or implied warranty. + * + * CHRIS WILSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS, IN NO EVENT SHALL CHRIS WILSON 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: Chris Wilson + */ + +#include "cairo-test.h" + +static cairo_test_draw_function_t draw; + +static const cairo_test_t test = { + "twin", + "Tests the internal font", + 128, 20, + draw +}; + +static cairo_test_status_t +draw (cairo_t *cr, int width, int height) +{ + cairo_set_source_rgb (cr, 1, 1, 1); + cairo_paint (cr); + cairo_set_source_rgb (cr, 0, 0, 0); + + cairo_select_font_face (cr, + "", + CAIRO_FONT_SLANT_NORMAL, + CAIRO_FONT_WEIGHT_NORMAL); + cairo_set_font_size (cr, 16); + + cairo_move_to (cr, 4, 14); + cairo_show_text (cr, "Is cairo's twin giza?"); + + return CAIRO_TEST_SUCCESS; +} + +int +main (void) +{ + return cairo_test (&test); +}