28 #include FT_INTERNAL_OBJECTS_H 29 #include FT_INTERNAL_CALC_H 30 #include FT_INTERNAL_DEBUG_H 31 #include FT_TRIGONOMETRY_H 41 #define FT_COMPONENT trace_outline 45 const FT_Outline null_outline = { 0, 0, 0, 0, 0, 0 };
56 #define SCALED( x ) ( ( (x) << shift ) - delta ) 76 if ( !outline || !func_interface )
79 shift = func_interface->shift;
80 delta = func_interface->delta;
83 for (
n = 0;
n < outline->n_contours;
n++ )
88 FT_TRACE5((
"FT_Outline_Decompose: Outline %d\n",
n ));
90 last = outline->contours[
n];
93 limit = outline->points + last;
95 v_start = outline->points[
first];
99 v_last = outline->points[last];
105 point = outline->points +
first;
106 tags = outline->tags +
first;
111 goto Invalid_Outline;
128 v_start.
x = ( v_start.
x + v_last.
x ) / 2;
129 v_start.
y = ( v_start.
y + v_last.
y ) / 2;
138 v_start.
x / 64.0, v_start.
y / 64.0 ));
139 error = func_interface->move_to( &v_start, user );
143 while ( point < limit )
160 vec.
x / 64.0, vec.
y / 64.0 ));
161 error = func_interface->line_to( &vec, user );
188 " with control (%.2f, %.2f)\n",
189 vec.
x / 64.0, vec.
y / 64.0,
190 v_control.
x / 64.0, v_control.
y / 64.0 ));
191 error = func_interface->conic_to( &v_control, &vec, user );
198 goto Invalid_Outline;
200 v_middle.
x = ( v_control.
x + vec.
x ) / 2;
201 v_middle.
y = ( v_control.
y + vec.
y ) / 2;
204 " with control (%.2f, %.2f)\n",
205 v_middle.
x / 64.0, v_middle.
y / 64.0,
206 v_control.
x / 64.0, v_control.
y / 64.0 ));
207 error = func_interface->conic_to( &v_control, &v_middle, user );
216 " with control (%.2f, %.2f)\n",
217 v_start.
x / 64.0, v_start.
y / 64.0,
218 v_control.
x / 64.0, v_control.
y / 64.0 ));
219 error = func_interface->conic_to( &v_control, &v_start, user );
227 if ( point + 1 > limit ||
229 goto Invalid_Outline;
240 if ( point <= limit )
249 " with controls (%.2f, %.2f) and (%.2f, %.2f)\n",
250 vec.
x / 64.0, vec.
y / 64.0,
251 vec1.
x / 64.0, vec1.
y / 64.0,
252 vec2.
x / 64.0, vec2.
y / 64.0 ));
253 error = func_interface->cubic_to( &vec1, &vec2, &vec, user );
260 " with controls (%.2f, %.2f) and (%.2f, %.2f)\n",
261 v_start.
x / 64.0, v_start.
y / 64.0,
262 vec1.
x / 64.0, vec1.
y / 64.0,
263 vec2.
x / 64.0, vec2.
y / 64.0 ));
264 error = func_interface->cubic_to( &vec1, &vec2, &v_start, user );
272 v_start.
x / 64.0, v_start.
y / 64.0 ));
273 error = func_interface->line_to( &v_start, user );
282 FT_TRACE5((
"FT_Outline_Decompose: Done\n",
n ));
303 if ( !anoutline || !memory )
304 return FT_THROW( Invalid_Argument );
306 *anoutline = null_outline;
308 if ( numContours < 0 ||
309 (
FT_UInt)numContours > numPoints )
310 return FT_THROW( Invalid_Argument );
320 anoutline->n_points = (
FT_UShort)numPoints;
321 anoutline->n_contours = (
FT_Short)numContours;
343 return FT_THROW( Invalid_Library_Handle );
346 numContours, anoutline );
357 FT_Int n_points = outline->n_points;
358 FT_Int n_contours = outline->n_contours;
364 if ( n_points == 0 && n_contours == 0 )
368 if ( n_points <= 0 || n_contours <= 0 )
372 for ( n = 0; n < n_contours; n++ )
374 end = outline->contours[
n];
383 if ( end != n_points - 1 )
391 return FT_THROW( Invalid_Argument );
407 return FT_THROW( Invalid_Argument );
423 target->flags |= is_owner;
433 if ( memory && outline )
441 *outline = null_outline;
446 return FT_THROW( Invalid_Argument );
459 return FT_THROW( Invalid_Library_Handle );
474 if ( outline && acbox )
476 if ( outline->n_points == 0 )
486 FT_Vector* limit = vec + outline->n_points;
489 xMin = xMax = vec->
x;
490 yMin = yMax = vec->
y;
493 for ( ; vec <
limit; vec++ )
500 if ( x > xMax ) xMax =
x;
504 if ( y > yMax ) yMax =
y;
529 vec = outline->points;
531 for (
n = 0;
n < outline->n_points;
n++ )
554 for (
n = 0;
n < outline->n_contours;
n++ )
556 last = outline->contours[
n];
577 char*
p = outline->tags +
first;
578 char*
q = outline->tags + last;
613 return FT_THROW( Invalid_Library_Handle );
615 if ( !outline || !
params )
616 return FT_THROW( Invalid_Argument );
621 params->source = (
void*)outline;
643 if ( !
error && update && renderer )
661 return FT_THROW( Invalid_Argument );
710 if ( !outline || !
matrix )
713 vec = outline->points;
714 limit = vec + outline->n_points;
716 for ( ; vec <
limit; vec++ )
723 #define FT_OUTLINE_GET_CONTOUR( outline, c, first, last ) \ 725 (first) = ( c > 0 ) ? (outline)->points + \ 726 (outline)->contours[c - 1] + 1 \ 727 : (outline)->points; \ 728 (last) = (outline)->points + (outline)->contours[c]; \ 749 FT_OUTLINE_GET_CONTOUR( outline,
c, first, last );
751 for ( a = first; a <= last; a++ )
757 b = ( a == last ) ? first : a + 1;
759 intersect = ( a->
y - point->
y ) ^ ( b->
y - point->
y );
762 if ( intersect >= 0 )
764 if ( intersect == 0 && a->
y == point->
y )
766 if ( ( a->
x <= point->
x && b->
x >= point->
x ) ||
767 ( a->
x >= point->
x && b->
x <= point->
x ) )
774 x = a->
x + ( b->
x - a->
x ) * (point->
y - a->
y ) / ( b->
y - a->
y );
778 else if ( x == point->
x )
795 FT_OUTLINE_GET_CONTOUR( outline, c, first, last );
799 if ( i != c && ft_contour_has( outline, i, first ) )
804 for ( pt = first + 1; pt <= last; pt++ )
805 if ( !ft_contour_has( outline, i, pt ) )
821 ft_outline_get_orientation(
FT_Outline* outline )
830 for ( i = 0; i < outline->
n_contours; i++, first = last + 1 )
840 if ( last < first + 2 )
843 if ( ft_contour_enclosed( outline, i ) )
849 for ( point = first + 1; point <= last; point++ )
851 if ( point->
x < xmin )
865 prev = ( xmin_point ==
first ) ? last : xmin_point - 1;
866 next = ( xmin_point == last ) ? first : xmin_point + 1;
868 if (
FT_Atan2( prev->
x - xmin_point->
x, prev->
y - xmin_point->
y ) >
869 FT_Atan2( next->
x - xmin_point->
x, next->
y - xmin_point->
y ) )
876 else if ( orient != o )
905 FT_Vector v_prev, v_first, v_next, v_cur;
911 return FT_THROW( Invalid_Argument );
915 if ( xstrength == 0 && ystrength == 0 )
922 return FT_THROW( Invalid_Argument );
937 v_first = points[
first];
938 v_prev = points[last];
942 in.
x = v_cur.
x - v_prev.
x;
943 in.
y = v_cur.
y - v_prev.
y;
954 v_next = points[
n + 1];
959 out.
x = v_next.
x - v_cur.
x;
960 out.
y = v_next.
y - v_cur.
y;
977 shift.
x = in.
y + out.
y;
978 shift.
y = in.
x + out.
x;
990 l =
FT_MIN( l_in, l_out );
1005 shift.
x = shift.
y = 0;
1007 outline->
points[
n].
x = v_cur.
x + xstrength + shift.
x;
1008 outline->
points[
n].
y = v_cur.
y + ystrength + shift.
y;
1035 if ( !outline || outline->
n_points <= 0 )
1046 xshift =
FT_MAX( xshift, 0 );
1049 yshift =
FT_MAX( yshift, 0 );
1051 points = outline->
points;
1059 v_prev = points[last];
1064 area += ( ( v_cur.
y - v_prev.
y ) >> yshift ) *
1065 ( ( v_cur.
x + v_prev.
x ) >> xshift );
1074 else if ( area < 0 )
FT_DivFix(FT_Long a, FT_Long b)
FT_Raster_Render_Func raster_render
FT_BEGIN_HEADER typedef signed long FT_Pos
GLboolean GLboolean GLboolean GLboolean a
GLsizei const GLfloat * points
fvec2 vec2
Defined as: 'typedef fvec2 vec2'. See also VL_PIPELINE_PRECISION.
FT_Outline_Done(FT_Library library, FT_Outline *outline)
#define FT_CURVE_TAG_CUBIC
GLint GLint GLint GLint GLint GLint y
#define FT_ARRAY_COPY(dest, source, count)
GLdouble GLdouble GLdouble GLdouble q
enum FT_Orientation_ FT_Orientation
return FT_THROW(Missing_Property)
GLsizei GLsizei GLchar * source
FT_Outline_EmboldenXY(FT_Outline *outline, FT_Pos xstrength, FT_Pos ystrength)
#define FT_RASTER_FLAG_AA
GLint GLint GLint GLint GLint x
FT_Outline_Get_Bitmap(FT_Library library, FT_Outline *outline, const FT_Bitmap *abitmap)
GLboolean GLboolean GLboolean b
FT_Lookup_Renderer(FT_Library library, FT_Glyph_Format format, FT_ListNode *node)
FT_BEGIN_HEADER typedef unsigned char FT_Bool
FT_Outline_Reverse(FT_Outline *outline)
FT_Outline_Get_CBox(const FT_Outline *outline, FT_BBox *acbox)
#define FT_OUTLINE_POINTS_MAX
FT_Outline_Decompose(FT_Outline *outline, const FT_Outline_Funcs *func_interface, void *user)
FT_Outline_Embolden(FT_Outline *outline, FT_Pos strength)
FT_Outline_Done_Internal(FT_Memory memory, FT_Outline *outline)
FT_Atan2(FT_Fixed x, FT_Fixed y)
FT_MulDiv(FT_Long a, FT_Long b, FT_Long c)
FT_Outline_Copy(const FT_Outline *source, FT_Outline *target)
local int out(void *out_desc, unsigned char *buf, unsigned len)
FT_Vector_Transform(FT_Vector *vector, const FT_Matrix *matrix)
FT_Outline_New(FT_Library library, FT_UInt numPoints, FT_Int numContours, FT_Outline *anoutline)
FT_Outline_Transform(const FT_Outline *outline, const FT_Matrix *matrix)
FT_Outline_New_Internal(FT_Memory memory, FT_UInt numPoints, FT_Int numContours, FT_Outline *anoutline)
FT_Outline_Render(FT_Library library, FT_Outline *outline, FT_Raster_Params *params)
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
#define FT_NEW_ARRAY(ptr, count)
FT_MulFix(FT_Long a, FT_Long b)
FT_Outline_Translate(const FT_Outline *outline, FT_Pos xOffset, FT_Pos yOffset)
GLenum const GLfloat * params
FT_Outline_Check(FT_Outline *outline)
#define FT_TRACE5(varformat)
FT_Outline_Get_Orientation(FT_Outline *outline)
FT_Vector_Length(FT_Vector *vec)
#define FT_CURVE_TAG_CONIC
#define FT_CURVE_TAG(flag)
FT_Module_Constructor FT_GLYPH_FORMAT_OUTLINE
#define FT_OUTLINE_REVERSE_FILL
FT_Set_Renderer(FT_Library library, FT_Renderer renderer, FT_UInt num_params, FT_Parameter *parameters)