[cairo] [PATCH] test: Always use DejaVu Sans as default font

Andrea Canciani ranma42 at gmail.com
Wed Jul 1 03:00:49 PDT 2015


This makes the results of the test suite more stable across different
environments, because it does not rely anymore on
CAIRO_FONT_FAMILY_DEFAULT (which on Windows is "Arial", on Mac
"Helvetica").

This change should not affect Linux environments, assuming that the
default font is already set to "DejaVu Sans".
---
 test/cairo-test.c        | 4 ++++
 test/clip-zero.c         | 2 +-
 test/pthread-show-text.c | 4 ++--
 test/show-glyphs-many.c  | 2 +-
 test/text-cache-crash.c  | 4 ++--
 test/user-font-proxy.c   | 2 +-
 6 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/test/cairo-test.c b/test/cairo-test.c
index a351b01..6f8cb79 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -915,6 +915,10 @@ REPEAT:
     cairo_paint (cr);
     cairo_restore (cr);
 
+    cairo_select_font_face (cr, CAIRO_TEST_FONT_FAMILY " Sans",
+			    CAIRO_FONT_SLANT_NORMAL,
+			    CAIRO_FONT_WEIGHT_NORMAL);
+    
     /* Set all components of font_options to avoid backend differences
      * and reduce number of needed reference images. */
     font_options = cairo_font_options_create ();
diff --git a/test/clip-zero.c b/test/clip-zero.c
index 5afd1b5..302b2b1 100644
--- a/test/clip-zero.c
+++ b/test/clip-zero.c
@@ -46,7 +46,7 @@ draw (cairo_t *cr, int width, int height)
     cairo_stroke_preserve (cr);
     cairo_paint (cr);
 
-    cairo_select_font_face (cr, "sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
+    cairo_select_font_face (cr, CAIRO_TEST_FONT_FAMILY " Sans", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
     cairo_show_text (cr, "ABC");
 
     cairo_mask (cr, cairo_get_source (cr));
diff --git a/test/pthread-show-text.c b/test/pthread-show-text.c
index 0e070b7..0f076cb 100644
--- a/test/pthread-show-text.c
+++ b/test/pthread-show-text.c
@@ -63,7 +63,7 @@ draw_thread (void *arg)
     cairo_paint (cr);
     cairo_set_source_rgb (cr, 0, 0, 0);
 
-    cairo_select_font_face (cr, "serif",
+    cairo_select_font_face (cr, CAIRO_TEST_FONT_FAMILY " Serif",
 			    CAIRO_FONT_SLANT_NORMAL,
 			    CAIRO_FONT_WEIGHT_NORMAL);
     cairo_set_font_size (cr, NUM_ITERATIONS);
@@ -74,7 +74,7 @@ draw_thread (void *arg)
     for (i = 0; i < NUM_ITERATIONS; i++) {
 	char buf[2];
 
-        cairo_select_font_face (cr, "serif",
+	cairo_select_font_face (cr, CAIRO_TEST_FONT_FAMILY " Serif",
 				CAIRO_FONT_SLANT_NORMAL,
 				CAIRO_FONT_WEIGHT_NORMAL);
 	cairo_set_font_size (cr, i);
diff --git a/test/show-glyphs-many.c b/test/show-glyphs-many.c
index f689fe0..e16282c 100644
--- a/test/show-glyphs-many.c
+++ b/test/show-glyphs-many.c
@@ -126,7 +126,7 @@ draw (cairo_t *cr, int width, int height)
     cairo_set_source_rgb (cr, 1, 1, 1);
     cairo_paint (cr);
 
-    cairo_select_font_face (cr, "Sans",
+    cairo_select_font_face (cr, CAIRO_TEST_FONT_FAMILY " Sans",
 			    CAIRO_FONT_SLANT_NORMAL,
 			    CAIRO_FONT_WEIGHT_NORMAL);
     cairo_set_font_size (cr, TEXT_SIZE);
diff --git a/test/text-cache-crash.c b/test/text-cache-crash.c
index 4786af4..27fe8cb 100644
--- a/test/text-cache-crash.c
+++ b/test/text-cache-crash.c
@@ -66,11 +66,11 @@ static cairo_test_status_t
 draw (cairo_t *cr, int width, int height)
 {
     /* Once there was a bug that choked when selecting the same font twice. */
-    cairo_select_font_face (cr, "sans",
+    cairo_select_font_face (cr, CAIRO_TEST_FONT_FAMILY " Sans",
 			    CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
     cairo_set_font_size (cr, 40.0);
 
-    cairo_select_font_face (cr, "sans",
+    cairo_select_font_face (cr, CAIRO_TEST_FONT_FAMILY " Sans",
 			    CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
     cairo_set_font_size (cr, 40.0);
     cairo_move_to (cr, 10, 50);
diff --git a/test/user-font-proxy.c b/test/user-font-proxy.c
index 6a39d8e..e4063f0 100644
--- a/test/user-font-proxy.c
+++ b/test/user-font-proxy.c
@@ -127,7 +127,7 @@ _user_font_face_create (cairo_font_face_t **out)
     /* This also happens to be default font face on cairo_t, so does
      * not make much sense here.  For demonstration only.
      */
-    fallback_font_face = cairo_toy_font_face_create ("",
+    fallback_font_face = cairo_toy_font_face_create (CAIRO_TEST_FONT_FAMILY " Sans",
 						     CAIRO_FONT_SLANT_NORMAL,
 						     CAIRO_FONT_WEIGHT_NORMAL);
 
-- 
2.3.2 (Apple Git-55)



More information about the cairo mailing list