[cairo-commit] 3 commits - test/get-path-extents.c

Carl Worth cworth at kemper.freedesktop.org
Thu Feb 28 16:39:57 PST 2008


 test/get-path-extents.c |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

New commits:
commit e7e4a03dd387d264226105dc29c8541f0528fd2c
Author: Carl Worth <cworth at cworth.org>
Date:   Thu Feb 28 16:39:42 2008 -0800

    get-path-extents: Fix APPROX_EQUALS to round values on both sides of the comparison

diff --git a/test/get-path-extents.c b/test/get-path-extents.c
index de41a6b..4d1966b 100644
--- a/test/get-path-extents.c
+++ b/test/get-path-extents.c
@@ -78,8 +78,13 @@ check_extents (const char *message, cairo_t *cr, enum ExtentsType type,
         break;
     case APPROX_EQUALS:
         relation_string = "approx. equal";
-        if (floor (ext_x1+0.5) == x && floor (ext_y1+0.5) == y && floor (ext_x2+0.5) == x + width && floor (ext_y2+0.5) == y + height)
+        if (floor (ext_x1 + 0.5) == floor (x + 0.5) &&
+	    floor (ext_y1 + 0.5) == floor (y + 0.5) &&
+	    floor (ext_x2 + 0.5) == floor (x + width + 0.5) &&
+	    floor (ext_y2 + 0.5) == floor (y + height + 0.5))
+	{
             return 1;
+	}
         break;
     case CONTAINS:
         relation_string = "contain";
commit 602489b150e879bc5cab6b1ad37c107799bf05ae
Author: Carl Worth <cworth at cworth.org>
Date:   Thu Feb 28 16:33:51 2008 -0800

    get-path-extents: Use APPROX_EQUALS instead of EQUALS for text path tests
    
    This is done grudgingly due to freetype rounding the coordinates
    of the extents when hinting is enabled.

diff --git a/test/get-path-extents.c b/test/get-path-extents.c
index b856d2f..de41a6b 100644
--- a/test/get-path-extents.c
+++ b/test/get-path-extents.c
@@ -314,9 +314,15 @@ draw (cairo_t *cr, int width, int height)
     cairo_move_to (cr2, -extents.x_bearing, -extents.y_bearing);
     cairo_text_path (cr2, string);
     cairo_set_line_width (cr2, 2.0);
-    errors += !check_extents (phase, cr2, FILL, EQUALS, 0, 0, extents.width, extents.height);
-    errors += !check_extents (phase, cr2, STROKE, EQUALS, -1, -1, extents.width+2, extents.height+2);
-    errors += !check_extents (phase, cr2, PATH, EQUALS, 0, 0, extents.width, extents.height);
+    /* XXX: We'd like to be able to use EQUALS here, but currently
+     * when hinting is enabled freetype returns integer extents. See
+     * http://cairographics.org/todo */
+    errors += !check_extents (phase, cr2, FILL, APPROX_EQUALS,
+			      0, 0, extents.width, extents.height);
+    errors += !check_extents (phase, cr2, STROKE, APPROX_EQUALS,
+			      -1, -1, extents.width+2, extents.height+2);
+    errors += !check_extents (phase, cr2, PATH, APPROX_EQUALS,
+			      0, 0, extents.width, extents.height);
     cairo_new_path (cr2);
     cairo_restore (cr2);
 
commit 50a6fe1a2aa88e1f5ba40eda21142319f98f3d0d
Author: Carl Worth <cworth at cworth.org>
Date:   Thu Feb 28 16:32:55 2008 -0800

    Remove unnecessary cairo_set_tolerance call from get-path-extents test

diff --git a/test/get-path-extents.c b/test/get-path-extents.c
index 214596e..b856d2f 100644
--- a/test/get-path-extents.c
+++ b/test/get-path-extents.c
@@ -289,7 +289,6 @@ draw (cairo_t *cr, int width, int height)
 
     phase = "Text";
     cairo_save (cr2);
-    cairo_set_tolerance (cr2, 100.0);
     cairo_select_font_face (cr2, "Bitstream Vera Sans",
 			    CAIRO_FONT_SLANT_NORMAL,
 			    CAIRO_FONT_WEIGHT_NORMAL);


More information about the cairo-commit mailing list