diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2008-10-30 19:14:07 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2008-10-30 19:14:45 +0000 |
commit | 4f2f46ef1bd793a712df045178b3d00d027e3ba6 (patch) | |
tree | e06a996a27ac18cedbb7b84efa79bda181849ddb | |
parent | 52c3fc58b52c77282998f9ad75657a6bec5956f8 (diff) |
Restore the ability to choose the internal font.
Behdad wants to include the feature with 1.10, so we enable it as early as
possible in 1.9 dev cycle to generate as much feedback as possible.
The first change is to use "<cairo>" as being a name unlikely to clash
with any real font names.
This reverts commits:
a824d284be23793a5c48b9ae833dcb7b2d5fff80,
292233685534aed712dfd45e8ccf498b792ce496,
e0046aaf417a61da008dc6374871fa3687ba94ab,
f534bd549e1e2283735d1eabb60c015a5949a735.
-rw-r--r-- | perf/Makefile.am | 1 | ||||
-rw-r--r-- | perf/cairo-perf.c | 1 | ||||
-rw-r--r-- | perf/cairo-perf.h | 1 | ||||
-rw-r--r-- | perf/twin.c | 50 | ||||
-rw-r--r-- | src/cairo-font-face.c | 6 | ||||
-rw-r--r-- | src/cairoint.h | 1 | ||||
-rw-r--r-- | test/.gitignore | 1 | ||||
-rw-r--r-- | test/Makefile.am | 6 | ||||
-rw-r--r-- | test/twin-ps2-ref.png | bin | 0 -> 1167 bytes | |||
-rw-r--r-- | test/twin-ps3-ref.png | bin | 0 -> 1167 bytes | |||
-rw-r--r-- | test/twin-ref.png | bin | 0 -> 1836 bytes | |||
-rw-r--r-- | test/twin-svg11-ref.png | bin | 0 -> 1773 bytes | |||
-rw-r--r-- | test/twin-svg12-ref.png | bin | 0 -> 1773 bytes | |||
-rw-r--r-- | test/twin.c | 60 |
14 files changed, 125 insertions, 2 deletions
diff --git a/perf/Makefile.am b/perf/Makefile.am index 3ac13a6f..daec8e4e 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 613d15cf..a6d59a57 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 57fe85f1..0cedb691 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 00000000..adedb25f --- /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>", + 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 30c8d9fb..6cea3958 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 28103483..f94e6821 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 "<cairo>" #if CAIRO_HAS_WIN32_FONT diff --git a/test/.gitignore b/test/.gitignore index 8da34a00..675315a6 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 887bd73a..026ce9a5 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 Binary files differnew file mode 100644 index 00000000..a58dc5b6 --- /dev/null +++ b/test/twin-ps2-ref.png diff --git a/test/twin-ps3-ref.png b/test/twin-ps3-ref.png Binary files differnew file mode 100644 index 00000000..a58dc5b6 --- /dev/null +++ b/test/twin-ps3-ref.png diff --git a/test/twin-ref.png b/test/twin-ref.png Binary files differnew file mode 100644 index 00000000..f2a5636d --- /dev/null +++ b/test/twin-ref.png diff --git a/test/twin-svg11-ref.png b/test/twin-svg11-ref.png Binary files differnew file mode 100644 index 00000000..5b7d67d4 --- /dev/null +++ b/test/twin-svg11-ref.png diff --git a/test/twin-svg12-ref.png b/test/twin-svg12-ref.png Binary files differnew file mode 100644 index 00000000..5b7d67d4 --- /dev/null +++ b/test/twin-svg12-ref.png diff --git a/test/twin.c b/test/twin.c new file mode 100644 index 00000000..ec004db1 --- /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 <chris@chris-wilson.co.uk> + */ + +#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>", + 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); +} |