[cairo-commit] perf/cairo-perf.c perf/cairo-perf.h perf/Makefile.am perf/twin.c src/cairo-font-face.c src/cairoint.h test/.gitignore test/Makefile.am test/twin.c test/twin-ps2-ref.png test/twin-ps3-ref.png test/twin-ref.png test/twin-svg11-ref.png test/twin-svg12-ref.png

Chris Wilson ickle at kemper.freedesktop.org
Thu Oct 30 12:22:26 PDT 2008


 perf/Makefile.am        |    1 
 perf/cairo-perf.c       |    1 
 perf/cairo-perf.h       |    1 
 perf/twin.c             |   50 ++++++++++++++++++++++++++++++++++++++++
 src/cairo-font-face.c   |    6 +++-
 src/cairoint.h          |    1 
 test/.gitignore         |    1 
 test/Makefile.am        |    6 ++++
 test/twin-ps2-ref.png   |binary
 test/twin-ps3-ref.png   |binary
 test/twin-ref.png       |binary
 test/twin-svg11-ref.png |binary
 test/twin-svg12-ref.png |binary
 test/twin.c             |   60 ++++++++++++++++++++++++++++++++++++++++++++++++
 14 files changed, 125 insertions(+), 2 deletions(-)

New commits:
commit 4f2f46ef1bd793a712df045178b3d00d027e3ba6
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Oct 30 19:14:07 2008 +0000

    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.

diff --git a/perf/Makefile.am b/perf/Makefile.am
index 3ac13a6..daec8e4 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 613d15c..a6d59a5 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 57fe85f..0cedb69 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 0000000..adedb25
--- /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 30c8d9f..6cea395 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 2810348..f94e682 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 8da34a0..675315a 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 887bd73..026ce9a 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 0000000..a58dc5b
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 0000000..a58dc5b
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 0000000..f2a5636
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 0000000..5b7d67d
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 0000000..5b7d67d
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 0000000..ec004db
--- /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 at 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);
+}


More information about the cairo-commit mailing list