20#include FT_INTERNAL_OBJECTS_H
21#include FT_INTERNAL_DEBUG_H
22#include FT_INTERNAL_CALC_H
29#define FT_COMPONENT trace_pshalgo
34 PSH_HintFunc ps_debug_hint_func =
NULL;
39#define COMPUTE_INFLEXS
56 return hint1->org_pos + hint1->org_len >= hint2->org_pos &&
57 hint2->org_pos + hint2->org_len >= hint1->org_pos;
104 FT_TRACE0((
"psh_hint_table_record: invalid hint index %d\n",
idx ));
129 hint->parent = hint2;
138 FT_TRACE0((
"psh_hint_table_record: too many sorted hints! BUG!\n" ));
193 table->num_hints = 0;
194 table->num_zones = 0;
219 table->hint_masks = hint_masks;
231 FT_TRACE0((
"psh_hint_table_init: missing/incorrect hint masks\n" ));
279 for ( count2 =
count; count2 > 0; count2--,
sort++ )
283 FT_TRACE0((
"psh_hint_table_activate_mask:"
284 " found overlapping hints\n" ))
293 if ( count < table->max_hints )
296 FT_TRACE0((
"psh_hint_tableactivate_mask:"
297 " too many active hints\n" ));
319 for ( i2 = i1 - 1; i2 >= 0; i2-- )
323 if ( hint2->org_pos < hint1->org_pos )
326 sort[i2 + 1] = hint2;
367 delta = (
len & 63 );
373 else if ( delta < 32 )
376 else if ( delta < 54 )
413 if ( ps_debug_hint_func )
414 ps_debug_hint_func(
hint, dimension );
480 if ( dimension == 1 )
486 switch (
align.align )
490 hint->cur_pos =
align.align_top - fit_len;
511 FT_Pos par_org_center, par_cur_center;
512 FT_Pos cur_org_center, cur_delta;
522 par_org_center =
parent->org_pos + (
parent->org_len >> 1 );
523 par_cur_center =
parent->cur_pos + (
parent->cur_len >> 1 );
524 cur_org_center =
hint->org_pos + (
hint->org_len >> 1 );
527 pos = par_cur_center + cur_delta - (
len >> 1 );
531 hint->cur_len = fit_len;
583 left_disp = -left_disp;
584 if ( right_disp < 0 )
585 right_disp = -right_disp;
586 if ( left_disp <= right_disp )
620 switch (
align.align )
651 if ( ps_debug_hint_func )
652 ps_debug_hint_func(
hint, dimension );
698 hint->cur_len = fit_len;
704 if ( dimension == 1 )
710 switch (
align.align )
714 hint->cur_pos =
align.align_top - fit_len;
735 FT_Pos par_org_center, par_cur_center;
736 FT_Pos cur_org_center, cur_delta;
741 psh_hint_align_light(
parent, globals, dimension, glyph );
743 par_org_center =
parent->org_pos + (
parent->org_len / 2 );
744 par_cur_center =
parent->cur_pos + (
parent->cur_len / 2 );
745 cur_org_center =
hint->org_pos + (
hint->org_len / 2 );
748 pos = par_cur_center + cur_delta - (
len >> 1 );
759 if ( (
pos +
len + 63 ) / 64 !=
pos / 64 + 1 )
793 if ( (
len / 64 ) & 1 )
813 else if ( frac_len < 48 )
836 if ( ps_debug_hint_func )
837 ps_debug_hint_func(
hint, dimension );
861 if ( ps_debug_no_vert_hints && dimension == 0 )
863 ps_simple_scale(
table,
scale, delta, dimension );
867 if ( ps_debug_no_horz_hints && dimension == 1 )
869 ps_simple_scale(
table,
scale, delta, dimension );
896#include FT_CONFIG_STANDARD_LIBRARY_H
901 printf(
"zone [scale,delta,min,max] = [%.5f,%.2f,%d,%d]\n",
902 zone->scale / 65536.0,
919#define psh_corner_is_flat ft_corner_is_flat
920#define psh_corner_orientation ft_corner_orientation
923#ifdef COMPUTE_INFLEXS
935 FT_Pos in_x, in_y, out_x, out_y;
936 FT_Int orient_prev, orient_cur;
957 }
while ( in_x == 0 && in_y == 0 );
973 }
while ( out_x == 0 && out_y == 0 );
977 }
while ( orient_prev == 0 );
1000 }
while ( out_x == 0 && out_y == 0 );
1004 }
while ( orient_cur == 0 );
1006 if ( ( orient_cur ^ orient_prev ) < 0 )
1020 orient_prev = orient_cur;
1024 }
while ( !finished );
1069 else if (
ax * 12 < ay )
1093 if ( dimension == 0 )
1126 if ( dimension == 0 )
1132 tags[
n] |= (
char)( ( dimension == 0 ) ? 32 : 64 );
1136 if ( dimension == 0 )
1200 point->contour = contour;
1207 point->contour = contour;
1228 FT_Pos dxi, dyi, dxo, dyo;
1260#ifdef COMPUTE_INFLEXS
1432 point_dir =
point->dir_in;
1435 point_dir =
point->dir_out;
1439 if ( point_dir == major_dir )
1444 for ( nn = 0; nn < num_hints; nn++ )
1450 if (
d < threshold && -
d < threshold )
1459 else if ( point_dir == -major_dir )
1464 for ( nn = 0; nn < num_hints; nn++ )
1470 if (
d < threshold && -
d < threshold )
1485 FT_UInt nn, min_flag, max_flag;
1499 if (
point->flags2 & min_flag )
1501 for ( nn = 0; nn < num_hints; nn++ )
1507 if (
d < threshold && -
d < threshold )
1516 else if (
point->flags2 & max_flag )
1518 for ( nn = 0; nn < num_hints; nn++ )
1524 if (
d < threshold && -
d < threshold )
1536 for ( nn = 0; nn < num_hints; nn++ )
1541 if ( org_u >=
hint->org_pos &&
1542 org_u <= hint->org_pos +
hint->org_len )
1557#define PSH_STRONG_THRESHOLD 32
1560#define PSH_STRONG_THRESHOLD_MAXIMUM 30
1587 if ( num_masks > 1 && glyph->
num_points > 0 )
1594 for ( ; num_masks > 1; num_masks--,
mask++ )
1608 threshold, major_dir );
1615 if ( num_masks == 1 )
1624 threshold, major_dir );
1654 for ( ; glyph_count > 0; glyph_count--,
point++ )
1672 blue_count =
table->count;
1675 for ( ; blue_count > 0; blue_count--,
zone++ )
1680 if ( delta < -blues->blue_fuzz )
1683 if ( y <= zone->org_top + blues->
blue_fuzz )
1684 if ( blues->
no_overshoots || delta <= blues->blue_threshold )
1694 blue_count =
table->count;
1697 for ( ; blue_count > 0; blue_count--,
zone-- )
1702 if ( delta < -blues->blue_fuzz )
1706 if ( blues->
no_overshoots || delta < blues->blue_threshold )
1752 else if ( delta >=
hint->org_len )
1767#define PSH_MAX_STRONG_INTERNAL 16
1797 if ( num_strongs == 0 )
1803 strongs = strongs_0;
1824 if (
insert[-1]->org_u <= point->org_u )
1850 point->flags &= ~PSH_POINT_SMOOTH;
1859 for ( nn = 0; nn < num_strongs; nn++ )
1860 if ( strongs[nn]->org_u >
point->org_u )
1873 before = strongs[nn - 1];
1875 for ( nn = num_strongs; nn > 0; nn-- )
1876 if ( strongs[nn - 1]->org_u < point->org_u )
1879 if ( nn == num_strongs )
1881 before = strongs[nn - 1];
1892 after = strongs[nn];
1900 else if (
u ==
after->org_u )
1914 if ( strongs != strongs_0 )
1934 for ( ; num_contours > 0; num_contours--, contour++ )
1957 if ( fit_count < 2 )
1959 if ( fit_count == 1 )
1997 FT_Pos org_a, org_ab, cur_a, cur_ab;
1998 FT_Pos org_c, org_ac, cur_c;
2004 org_a =
first->org_u;
2005 cur_a =
first->cur_u;
2006 org_ab =
next->org_u - org_a;
2007 cur_ab =
next->cur_u - cur_a;
2011 org_a =
next->org_u;
2012 cur_a =
next->cur_u;
2013 org_ab =
first->org_u - org_a;
2014 cur_ab =
first->cur_u - cur_a;
2017 scale_ab = 0x10000L;
2024 org_c =
point->org_u;
2025 org_ac = org_c - org_a;
2032 else if ( org_ac >= org_ab )
2040 cur_c = cur_a +
FT_MulFix( org_ac, scale_ab );
2043 point->cur_u = cur_c;
2090 memory = globals->memory;
2092 if ( ps_debug_glyph )
2101 ps_debug_glyph = glyph;
2128 scaled =
FT_MulFix( globals->blues.normal_top.zones->org_ref, y_scale );
2131 if ( fitted != 0 && scaled != fitted )
2135 y_scale =
FT_MulDiv( y_scale, fitted, scaled );
2137 if ( fitted < scaled )
2138 x_scale -= x_scale / 50;
2154 for ( dimension = 0; dimension < 2; dimension++ )
2170 if ( dimension == 1 )
2181 old_x_scale, old_y_scale, 0, 0 );
_STLP_MOVE_TO_STD_NAMESPACE void sort(_RandomAccessIter __first, _RandomAccessIter __last)
int align(int length, int align)
enum FT_Render_Mode_ FT_Render_Mode
FT_DivFix(FT_Long a, FT_Long b)
FT_MulDiv(FT_Long a, FT_Long b, FT_Long c)
FT_MulFix(FT_Long a, FT_Long b)
#define FT_TRACE0(varformat)
FT_BEGIN_HEADER typedef signed long FT_Pos
#define FT_NEW_ARRAY(ptr, count)
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
FT_BEGIN_HEADER typedef unsigned char FT_Bool
GLint GLint GLint GLint GLint GLint y
GLuint GLuint GLsizei count
GLenum GLenum GLenum GLenum GLenum scale
GLsizei const GLfloat * points
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
typedefFT_BEGIN_HEADER struct PSH_GlobalsRec_ * PSH_Globals
static char memory[1024 *256]
static void psh_hint_table_record_mask(PSH_Hint_Table table, PS_Mask hint_mask)
#define psh_corner_is_flat
static void psh_hint_table_activate_mask(PSH_Hint_Table table, PS_Mask hint_mask)
static void psh_glyph_interpolate_other_points(PSH_Glyph glyph, FT_Int dimension)
static void psh_glyph_compute_extrema(PSH_Glyph glyph)
#define PSH_STRONG_THRESHOLD
static void psh_hint_align(PSH_Hint hint, PSH_Globals globals, FT_Int dimension, PSH_Glyph glyph)
static int psh_compute_dir(FT_Pos dx, FT_Pos dy)
static FT_Int psh_hint_overlap(PSH_Hint hint1, PSH_Hint hint2)
#define PSH_STRONG_THRESHOLD_MAXIMUM
static void psh_glyph_interpolate_strong_points(PSH_Glyph glyph, FT_Int dimension)
static void psh_glyph_find_strong_points(PSH_Glyph glyph, FT_Int dimension)
FT_Error ps_hints_apply(PS_Hints ps_hints, FT_Outline *outline, PSH_Globals globals, FT_Render_Mode hint_mode)
static FT_Pos psh_dimension_quantize_len(PSH_Dimension dim, FT_Pos len, FT_Bool do_snapping)
static void psh_glyph_find_blue_points(PSH_Blues blues, PSH_Glyph glyph)
static void psh_glyph_save_points(PSH_Glyph glyph, FT_Int dimension)
static void psh_glyph_done(PSH_Glyph glyph)
static FT_Error psh_hint_table_init(PSH_Hint_Table table, PS_Hint_Table hints, PS_Mask_Table hint_masks, PS_Mask_Table counter_masks, FT_Memory memory)
#define PSH_MAX_STRONG_INTERNAL
#define psh_corner_orientation
static void psh_glyph_load_points(PSH_Glyph glyph, FT_Int dimension)
static void psh_hint_table_deactivate(PSH_Hint_Table table)
static void psh_hint_table_record(PSH_Hint_Table table, FT_UInt idx)
static void psh_hint_table_find_strong_points(PSH_Hint_Table table, PSH_Point point, FT_UInt count, FT_Int threshold, FT_Int major_dir)
static void psh_hint_table_align_hints(PSH_Hint_Table table, PSH_Globals globals, FT_Int dimension, PSH_Glyph glyph)
static void psh_glyph_compute_inflections(PSH_Glyph glyph)
static void psh_hint_table_done(PSH_Hint_Table table, FT_Memory memory)
static void psh_glyph_interpolate_normal_points(PSH_Glyph glyph, FT_Int dimension)
static FT_Fixed psh_hint_snap_stem_side_delta(FT_Fixed pos, FT_Fixed len)
static FT_Error psh_glyph_init(PSH_Glyph glyph, FT_Outline *outline, PS_Hints ps_hints, PSH_Globals globals)
#define PSH_POINT_POSITIVE
#define psh_point_is_strong(p)
#define psh_hint_deactivate(x)
#define psh_point_set_inflex(p)
#define psh_point_is_inflex(p)
typedefFT_BEGIN_HEADER struct PSH_HintRec_ * PSH_Hint
#define psh_hint_is_active(x)
#define psh_point_is_edge_max(p)
#define psh_hint_activate(x)
#define psh_point_is_smooth(p)
#define psh_point_is_extremum(p)
#define psh_point_set_negative(p)
#define psh_point_set_strong(p)
#define PSH_POINT_EDGE_MIN
#define psh_point_is_edge_min(p)
#define PSH_DIR_COMPARE(d1, d2)
#define psh_point_set_extremum(p)
#define psh_hint_set_fitted(x)
#define psh_point_set_positive(p)
#define psh_hint_is_fitted(x)
#define PSH_POINT_NEGATIVE
#define psh_point_set_fitted(p)
#define psh_point_is_fitted(p)
#define PSH_POINT_EDGE_MAX
#define PSH_DIR_HORIZONTAL
psh_blues_snap_stem(PSH_Blues blues, FT_Int stem_top, FT_Int stem_bot, PSH_Alignment alignment)
psh_globals_set_scale(PSH_Globals globals, FT_Fixed x_scale, FT_Fixed y_scale, FT_Fixed x_delta, FT_Fixed y_delta)
#define PSH_BLUE_ALIGN_BOT
#define PSH_BLUE_ALIGN_NONE
#define PSH_BLUE_ALIGN_TOP
typedefFT_BEGIN_HEADER struct PS_HintRec_ * PS_Hint
static unsigned __int64 next
namespace GUID const ADDRINFOEXW * hints
PSH_Blue_TableRec normal_top
PSH_Blue_TableRec normal_bottom
PSH_Hint_TableRec hint_tables[2]
PSH_WidthRec widths[PS_GLOBALS_MAX_STD_WIDTHS]
PS_Mask_TableRec counters
PS_DimensionRec dimension[2]
ecx edi movl ebx edx edi decl ecx esi eax jecxz decl eax andl eax esi movl edx movl TEMP incl eax andl eax ecx incl ebx testl eax jnz xchgl ecx incl TEMP esp ecx subl ebx pushl ecx ecx edx ecx shrl ecx mm0 mm4 mm0 mm4 mm1 mm5 mm1 mm5 mm2 mm6 mm2 mm6 mm3 mm7 mm3 mm7 paddd mm0 paddd mm4 paddd mm0 paddd mm4 paddd mm0 paddd mm4 movq mm1 movq mm5 psrlq mm1 psrlq mm5 paddd mm0 paddd mm4 psrad mm0 psrad mm4 packssdw mm0 packssdw mm4 mm1 punpckldq mm0 pand mm1 pand mm0 por mm1 movq edi esi edx edi decl ecx jnz popl ecx andl ecx jecxz mm0 mm0 mm1 mm1 mm2 mm2 mm3 mm3 paddd mm0 paddd mm0 paddd mm0 movq mm1 psrlq mm1 paddd mm0 psrad mm0 packssdw mm0 movd eax movw ax
__inline int before(__u32 seq1, __u32 seq2)
__inline int after(__u32 seq1, __u32 seq2)