[cairo-commit] cairo/test ft-font-create-for-ft-face.c,1.1,1.2

Carl Worth commit at pdx.freedesktop.org
Fri Jan 20 15:15:42 PST 2006


Committed by: cworth

Update of /cvs/cairo/cairo/test
In directory gabe:/tmp/cvs-serv14648/test

Modified Files:
	ft-font-create-for-ft-face.c 
Log Message:

2006-01-20  Carl Worth  <cworth at cworth.org>

        * test/ft-font-create-for-ft-face.c: (draw): Fix test to use
        fontconfig properly so that the test no longer fails. Fixes bug
        #4674. (Thnks to sunmoon1997 for the fix).


Index: ft-font-create-for-ft-face.c
===================================================================
RCS file: /cvs/cairo/cairo/test/ft-font-create-for-ft-face.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ft-font-create-for-ft-face.c	17 Aug 2005 16:51:09 -0000	1.1
+++ ft-font-create-for-ft-face.c	20 Jan 2006 23:15:40 -0000	1.2
@@ -35,7 +35,8 @@
 static cairo_test_status_t
 draw (cairo_t *cr, int width, int height)
 {
-    FcPattern *pattern;
+    FcPattern *pattern, *resolved;
+    FcResult result;
     cairo_font_face_t *font_face;
     cairo_scaled_font_t *scaled_font;
     cairo_font_options_t *font_options;
@@ -44,13 +45,24 @@
     FT_Face ft_face;
 
     /* We're trying here to get our hands on _some_ FT_Face but we do
-     * not at all care which one, so an empty pattern should work just
-     * fine. */
+     * not at all care which one. So we start with an empty pattern
+     * and do the minimal substitution on it in order to get a valid
+     * pattern. */
     pattern = FcPatternCreate ();
-    if (!pattern)
+    if (! pattern) {
+	cairo_test_log ("FcPatternCreate failed.\n");
+	return CAIRO_TEST_FAILURE;
+    }
+
+    FcConfigSubstitute (NULL, pattern, FcMatchPattern);
+    FcDefaultSubstitute (pattern);
+    resolved = FcFontMatch (NULL, pattern, &result);
+    if (! resolved) {
+	cairo_test_log ("FcFontMatch failed.\n");
 	return CAIRO_TEST_FAILURE;
+    }
 
-    font_face = cairo_ft_font_face_create_for_pattern (pattern);
+    font_face = cairo_ft_font_face_create_for_pattern (resolved);
 
     cairo_matrix_init_identity (&font_matrix);
 
@@ -68,8 +80,10 @@
     cairo_font_options_destroy (font_options);
     cairo_font_face_destroy (font_face);
     FcPatternDestroy (pattern);
+    FcPatternDestroy (resolved);
 
     if (!ft_face) {
+	cairo_test_log ("Failed to get an ft_face with cairo_ft_scaled_font_lock_face\n");
 	cairo_scaled_font_destroy (scaled_font);
 	return CAIRO_TEST_FAILURE;
     }



More information about the cairo-commit mailing list