freetype-devel
[Top][All Lists]

[ft-devel] FT_MAX_CURVE_DEVIATION vs ONE_PIXEL cont'd

 From: Алексей Подтележников Subject: [ft-devel] FT_MAX_CURVE_DEVIATION vs ONE_PIXEL cont'd Date: Sat, 16 Oct 2010 23:41:15 -0400

```Werner, Graham

It turns out that since 2.4.3 the cubic deviations have been estimated
*after* UPSCALE, whereas conic ones have been evaluated *before*
UPSCALE. This was probably the original sin that led to the misuse of
FT_MAX_CURVE_DEVIATION that we've just fixed in "cubic".
Let's fix the original sin now.

Frankly, I would just adapt the cubic approach to conic splines too.
The current conic approach is just not very good... This  will come a
little later.

diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index 4477638..8f93392 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -877,40 +877,35 @@ typedef ptrdiff_t  FT_PtrDist;
FT_Vector*  arc;

-    dx = DOWNSCALE( ras.x ) + to->x - ( control->x << 1 );
-    if ( dx < 0 )
-      dx = -dx;
-    dy = DOWNSCALE( ras.y ) + to->y - ( control->y << 1 );
-    if ( dy < 0 )
-      dy = -dy;
+    arc      = ras.bez_stack;
+    arc[0].x = UPSCALE( to->x );
+    arc[0].y = UPSCALE( to->y );
+    arc[1].x = UPSCALE( control->x );
+    arc[1].y = UPSCALE( control->y );
+    arc[2].x = ras.x;
+    arc[2].y = ras.y;
+
+    dx = FT_ABS( arc[2].x + arc[0].x - 2 * arc[1].x );
+    dy = FT_ABS( arc[2].y + arc[0].y - 2 * arc[1].y );
if ( dx < dy )
dx = dy;

-    if ( dx <= ONE_PIXEL / 8 )
+    if ( dx <= ONE_PIXEL / 4 )
{
-      gray_render_line( RAS_VAR_ UPSCALE( to->x ), UPSCALE( to->y ) );
+      gray_render_line( RAS_VAR_ arc[0].x, arc[0].y );
return;
}

-    level = 1;
-    dx /= ONE_PIXEL / 8;
-    while ( dx > 1 )
+    level = 0;
+    while ( dx > ONE_PIXEL / 4 )
{
dx >>= 2;
level++;
}

-    arc       = ras.bez_stack;
levels    = ras.lev_stack;
-    top       = 0;
levels[0] = level;
-
-    arc[0].x = UPSCALE( to->x );
-    arc[0].y = UPSCALE( to->y );
-    arc[1].x = UPSCALE( control->x );
-    arc[1].y = UPSCALE( control->y );
-    arc[2].x = ras.x;
-    arc[2].y = ras.y;
+    top       = 0;

while ( top >= 0 )
{

```