28 #include FT_INTERNAL_OBJECTS_H
29 #include FT_INTERNAL_DEBUG_H
30 #include FT_TRIGONOMETRY_H
40 #define FT_COMPONENT trace_outline
55 #define SCALED( x ) ( ( (x) << shift ) - delta )
75 if ( !outline || !func_interface )
78 shift = func_interface->shift;
79 delta = func_interface->delta;
82 for ( n = 0; n < outline->n_contours; n++ )
87 FT_TRACE5((
"FT_Outline_Decompose: Outline %d\n", n ));
89 last = outline->contours[
n];
92 limit = outline->points + last;
94 v_start = outline->points[
first];
98 v_last = outline->points[last];
104 point = outline->points +
first;
105 tags = outline->tags +
first;
110 goto Invalid_Outline;
127 v_start.
x = ( v_start.
x + v_last.
x ) / 2;
128 v_start.
y = ( v_start.
y + v_last.
y ) / 2;
137 v_start.
x / 64.0, v_start.
y / 64.0 ));
138 error = func_interface->move_to( &v_start, user );
142 while ( point < limit )
159 vec.
x / 64.0, vec.
y / 64.0 ));
160 error = func_interface->line_to( &vec, user );
187 " with control (%.2f, %.2f)\n",
188 vec.
x / 64.0, vec.
y / 64.0,
189 v_control.
x / 64.0, v_control.
y / 64.0 ));
190 error = func_interface->conic_to( &v_control, &vec, user );
197 goto Invalid_Outline;
199 v_middle.
x = ( v_control.
x + vec.
x ) / 2;
200 v_middle.
y = ( v_control.
y + vec.
y ) / 2;
203 " with control (%.2f, %.2f)\n",
204 v_middle.
x / 64.0, v_middle.
y / 64.0,
205 v_control.
x / 64.0, v_control.
y / 64.0 ));
206 error = func_interface->conic_to( &v_control, &v_middle, user );
215 " with control (%.2f, %.2f)\n",
216 v_start.
x / 64.0, v_start.
y / 64.0,
217 v_control.
x / 64.0, v_control.
y / 64.0 ));
218 error = func_interface->conic_to( &v_control, &v_start, user );
226 if ( point + 1 > limit ||
228 goto Invalid_Outline;
239 if ( point <= limit )
248 " with controls (%.2f, %.2f) and (%.2f, %.2f)\n",
249 vec.
x / 64.0, vec.
y / 64.0,
250 vec1.
x / 64.0, vec1.
y / 64.0,
251 vec2.
x / 64.0, vec2.
y / 64.0 ));
252 error = func_interface->cubic_to( &vec1, &vec2, &vec, user );
259 " with controls (%.2f, %.2f) and (%.2f, %.2f)\n",
260 v_start.
x / 64.0, v_start.
y / 64.0,
261 vec1.
x / 64.0, vec1.
y / 64.0,
262 vec2.
x / 64.0, vec2.
y / 64.0 ));
263 error = func_interface->cubic_to( &vec1, &vec2, &v_start, user );
271 v_start.
x / 64.0, v_start.
y / 64.0 ));
272 error = func_interface->line_to( &v_start, user );
281 FT_TRACE5((
"FT_Outline_Decompose: Done\n", n ));
285 FT_TRACE5((
"FT_Outline_Decompose: Error %d\n", error ));
302 if ( !anoutline || !memory )
313 anoutline->n_contours = (
FT_Short)numContours;
335 return FT_Err_Invalid_Library_Handle;
338 numContours, anoutline );
349 FT_Int n_points = outline->n_points;
350 FT_Int n_contours = outline->n_contours;
356 if ( n_points == 0 && n_contours == 0 )
360 if ( n_points <= 0 || n_contours <= 0 )
364 for ( n = 0; n < n_contours; n++ )
366 end = outline->contours[
n];
375 if ( end != n_points - 1 )
396 if ( !source || !target ||
397 source->n_points != target->n_points ||
398 source->n_contours != target->n_contours )
401 if ( source == target )
404 FT_ARRAY_COPY( target->points, source->points, source->n_points );
406 FT_ARRAY_COPY( target->tags, source->tags, source->n_points );
408 FT_ARRAY_COPY( target->contours, source->contours, source->n_contours );
412 target->flags = source->flags;
415 target->flags |= is_owner;
425 if ( memory && outline )
451 return FT_Err_Invalid_Library_Handle;
466 if ( outline && acbox )
468 if ( outline->n_points == 0 )
481 xMin = xMax = vec->
x;
482 yMin = yMax = vec->
y;
485 for ( ; vec <
limit; vec++ )
491 if ( x < xMin ) xMin =
x;
492 if ( x > xMax ) xMax =
x;
495 if ( y < yMin ) yMin =
y;
496 if ( y > yMax ) yMax =
y;
521 vec = outline->points;
523 for ( n = 0; n < outline->n_points; n++ )
546 for ( n = 0; n < outline->n_contours; n++ )
548 last = outline->contours[
n];
569 char*
p = outline->tags +
first;
570 char*
q = outline->tags + last;
605 return FT_Err_Invalid_Library_Handle;
607 if ( !outline || !params )
610 renderer = library->cur_renderer;
611 node = library->renderers.head;
613 params->source = (
void*)outline;
615 error = FT_Err_Cannot_Render_Glyph;
619 if ( !error ||
FT_ERROR_BASE( error ) != FT_Err_Cannot_Render_Glyph )
635 if ( !error && update && renderer )
678 if ( !vector || !matrix )
681 xz =
FT_MulFix( vector->x, matrix->xx ) +
684 yz =
FT_MulFix( vector->x, matrix->yx ) +
702 if ( !outline || !matrix )
705 vec = outline->points;
706 limit = vec + outline->n_points;
708 for ( ; vec <
limit; vec++ )
715 #define FT_OUTLINE_GET_CONTOUR( outline, c, first, last ) \
717 (first) = ( c > 0 ) ? (outline)->points + \
718 (outline)->contours[c - 1] + 1 \
719 : (outline)->points; \
720 (last) = (outline)->points + (outline)->contours[c]; \
741 FT_OUTLINE_GET_CONTOUR( outline, c, first, last );
743 for ( a = first; a <= last; a++ )
749 b = ( a == last ) ? first : a + 1;
751 intersect = ( a->
y - point->
y ) ^ ( b->
y - point->
y );
754 if ( intersect >= 0 )
756 if ( intersect == 0 && a->
y == point->
y )
758 if ( ( a->
x <= point->
x && b->
x >= point->
x ) ||
759 ( a->
x >= point->
x && b->
x <= point->
x ) )
766 x = a->
x + ( b->
x - a->
x ) * (point->
y - a->
y ) / ( b->
y - a->
y );
770 else if ( x == point->
x )
787 FT_OUTLINE_GET_CONTOUR( outline, c, first, last );
791 if ( i != c && ft_contour_has( outline, i, first ) )
796 for ( pt = first + 1; pt <= last; pt++ )
797 if ( !ft_contour_has( outline, i, pt ) )
813 ft_outline_get_orientation(
FT_Outline* outline )
822 for ( i = 0; i < outline->
n_contours; i++, first = last + 1 )
832 if ( last < first + 2 )
835 if ( ft_contour_enclosed( outline, i ) )
841 for ( point = first + 1; point <= last; point++ )
843 if ( point->
x < xmin )
857 prev = ( xmin_point ==
first ) ? last : xmin_point - 1;
858 next = ( xmin_point == last ) ? first : xmin_point + 1;
860 if (
FT_Atan2( prev->
x - xmin_point->
x, prev->
y - xmin_point->
y ) >
861 FT_Atan2( next->
x - xmin_point->
x, next->
y - xmin_point->
y ) )
868 else if ( orient != o )
886 FT_Vector v_prev, v_first, v_next, v_cur;
887 FT_Angle rotate, angle_in, angle_out;
902 if ( outline->n_contours )
913 points = outline->points;
916 for ( c = 0; c < outline->n_contours; c++ )
918 int last = outline->contours[
c];
921 v_first = points[
first];
922 v_prev = points[last];
925 for ( n = first; n <= last; n++ )
934 v_next = points[n + 1];
939 in.
x = v_cur.
x - v_prev.
x;
940 in.
y = v_cur.
y - v_prev.
y;
942 out.
x = v_next.
x - v_cur.
x;
943 out.
y = v_next.
y - v_cur.
y;
948 scale =
FT_Cos( angle_diff / 2 );
959 outline->points[
n].x = v_cur.
x + strength + in.
x;
960 outline->points[
n].y = v_cur.
y + strength + in.
y;
979 FT_Pos xmin_ymin = 32768L;
980 FT_Pos xmin_ymax = -32768L;
997 if ( !outline || outline->n_points <= 0 )
1005 first = outline->points;
1006 for ( contour = outline->contours;
1007 contour < outline->contours + outline->n_contours;
1008 contour++, first = last + 1 )
1010 FT_Pos contour_xmin = 32768L;
1011 FT_Pos contour_xmax = -32768L;
1012 FT_Pos contour_ymin = 32768L;
1013 FT_Pos contour_ymax = -32768L;
1016 last = outline->points + *contour;
1019 if ( last < first + 2 )
1022 for ( point = first; point <= last; ++point )
1024 if ( point->
x < contour_xmin )
1025 contour_xmin = point->
x;
1027 if ( point->
x > contour_xmax )
1028 contour_xmax = point->
x;
1030 if ( point->
y < contour_ymin )
1031 contour_ymin = point->
y;
1033 if ( point->
y > contour_ymax )
1034 contour_ymax = point->
y;
1037 if ( contour_xmin < xmin &&
1038 contour_xmin != contour_xmax &&
1039 contour_ymin != contour_ymax )
1041 xmin = contour_xmin;
1042 xmin_ymin = contour_ymin;
1043 xmin_ymax = contour_ymax;
1049 if ( xmin == 32768L )
1052 ray_y[0] = ( xmin_ymin * 3 + xmin_ymax ) >> 2;
1053 ray_y[1] = ( xmin_ymin + xmin_ymax ) >> 1;
1054 ray_y[2] = ( xmin_ymin + xmin_ymax * 3 ) >> 2;
1056 for ( i = 0; i < 3; i++ )
1070 left1 = left2 = right1 = right2 =
NULL;
1073 for ( point = xmin_first; point <= xmin_last; prev = point, ++point )
1078 if ( point->
y == ray_y[i] || prev->
y == ray_y[i] )
1084 if ( ( point->
y < ray_y[i] && prev->
y < ray_y[i] ) ||
1085 ( point->
y > ray_y[
i] && prev->
y > ray_y[
i] ) )
1090 point->
y - prev->
y ) + prev->
x;
1092 if ( tmp_x < left_x )
1099 if ( tmp_x > right_x )
1107 if ( left1 && right1 )
1109 if ( left1->
y < left2->
y && right1->
y > right2->
y )
1111 else if ( left1->
y > left2->
y && right1->
y < right2->
y )
1119 ( result[0] == result[1] || result[0] == result[2] ) )
FT_DivFix(FT_Long a, FT_Long b)
FT_Raster_Render_Func raster_render
FT_Outline_Render(FT_Library library, FT_Outline *outline, FT_Raster_Params *params)
FT_BEGIN_HEADER typedef signed long FT_Pos
#define FT_CURVE_TAG_CUBIC
#define FT_ARRAY_COPY(dest, source, count)
return FT_Err_Invalid_Argument
enum FT_Orientation_ FT_Orientation
FT_Outline_Embolden(FT_Outline *outline, FT_Pos strength)
#define FT_RASTER_FLAG_AA
FT_Outline_Get_Orientation(FT_Outline *outline)
GLboolean GLboolean GLboolean GLboolean a
FT_Outline_Reverse(FT_Outline *outline)
return Display return Display Bool Bool int d
FT_Outline_Get_Bitmap(FT_Library library, FT_Outline *outline, const FT_Bitmap *abitmap)
FT_Lookup_Renderer(FT_Library library, FT_Glyph_Format format, FT_ListNode *node)
FT_BEGIN_HEADER typedef unsigned char FT_Bool
FT_Outline_Copy(const FT_Outline *source, FT_Outline *target)
FT_Outline_New_Internal(FT_Memory memory, FT_UInt numPoints, FT_Int numContours, FT_Outline *anoutline)
EGLContext EGLenum target
FT_Outline_Get_CBox(const FT_Outline *outline, FT_BBox *acbox)
FT_Vector_From_Polar(FT_Vector *vec, FT_Fixed length, FT_Angle angle)
FT_Outline_Transform(const FT_Outline *outline, const FT_Matrix *matrix)
FT_Outline_New(FT_Library library, FT_UInt numPoints, FT_Int numContours, FT_Outline *anoutline)
FT_Atan2(FT_Fixed x, FT_Fixed y)
FT_MulDiv(FT_Long a, FT_Long b, FT_Long c)
FT_Outline_Done(FT_Library library, FT_Outline *outline)
FT_BEGIN_HEADER typedef FT_Fixed FT_Angle
FT_BEGIN_HEADER FT_Outline_Decompose(FT_Outline *outline, const FT_Outline_Funcs *func_interface, void *user)
GLenum GLenum GLenum GLenum GLenum scale
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
FT_Outline_Done_Internal(FT_Memory memory, FT_Outline *outline)
#define FT_NEW_ARRAY(ptr, count)
EGLSurface EGLint EGLint y
FT_MulFix(FT_Long a, FT_Long b)
static const FT_Outline null_outline
FT_Outline_Check(FT_Outline *outline)
FT_Vector_Transform(FT_Vector *vec, const FT_Matrix *matrix)
void swap(Zeni::String &lhs, Zeni::String &rhs)
FT_Angle_Diff(FT_Angle angle1, FT_Angle angle2)
GLdouble GLdouble GLdouble GLdouble q
#define FT_TRACE5(varformat)
GLdouble GLdouble GLdouble b
FT_Outline_Translate(const FT_Outline *outline, FT_Pos xOffset, FT_Pos yOffset)
GLuint GLdouble GLdouble GLint GLint const GLdouble * points
#define FT_CURVE_TAG_CONIC
#define FT_CURVE_TAG(flag)
GLsizei GLsizei GLchar * source
return FT_Err_Invalid_Outline
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)