/[freetype]/freetype2/src/base/ftoutln.c
ViewVC logotype

Diff of /freetype2/src/base/ftoutln.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.61 by wl, Fri May 20 21:52:19 2005 UTC revision 1.62 by wl, Wed May 25 05:51:01 2005 UTC
# Line 670  Line 670 
670    
671    /* documentation is in ftoutln.h */    /* documentation is in ftoutln.h */
672    
673      FT_EXPORT_DEF( FT_Error )
674      FT_Outline_Embolden( FT_Outline*  outline,
675                           FT_Pos       strength )
676      {
677        FT_Vector*  points;
678        FT_Vector   v_prev, v_first, v_next, v_cur;
679        FT_Angle    rotate, angle_in, angle_out;
680        FT_Int      c, n, first;
681    
682    
683        if ( !outline )
684          return FT_Err_Invalid_Argument;
685    
686        if ( strength == 0 )
687          return FT_Err_Ok;
688    
689        if ( FT_Outline_Get_Orientation( outline ) == FT_ORIENTATION_TRUETYPE )
690          rotate = -FT_ANGLE_PI2;
691        else
692          rotate = FT_ANGLE_PI2;
693    
694        points = outline->points;
695    
696        first = 0;
697        for ( c = 0; c < outline->n_contours; c++ )
698        {
699          int  last = outline->contours[c];
700    
701    
702          v_first = points[first];
703          v_prev  = points[last];
704          v_cur   = v_first;
705    
706          for ( n = first; n <= last; n++ )
707          {
708            FT_Vector  in, out;
709            FT_Angle   angle_diff;
710            FT_Pos     d;
711            FT_Fixed   scale;
712    
713    
714            if ( n < last )
715              v_next = points[n + 1];
716            else
717              v_next = v_first;
718    
719            /* compute the in and out vectors */
720            in.x = v_cur.x - v_prev.x;
721            in.y = v_cur.y - v_prev.y;
722    
723            out.x = v_next.x - v_cur.x;
724            out.y = v_next.y - v_cur.y;
725    
726            angle_in   = FT_Atan2( in.x, in.y );
727            angle_out  = FT_Atan2( out.x, out.y );
728            angle_diff = FT_Angle_Diff( angle_in, angle_out );
729            scale      = FT_Cos( angle_diff / 2 );
730    
731            if ( scale < 0x4000L && scale > -0x4000L )
732              in.x = in.y = 0;
733            else
734            {
735              d = FT_DivFix( strength, scale );
736    
737              FT_Vector_From_Polar( &in, d, angle_in + angle_diff / 2 - rotate );
738            }
739    
740            outline->points[n].x = v_cur.x + strength + in.x;
741            outline->points[n].y = v_cur.y + strength + in.y;
742    
743            v_prev = v_cur;
744            v_cur  = v_next;
745          }
746    
747          first = last + 1;
748        }
749    
750        return FT_Err_Ok;
751      }
752    
753    
754      /* documentation is in ftoutln.h */
755    
756    FT_EXPORT_DEF( FT_Orientation )    FT_EXPORT_DEF( FT_Orientation )
757    FT_Outline_Get_Orientation( FT_Outline*  outline )    FT_Outline_Get_Orientation( FT_Outline*  outline )
758    {    {

Legend:
Removed from v.1.61  
changed lines
  Added in v.1.62

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26