29 * The macro FT_COMPONENT is used in trace mode. It is an implicit
30 * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
31 * messages during execution.
32 */
33 #undef FT_COMPONENT
34 #define FT_COMPONENT outline
35
36
37 static
38 const FT_Outline null_outline = { 0, 0, NULL, NULL, NULL, 0 };
39
40
41 /* documentation is in ftoutln.h */
42
43 FT_EXPORT_DEF( FT_Error )
44 FT_Outline_Decompose( FT_Outline* outline,
45 const FT_Outline_Funcs* func_interface,
46 void* user )
47 {
48 #undef SCALED
49 #define SCALED( x ) ( ( (x) < 0 ? -( -(x) << shift ) \
50 : ( (x) << shift ) ) - delta )
51
52 FT_Vector v_last;
53 FT_Vector v_control;
54 FT_Vector v_start;
55
56 FT_Vector* point;
57 FT_Vector* limit;
58 char* tags;
59
60 FT_Error error;
61
62 FT_Int n; /* index of contour in outline */
63 FT_UInt first; /* index of first point in contour */
64 FT_Int tag; /* current point's state */
65
66 FT_Int shift;
67 FT_Pos delta;
68
69
70 if ( !outline )
603
604
605 if ( !library )
606 return FT_THROW( Invalid_Library_Handle );
607
608 if ( !outline )
609 return FT_THROW( Invalid_Outline );
610
611 if ( !params )
612 return FT_THROW( Invalid_Argument );
613
614 FT_Outline_Get_CBox( outline, &cbox );
615 if ( cbox.xMin < -0x1000000L || cbox.yMin < -0x1000000L ||
616 cbox.xMax > 0x1000000L || cbox.yMax > 0x1000000L )
617 return FT_THROW( Invalid_Outline );
618
619 renderer = library->cur_renderer;
620 node = library->renderers.head;
621
622 params->source = (void*)outline;
623
624 error = FT_ERR( Cannot_Render_Glyph );
625 while ( renderer )
626 {
627 error = renderer->raster_render( renderer->raster, params );
628 if ( !error || FT_ERR_NEQ( error, Cannot_Render_Glyph ) )
629 break;
630
631 /* FT_Err_Cannot_Render_Glyph is returned if the render mode */
632 /* is unsupported by the current renderer for this glyph image */
633 /* format */
634
635 /* now, look for another renderer that supports the same */
636 /* format */
637 renderer = FT_Lookup_Renderer( library, FT_GLYPH_FORMAT_OUTLINE,
638 &node );
639 }
640
641 return error;
642 }
|
29 * The macro FT_COMPONENT is used in trace mode. It is an implicit
30 * parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log
31 * messages during execution.
32 */
33 #undef FT_COMPONENT
34 #define FT_COMPONENT outline
35
36
37 static
38 const FT_Outline null_outline = { 0, 0, NULL, NULL, NULL, 0 };
39
40
41 /* documentation is in ftoutln.h */
42
43 FT_EXPORT_DEF( FT_Error )
44 FT_Outline_Decompose( FT_Outline* outline,
45 const FT_Outline_Funcs* func_interface,
46 void* user )
47 {
48 #undef SCALED
49 #define SCALED( x ) ( (x) * ( 1L << shift ) - delta )
50
51 FT_Vector v_last;
52 FT_Vector v_control;
53 FT_Vector v_start;
54
55 FT_Vector* point;
56 FT_Vector* limit;
57 char* tags;
58
59 FT_Error error;
60
61 FT_Int n; /* index of contour in outline */
62 FT_UInt first; /* index of first point in contour */
63 FT_Int tag; /* current point's state */
64
65 FT_Int shift;
66 FT_Pos delta;
67
68
69 if ( !outline )
602
603
604 if ( !library )
605 return FT_THROW( Invalid_Library_Handle );
606
607 if ( !outline )
608 return FT_THROW( Invalid_Outline );
609
610 if ( !params )
611 return FT_THROW( Invalid_Argument );
612
613 FT_Outline_Get_CBox( outline, &cbox );
614 if ( cbox.xMin < -0x1000000L || cbox.yMin < -0x1000000L ||
615 cbox.xMax > 0x1000000L || cbox.yMax > 0x1000000L )
616 return FT_THROW( Invalid_Outline );
617
618 renderer = library->cur_renderer;
619 node = library->renderers.head;
620
621 params->source = (void*)outline;
622
623 /* preset clip_box for direct mode */
624 if ( params->flags & FT_RASTER_FLAG_DIRECT &&
625 !( params->flags & FT_RASTER_FLAG_CLIP ) )
626 {
627 params->clip_box.xMin = cbox.xMin >> 6;
628 params->clip_box.yMin = cbox.yMin >> 6;
629 params->clip_box.xMax = ( cbox.xMax + 63 ) >> 6;
630 params->clip_box.yMax = ( cbox.yMax + 63 ) >> 6;
631 }
632
633 error = FT_ERR( Cannot_Render_Glyph );
634 while ( renderer )
635 {
636 error = renderer->raster_render( renderer->raster, params );
637 if ( !error || FT_ERR_NEQ( error, Cannot_Render_Glyph ) )
638 break;
639
640 /* FT_Err_Cannot_Render_Glyph is returned if the render mode */
641 /* is unsupported by the current renderer for this glyph image */
642 /* format */
643
644 /* now, look for another renderer that supports the same */
645 /* format */
646 renderer = FT_Lookup_Renderer( library, FT_GLYPH_FORMAT_OUTLINE,
647 &node );
648 }
649
650 return error;
651 }
|