28#define FT_COMPONENT pshalgo
33 PSH_HintFunc ps_debug_hint_func =
NULL;
38#define COMPUTE_INFLEXS
55 return ADD_INT( hint1->org_pos, hint1->org_len ) >= hint2->org_pos &&
56 ADD_INT( hint2->org_pos, hint2->org_len ) >= hint1->org_pos;
103 FT_TRACE0((
"psh_hint_table_record: invalid hint index %d\n",
idx ));
128 hint->parent = hint2;
137 FT_TRACE0((
"psh_hint_table_record: too many sorted hints! BUG!\n" ));
192 table->num_hints = 0;
193 table->num_zones = 0;
218 table->hint_masks = hint_masks;
230 FT_TRACE0((
"psh_hint_table_init: missing/incorrect hint masks\n" ));
278 for ( count2 =
count; count2 > 0; count2--,
sort++ )
282 FT_TRACE0((
"psh_hint_table_activate_mask:"
283 " found overlapping hints\n" ))
292 if ( count < table->max_hints )
295 FT_TRACE0((
"psh_hint_tableactivate_mask:"
296 " too many active hints\n" ));
318 for ( i2 = i1 - 1; i2 >= 0; i2-- )
322 if ( hint2->org_pos < hint1->org_pos )
325 sort[i2 + 1] = hint2;
366 delta = (
len & 63 );
372 else if ( delta < 32 )
375 else if ( delta < 54 )
412 if ( ps_debug_hint_func )
413 ps_debug_hint_func(
hint, dimension );
479 if ( dimension == 1 )
485 switch (
align.align )
489 hint->cur_pos =
align.align_top - fit_len;
510 FT_Pos par_org_center, par_cur_center;
511 FT_Pos cur_org_center, cur_delta;
521 par_org_center =
parent->org_pos + (
parent->org_len >> 1 );
522 par_cur_center =
parent->cur_pos + (
parent->cur_len >> 1 );
523 cur_org_center =
hint->org_pos + (
hint->org_len >> 1 );
526 pos = par_cur_center + cur_delta - (
len >> 1 );
530 hint->cur_len = fit_len;
582 left_disp = -left_disp;
583 if ( right_disp < 0 )
584 right_disp = -right_disp;
585 if ( left_disp <= right_disp )
619 switch (
align.align )
650 if ( ps_debug_hint_func )
651 ps_debug_hint_func(
hint, dimension );
697 hint->cur_len = fit_len;
703 if ( dimension == 1 )
709 switch (
align.align )
713 hint->cur_pos =
align.align_top - fit_len;
734 FT_Pos par_org_center, par_cur_center;
735 FT_Pos cur_org_center, cur_delta;
740 psh_hint_align_light(
parent, globals, dimension, glyph );
742 par_org_center =
parent->org_pos + (
parent->org_len / 2 );
743 par_cur_center =
parent->cur_pos + (
parent->cur_len / 2 );
744 cur_org_center =
hint->org_pos + (
hint->org_len / 2 );
747 pos = par_cur_center + cur_delta - (
len >> 1 );
758 if ( (
pos +
len + 63 ) / 64 !=
pos / 64 + 1 )
792 if ( (
len / 64 ) & 1 )
812 else if ( frac_len < 48 )
835 if ( ps_debug_hint_func )
836 ps_debug_hint_func(
hint, dimension );
860 if ( ps_debug_no_vert_hints && dimension == 0 )
862 ps_simple_scale(
table,
scale, delta, dimension );
866 if ( ps_debug_no_horz_hints && dimension == 1 )
868 ps_simple_scale(
table,
scale, delta, dimension );
895#include FT_CONFIG_STANDARD_LIBRARY_H
900 printf(
"zone [scale,delta,min,max] = [%.5f,%.2f,%d,%d]\n",
901 zone->scale / 65536.0,
918#define psh_corner_is_flat ft_corner_is_flat
919#define psh_corner_orientation ft_corner_orientation
922#ifdef COMPUTE_INFLEXS
934 FT_Pos in_x, in_y, out_x, out_y;
935 FT_Int orient_prev, orient_cur;
956 }
while ( in_x == 0 && in_y == 0 );
972 }
while ( out_x == 0 && out_y == 0 );
976 }
while ( orient_prev == 0 );
999 }
while ( out_x == 0 && out_y == 0 );
1003 }
while ( orient_cur == 0 );
1005 if ( ( orient_cur ^ orient_prev ) < 0 )
1019 orient_prev = orient_cur;
1023 }
while ( !finished );
1068 else if (
ax * 12 < ay )
1092 if ( dimension == 0 )
1125 if ( dimension == 0 )
1131 tags[
n] |= (
char)( ( dimension == 0 ) ? 32 : 64 );
1135 if ( dimension == 0 )
1199 point->contour = contour;
1206 point->contour = contour;
1227 FT_Pos dxi, dyi, dxo, dyo;
1259#ifdef COMPUTE_INFLEXS
1431 point_dir =
point->dir_in;
1434 point_dir =
point->dir_out;
1438 if ( point_dir == major_dir )
1443 for ( nn = 0; nn < num_hints; nn++ )
1449 if (
d < threshold && -
d < threshold )
1458 else if ( point_dir == -major_dir )
1463 for ( nn = 0; nn < num_hints; nn++ )
1469 if (
d < threshold && -
d < threshold )
1484 FT_UInt nn, min_flag, max_flag;
1498 if (
point->flags2 & min_flag )
1500 for ( nn = 0; nn < num_hints; nn++ )
1506 if (
d < threshold && -
d < threshold )
1515 else if (
point->flags2 & max_flag )
1517 for ( nn = 0; nn < num_hints; nn++ )
1523 if (
d < threshold && -
d < threshold )
1535 for ( nn = 0; nn < num_hints; nn++ )
1540 if ( org_u >=
hint->org_pos &&
1556#define PSH_STRONG_THRESHOLD 32
1559#define PSH_STRONG_THRESHOLD_MAXIMUM 30
1586 if ( num_masks > 1 && glyph->
num_points > 0 )
1593 for ( ; num_masks > 1; num_masks--,
mask++ )
1607 threshold, major_dir );
1614 if ( num_masks == 1 )
1623 threshold, major_dir );
1653 for ( ; glyph_count > 0; glyph_count--,
point++ )
1671 blue_count =
table->count;
1674 for ( ; blue_count > 0; blue_count--,
zone++ )
1679 if ( delta < -blues->blue_fuzz )
1682 if ( y <= zone->org_top + blues->
blue_fuzz )
1683 if ( blues->
no_overshoots || delta <= blues->blue_threshold )
1693 blue_count =
table->count;
1696 for ( ; blue_count > 0; blue_count--,
zone-- )
1701 if ( delta < -blues->blue_fuzz )
1705 if ( blues->
no_overshoots || delta < blues->blue_threshold )
1751 else if ( delta >=
hint->org_len )
1766#define PSH_MAX_STRONG_INTERNAL 16
1796 if ( num_strongs == 0 )
1802 strongs = strongs_0;
1821 for ( insert = strongs + num_strongs; insert > strongs; insert-- )
1823 if ( insert[-1]->org_u <= point->org_u )
1826 insert[0] = insert[-1];
1849 point->flags &= ~PSH_POINT_SMOOTH;
1858 for ( nn = 0; nn < num_strongs; nn++ )
1859 if ( strongs[nn]->org_u >
point->org_u )
1872 before = strongs[nn - 1];
1874 for ( nn = num_strongs; nn > 0; nn-- )
1875 if ( strongs[nn - 1]->org_u < point->org_u )
1878 if ( nn == num_strongs )
1880 before = strongs[nn - 1];
1891 after = strongs[nn];
1899 else if (
u ==
after->org_u )
1913 if ( strongs != strongs_0 )
1933 for ( ; num_contours > 0; num_contours--, contour++ )
1956 if ( fit_count < 2 )
1958 if ( fit_count == 1 )
1996 FT_Pos org_a, org_ab, cur_a, cur_ab;
1997 FT_Pos org_c, org_ac, cur_c;
2003 org_a =
first->org_u;
2004 cur_a =
first->cur_u;
2005 org_ab =
next->org_u - org_a;
2006 cur_ab =
next->cur_u - cur_a;
2010 org_a =
next->org_u;
2011 cur_a =
next->cur_u;
2012 org_ab =
first->org_u - org_a;
2013 cur_ab =
first->cur_u - cur_a;
2016 scale_ab = 0x10000L;
2023 org_c =
point->org_u;
2024 org_ac = org_c - org_a;
2031 else if ( org_ac >= org_ab )
2039 cur_c = cur_a +
FT_MulFix( org_ac, scale_ab );
2042 point->cur_u = cur_c;
2089 memory = globals->memory;
2091 if ( ps_debug_glyph )
2100 ps_debug_glyph = glyph;
2127 scaled =
FT_MulFix( globals->blues.normal_top.zones->org_ref, y_scale );
2130 if ( fitted != 0 && scaled != fitted )
2134 y_scale =
FT_MulDiv( y_scale, fitted, scaled );
2136 if ( fitted < scaled )
2137 x_scale -= x_scale / 50;
2153 for ( dimension = 0; dimension < 2; dimension++ )
2169 if ( dimension == 1 )
2180 old_x_scale, old_y_scale, 0, 0 );
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
GLuint GLuint GLsizei count
GLint GLint GLint GLint GLint GLint y
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
STDMETHOD() Skip(THIS_ ULONG celt) PURE
STDMETHOD() Next(THIS_ ULONG celt, IAssociationElement *pElement, ULONG *pceltFetched) PURE
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)