Bugzilla – Attachment 102025 Details for
Bug 158573
<Tradition Chinese Font are different.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
IDP Log In
|
Forgot Password
[patch]
A patch to implement a new algorithm using nonzero winding rule.
freetype-fix-contour-orientation-detection.diff (text/plain), 5.34 KB, created by
Zhe Su
on 2006-10-19 11:07:14 UTC
(
hide
)
Description:
A patch to implement a new algorithm using nonzero winding rule.
Filename:
MIME Type:
Creator:
Zhe Su
Created:
2006-10-19 11:07:14 UTC
Size:
5.34 KB
patch
obsolete
>--- src/base/ftoutln.c.old 2006-10-19 16:28:54.000000000 +0800 >+++ src/base/ftoutln.c 2006-10-19 18:54:44.000000000 +0800 >@@ -933,18 +933,23 @@ > FT_EXPORT_DEF( FT_Orientation ) > FT_Outline_Get_Orientation( FT_Outline* outline ) > { >- FT_Pos xmin = 32768L; >- FT_Vector* xmin_point = NULL; >- FT_Vector* xmin_first = NULL; >- FT_Vector* xmin_last = NULL; >+ 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* next; >+ FT_Vector* point; > >+ int i; >+ FT_Pos ray_y [3] = { 0, 0, 0 }; >+ int result [3]; > > if ( !outline || outline->n_points <= 0 ) > return FT_ORIENTATION_TRUETYPE; >@@ -954,11 +959,10 @@ > contour < outline->contours + outline->n_contours; > contour++, first = last + 1 ) > { >- FT_Vector* point; >- FT_Int on_curve; >- FT_Int on_curve_count = 0; >- FT_Pos tmp_xmin = 32768L; >- FT_Vector* tmp_xmin_point = NULL; >+ FT_Pos contour_xmin = 32768L; >+ FT_Pos contour_xmax = -32768L; >+ FT_Pos contour_ymin = 32768L; >+ FT_Pos contour_ymax = -32768L; > > last = outline->points + *contour; > >@@ -968,55 +972,99 @@ > > for ( point = first; point <= last; ++point ) > { >- /* Count on-curve points. If there are less than 3 on-curve */ >- /* points, just bypass this contour. */ >- on_curve = outline->tags[point - outline->points] & 1; >- on_curve_count += on_curve; >+ if ( point->x < contour_xmin ) >+ contour_xmin = point->x; > >- if ( point->x < tmp_xmin && on_curve ) >- { >- tmp_xmin = point->x; >- tmp_xmin_point = point; >- } >+ 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 ( on_curve_count > 2 && tmp_xmin < xmin ) >+ if ( contour_xmin < xmin && contour_xmin != contour_xmax && contour_ymin != contour_ymax) > { >- xmin = tmp_xmin; >- xmin_point = tmp_xmin_point; >+ xmin = contour_xmin; >+ xmin_ymin = contour_ymin; >+ xmin_ymax = contour_ymax; > xmin_first = first; > xmin_last = last; > } > } > >- if ( !xmin_point ) >+ if ( xmin == 32768L ) > return FT_ORIENTATION_TRUETYPE; > >- prev = ( xmin_point == xmin_first ) ? xmin_last : xmin_point - 1; >- next = ( xmin_point == xmin_last ) ? xmin_first : xmin_point + 1; >+ 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; > >- /* Skip off-curve points */ >- while ( ( outline->tags[prev - outline->points] & 1 ) == 0 ) >+ for ( i = 0; i < 3; ++i ) > { >- if ( prev == xmin_first ) >- prev = xmin_last; >- else >- --prev; >- } >+ FT_Pos left_is_x; >+ FT_Pos right_is_x; >+ FT_Vector* left_p1; >+ FT_Vector* left_p2; >+ FT_Vector* right_p1; >+ FT_Vector* right_p2; >+ >+ redo_ray: >+ left_is_x = 32768L; >+ right_is_x = -32768L; >+ left_p1 = left_p2 = right_p1 = right_p2 = NULL; > >- while ( ( outline->tags[next - outline->points] & 1 ) == 0 ) >- { >- if ( next == xmin_last ) >- next = xmin_first; >+ prev = xmin_last; >+ for ( point = xmin_first; point <= xmin_last; prev = point, ++point ) >+ { >+ FT_Pos tmp_x; >+ >+ if ( point->y == ray_y [i] || prev->y == ray_y [i]) >+ { >+ ++ ray_y [i]; >+ goto redo_ray; >+ } >+ else if ( (point->y < ray_y [i] && prev->y < ray_y [i]) || (point->y > ray_y [i] && prev->y > ray_y [i]) ) >+ continue; >+ >+ tmp_x = (point->x - prev->x) * (ray_y [i] - prev->y) / (point->y - prev->y) + prev->x; >+ >+ if ( tmp_x < left_is_x ) >+ { >+ left_is_x = tmp_x; >+ left_p1 = prev; >+ left_p2 = point; >+ } >+ >+ if ( tmp_x > right_is_x ) >+ { >+ right_is_x = tmp_x; >+ right_p1 = prev; >+ right_p2 = point; >+ } >+ } >+ >+ if ( left_p1 && left_p2 && right_p1 && right_p2 ) >+ { >+ if ( left_p1->y < left_p2->y && right_p1->y > right_p2->y ) >+ result [i] = FT_ORIENTATION_TRUETYPE; >+ else if ( left_p1->y > left_p2->y && right_p1->y < right_p2->y ) >+ result [i] = FT_ORIENTATION_POSTSCRIPT; >+ else >+ result [i] = FT_ORIENTATION_NONE; >+ } > else >- ++next; >+ result [i] = FT_ORIENTATION_NONE; > } > >- if ( FT_Atan2( prev->x - xmin_point->x, prev->y - xmin_point->y ) > >- FT_Atan2( next->x - xmin_point->x, next->y - xmin_point->y ) ) >- return FT_ORIENTATION_POSTSCRIPT; >- else >- return FT_ORIENTATION_TRUETYPE; >+ if ((result [0] == result [1] || result [0] == result [2]) && result [0] != FT_ORIENTATION_NONE) >+ return result [0]; >+ else if (result [1] == result [2] && result [1] != FT_ORIENTATION_NONE) >+ return result [1]; >+ >+ return FT_ORIENTATION_TRUETYPE; > } > >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
Attachments on
bug 158573
:
73283
|
73284
|
73306
|
73444
|
73445
|
73674
|
73726
|
101395
|
101396
|
101397
|
101492
|
101493
|
101863
|
101864
| 102025 |
102295