From a33de30073bfa0ee1abba186dba9fa52cf0aa23a Mon Sep 17 00:00:00 2001 From: marha Date: Fri, 15 Jun 2012 14:04:46 +0200 Subject: Updated to following packages: freetype-2.4.10 libXaw-1.0.11 openssl-1.0.1c --- freetype/src/base/ftbitmap.c | 2 +- freetype/src/base/ftoutln.c | 224 +++++++++++++------------------------------ freetype/src/base/ftpic.c | 12 +-- freetype/src/base/ftsynth.c | 23 ++--- 4 files changed, 79 insertions(+), 182 deletions(-) (limited to 'freetype/src/base') diff --git a/freetype/src/base/ftbitmap.c b/freetype/src/base/ftbitmap.c index 15c9d6559..84fa32275 100644 --- a/freetype/src/base/ftbitmap.c +++ b/freetype/src/base/ftbitmap.c @@ -231,7 +231,7 @@ if ( ( ( FT_PIX_ROUND( xStrength ) >> 6 ) > FT_INT_MAX ) || ( ( FT_PIX_ROUND( yStrength ) >> 6 ) > FT_INT_MAX ) ) return FT_Err_Invalid_Argument; - + xstr = (FT_Int)FT_PIX_ROUND( xStrength ) >> 6; ystr = (FT_Int)FT_PIX_ROUND( yStrength ) >> 6; diff --git a/freetype/src/base/ftoutln.c b/freetype/src/base/ftoutln.c index 9ae276d08..76e2b04a1 100644 --- a/freetype/src/base/ftoutln.c +++ b/freetype/src/base/ftoutln.c @@ -881,10 +881,20 @@ FT_EXPORT_DEF( FT_Error ) FT_Outline_Embolden( FT_Outline* outline, FT_Pos strength ) + { + return FT_Outline_EmboldenXY( outline, strength, strength ); + } + + + /* documentation is in ftoutln.h */ + + FT_EXPORT_DEF( FT_Error ) + FT_Outline_EmboldenXY( FT_Outline* outline, + FT_Pos xstrength, + FT_Pos ystrength ) { FT_Vector* points; FT_Vector v_prev, v_first, v_next, v_cur; - FT_Angle rotate, angle_in, angle_out; FT_Int c, n, first; FT_Int orientation; @@ -892,8 +902,9 @@ if ( !outline ) return FT_Err_Invalid_Argument; - strength /= 2; - if ( strength == 0 ) + xstrength /= 2; + ystrength /= 2; + if ( xstrength == 0 && ystrength == 0 ) return FT_Err_Ok; orientation = FT_Outline_Get_Orientation( outline ); @@ -905,62 +916,63 @@ return FT_Err_Ok; } - if ( orientation == FT_ORIENTATION_TRUETYPE ) - rotate = -FT_ANGLE_PI2; - else - rotate = FT_ANGLE_PI2; - points = outline->points; first = 0; for ( c = 0; c < outline->n_contours; c++ ) { - int last = outline->contours[c]; + FT_Vector in, out, shift; + FT_Fixed l_in, l_out, d; + int last = outline->contours[c]; v_first = points[first]; v_prev = points[last]; v_cur = v_first; + /* compute the incoming vector and its length */ + in.x = v_cur.x - v_prev.x; + in.y = v_cur.y - v_prev.y; + l_in = FT_Vector_Length( &in ); + for ( n = first; n <= last; n++ ) { - FT_Vector in, out; - FT_Angle angle_diff; - FT_Pos d; - FT_Fixed scale; - - if ( n < last ) v_next = points[n + 1]; else v_next = v_first; - /* compute the in and out vectors */ - in.x = v_cur.x - v_prev.x; - in.y = v_cur.y - v_prev.y; - + /* compute the outgoing vector and its length */ out.x = v_next.x - v_cur.x; out.y = v_next.y - v_cur.y; + l_out = FT_Vector_Length( &out ); - angle_in = FT_Atan2( in.x, in.y ); - angle_out = FT_Atan2( out.x, out.y ); - angle_diff = FT_Angle_Diff( angle_in, angle_out ); - scale = FT_Cos( angle_diff / 2 ); + d = l_in * l_out + in.x * out.x + in.y * out.y; - if ( scale < 0x4000L && scale > -0x4000L ) - in.x = in.y = 0; - else + /* shift only if turn is less then ~160 degrees */ + if ( 16 * d > l_in * l_out ) { - d = FT_DivFix( strength, scale ); + /* shift components are rotated */ + shift.x = FT_DivFix( l_out * in.y + l_in * out.y, d ); + shift.y = FT_DivFix( l_out * in.x + l_in * out.x, d ); - FT_Vector_From_Polar( &in, d, angle_in + angle_diff / 2 - rotate ); + if ( orientation == FT_ORIENTATION_TRUETYPE ) + shift.x = -shift.x; + else + shift.y = -shift.y; + + shift.x = FT_MulFix( xstrength, shift.x ); + shift.y = FT_MulFix( ystrength, shift.y ); } + else + shift.x = shift.y = 0; - outline->points[n].x = v_cur.x + strength + in.x; - outline->points[n].y = v_cur.y + strength + in.y; + outline->points[n].x = v_cur.x + xstrength + shift.x; + outline->points[n].y = v_cur.y + ystrength + shift.y; - v_prev = v_cur; - v_cur = v_next; + in = out; + l_in = l_out; + v_cur = v_next; } first = last + 1; @@ -975,23 +987,10 @@ FT_EXPORT_DEF( FT_Orientation ) FT_Outline_Get_Orientation( FT_Outline* outline ) { - FT_Pos xmin = 32768L; - FT_Pos xmin_ymin = 32768L; - FT_Pos xmin_ymax = -32768L; - FT_Vector* xmin_first = NULL; - FT_Vector* xmin_last = NULL; - - short* contour; - - FT_Vector* first; - FT_Vector* last; - FT_Vector* prev; - FT_Vector* point; - - int i; - FT_Pos ray_y[3]; - FT_Orientation result[3] = - { FT_ORIENTATION_NONE, FT_ORIENTATION_NONE, FT_ORIENTATION_NONE }; + FT_Vector* points; + FT_Vector v_prev, v_cur; + FT_Int c, n, first; + FT_Pos area = 0; if ( !outline || outline->n_points <= 0 ) @@ -1002,127 +1001,32 @@ /* cubic or quadratic curves, this test deals with the polygon */ /* only which is spanned up by the control points. */ - first = outline->points; - for ( contour = outline->contours; - contour < outline->contours + outline->n_contours; - contour++, first = last + 1 ) - { - FT_Pos contour_xmin = 32768L; - FT_Pos contour_xmax = -32768L; - FT_Pos contour_ymin = 32768L; - FT_Pos contour_ymax = -32768L; - - - last = outline->points + *contour; - - /* skip degenerate contours */ - if ( last < first + 2 ) - continue; - - for ( point = first; point <= last; ++point ) - { - if ( point->x < contour_xmin ) - contour_xmin = point->x; - - if ( point->x > contour_xmax ) - contour_xmax = point->x; - - if ( point->y < contour_ymin ) - contour_ymin = point->y; - - if ( point->y > contour_ymax ) - contour_ymax = point->y; - } - - if ( contour_xmin < xmin && - contour_xmin != contour_xmax && - contour_ymin != contour_ymax ) - { - xmin = contour_xmin; - xmin_ymin = contour_ymin; - xmin_ymax = contour_ymax; - xmin_first = first; - xmin_last = last; - } - } - - if ( xmin == 32768L ) - return FT_ORIENTATION_TRUETYPE; - - ray_y[0] = ( xmin_ymin * 3 + xmin_ymax ) >> 2; - ray_y[1] = ( xmin_ymin + xmin_ymax ) >> 1; - ray_y[2] = ( xmin_ymin + xmin_ymax * 3 ) >> 2; + points = outline->points; - for ( i = 0; i < 3; i++ ) + first = 0; + for ( c = 0; c < outline->n_contours; c++ ) { - FT_Pos left_x; - FT_Pos right_x; - FT_Vector* left1; - FT_Vector* left2; - FT_Vector* right1; - FT_Vector* right2; - + FT_Int last = outline->contours[c]; - RedoRay: - left_x = 32768L; - right_x = -32768L; - left1 = left2 = right1 = right2 = NULL; + v_prev = points[last]; - prev = xmin_last; - for ( point = xmin_first; point <= xmin_last; prev = point, ++point ) + for ( n = first; n <= last; n++ ) { - FT_Pos tmp_x; - - - if ( point->y == ray_y[i] || prev->y == ray_y[i] ) - { - ray_y[i]++; - goto RedoRay; - } - - if ( ( point->y < ray_y[i] && prev->y < ray_y[i] ) || - ( point->y > ray_y[i] && prev->y > ray_y[i] ) ) - continue; - - tmp_x = FT_MulDiv( point->x - prev->x, - ray_y[i] - prev->y, - point->y - prev->y ) + prev->x; - - if ( tmp_x < left_x ) - { - left_x = tmp_x; - left1 = prev; - left2 = point; - } - - if ( tmp_x > right_x ) - { - right_x = tmp_x; - right1 = prev; - right2 = point; - } + v_cur = points[n]; + area += ( v_cur.y - v_prev.y ) * ( v_cur.x + v_prev.x ); + v_prev = v_cur; } - if ( left1 && right1 ) - { - if ( left1->y < left2->y && right1->y > right2->y ) - result[i] = FT_ORIENTATION_TRUETYPE; - else if ( left1->y > left2->y && right1->y < right2->y ) - result[i] = FT_ORIENTATION_POSTSCRIPT; - else - result[i] = FT_ORIENTATION_NONE; - } + first = last + 1; } - if ( result[0] != FT_ORIENTATION_NONE && - ( result[0] == result[1] || result[0] == result[2] ) ) - return result[0]; - - if ( result[1] != FT_ORIENTATION_NONE && result[1] == result[2] ) - return result[1]; - - return FT_ORIENTATION_TRUETYPE; + if ( area > 0 ) + return FT_ORIENTATION_POSTSCRIPT; + else if ( area < 0 ) + return FT_ORIENTATION_TRUETYPE; + else + return FT_ORIENTATION_NONE; } diff --git a/freetype/src/base/ftpic.c b/freetype/src/base/ftpic.c index d5271a972..b74e90dad 100644 --- a/freetype/src/base/ftpic.c +++ b/freetype/src/base/ftpic.c @@ -26,15 +26,15 @@ /* documentation is in ftpic.h */ FT_BASE_DEF( FT_Error ) - ft_pic_container_init( FT_Library library ) + ft_pic_container_init( FT_Library library ) { - FT_PIC_Container* pic_container = &library->pic_container; - FT_Error error = FT_Err_Ok; + FT_PIC_Container* pic_container = &library->pic_container; + FT_Error error = FT_Err_Ok; - FT_MEM_SET( pic_container, 0, sizeof(*pic_container) ); + FT_MEM_SET( pic_container, 0, sizeof ( *pic_container ) ); error = ft_base_pic_init( library ); - if(error) + if ( error ) return error; return FT_Err_Ok; @@ -43,7 +43,7 @@ /* Destroy the contents of the container. */ FT_BASE_DEF( void ) - ft_pic_container_destroy( FT_Library library ) + ft_pic_container_destroy( FT_Library library ) { ft_base_pic_free( library ); } diff --git a/freetype/src/base/ftsynth.c b/freetype/src/base/ftsynth.c index d4ec0da57..81e2ed246 100644 --- a/freetype/src/base/ftsynth.c +++ b/freetype/src/base/ftsynth.c @@ -4,7 +4,7 @@ /* */ /* FreeType synthesizing code for emboldening and slanting (body). */ /* */ -/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2010 by */ +/* Copyright 2000-2006, 2010, 2012 by */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* */ /* This file is part of the FreeType project, and may only be used, */ @@ -33,6 +33,7 @@ #undef FT_COMPONENT #define FT_COMPONENT trace_synth + /*************************************************************************/ /*************************************************************************/ /**** ****/ @@ -72,7 +73,7 @@ /*************************************************************************/ /*************************************************************************/ /**** ****/ - /**** EXPERIMENTAL EMBOLDENING/OUTLINING SUPPORT ****/ + /**** EXPERIMENTAL EMBOLDENING SUPPORT ****/ /**** ****/ /*************************************************************************/ /*************************************************************************/ @@ -101,12 +102,7 @@ if ( slot->format == FT_GLYPH_FORMAT_OUTLINE ) { /* ignore error */ - (void)FT_Outline_Embolden( &slot->outline, xstr ); - - /* this is more than enough for most glyphs; if you need accurate */ - /* values, you have to call FT_Outline_Get_CBox */ - xstr = xstr * 2; - ystr = xstr; + (void)FT_Outline_EmboldenXY( &slot->outline, xstr, ystr ); } else /* slot->format == FT_GLYPH_FORMAT_BITMAP */ { @@ -143,13 +139,10 @@ if ( slot->advance.y ) slot->advance.y += ystr; - slot->metrics.width += xstr; - slot->metrics.height += ystr; - slot->metrics.horiBearingY += ystr; - slot->metrics.horiAdvance += xstr; - slot->metrics.vertBearingX -= xstr / 2; - slot->metrics.vertBearingY += ystr; - slot->metrics.vertAdvance += ystr; + slot->metrics.width += xstr; + slot->metrics.height += ystr; + slot->metrics.horiAdvance += xstr; + slot->metrics.vertAdvance += ystr; /* XXX: 16-bit overflow case must be excluded before here */ if ( slot->format == FT_GLYPH_FORMAT_BITMAP ) -- cgit v1.2.3