20 #include FT_FREETYPE_H 21 #include FT_INTERNAL_OBJECTS_H 22 #include FT_INTERNAL_DEBUG_H 23 #include FT_INTERNAL_CALC_H 31 #define FT_COMPONENT trace_pshrec 35 int ps_debug_no_horz_hints = 0;
36 int ps_debug_no_vert_hints = 0;
70 if ( new_max > old_max )
96 error = ps_hint_table_ensure( table, count, memory );
101 hint = table->
hints + count - 1;
145 if ( new_max > old_max )
157 ps_mask_test_bit(
PS_Mask mask,
163 return mask->
bytes[idx >> 3] & ( 0x80 >> ( idx & 7 ) );
169 ps_mask_clear_bit(
PS_Mask mask,
178 p = mask->
bytes + ( idx >> 3 );
179 p[0] = (
FT_Byte)( p[0] & ~( 0x80 >> ( idx & 7 ) ) );
198 error = ps_mask_ensure( mask,
idx + 1, memory );
206 p[0] = (
FT_Byte)( p[0] | ( 0x80 >> (
idx & 7 ) ) );
222 for ( ; count > 0; count--, mask++ )
223 ps_mask_done( mask, memory );
242 if ( new_max > old_max )
268 error = ps_mask_table_ensure( table, count, memory );
273 mask = table->
masks + count - 1;
298 error = ps_mask_table_alloc( table, memory, &mask );
303 mask = table->
masks + count - 1;
323 error = ps_mask_table_last( table, memory, &mask );
327 error = ps_mask_ensure( mask, bit_count, memory );
336 FT_Int rmask = 0x80 >> ( bit_pos & 7 );
342 for ( ; bit_count > 0; bit_count-- )
344 val = write[0] & ~wmask;
346 if ( read[0] & rmask )
387 count =
FT_MIN( count1, count2 );
388 for ( ; count >= 8; count -= 8 )
400 return ( p1[0] & p2[0] ) & ~( 0xFF >>
count );
416 if ( index1 > index2 )
423 if ( index1 < index2 && index1 >= 0 && index2 < (
FT_Int)table->
num_masks )
443 if ( count2 > count1 )
445 error = ps_mask_ensure( mask1, count2, memory );
449 for ( pos = count1; pos < count2; pos++ )
450 ps_mask_clear_bit( mask1, pos );
455 write = mask1->
bytes;
456 pos = (
FT_UInt)( ( count2 + 7 ) >> 3 );
458 for ( ; pos > 0; pos-- )
460 write[0] = (
FT_Byte)( write[0] | read[0] );
480 mask2[delta] = dummy;
486 FT_TRACE0((
"ps_mask_table_merge: ignoring invalid indices (%d,%d)\n",
505 for ( index1 = table->
num_masks - 1; index1 > 0; index1-- )
507 for ( index2 = index1 - 1; index2 >= 0; index2-- )
509 if ( ps_mask_table_test_intersect( table, index1, index2 ) )
511 error = ps_mask_table_merge( table, index2, index1, memory );
539 ps_mask_table_done( &dimension->
counters, memory );
540 ps_mask_table_done( &dimension->
masks, memory );
541 ps_hint_table_done( &dimension->
hints, memory );
568 error = ps_mask_table_last( &dim->
masks, memory, &mask );
572 error = ps_mask_set_bit( mask,
idx, memory );
608 ps_dimension_end_mask( dim, end_point );
611 return ps_mask_table_alloc( &dim->
masks, memory, &mask );
628 error = ps_dimension_reset_mask( dim, end_point, memory );
633 error = ps_mask_table_set_bits( &dim->
masks,
source,
634 source_pos, source_bits, memory );
676 for ( idx = 0; idx <
max; idx++, hint++ )
678 if ( hint->pos == pos && hint->len ==
len )
685 error = ps_hint_table_alloc( &dim->
hints, memory, &hint );
695 error = ps_mask_table_last( &dim->
masks, memory, &mask );
699 error = ps_mask_set_bit( mask, idx, memory );
727 for ( ; count > 0; count--, counter++ )
729 if ( ps_mask_test_bit( counter, hint1 ) ||
730 ps_mask_test_bit( counter, hint2 ) ||
731 ps_mask_test_bit( counter, hint3 ) )
738 error = ps_mask_table_alloc( &dim->
counters, memory, &counter );
744 error = ps_mask_set_bit( counter, hint1, memory );
748 error = ps_mask_set_bit( counter, hint2, memory );
752 error = ps_mask_set_bit( counter, hint3, memory );
768 ps_dimension_end_mask( dim, end_point );
771 return ps_mask_table_merge_all( &dim->
counters, memory );
791 ps_dimension_done( &hints->dimension[0], memory );
792 ps_dimension_done( &hints->dimension[1], memory );
804 hints->memory = memory;
821 ps_dimension_init( &hints->
dimension[0] );
822 ps_dimension_init( &hints->
dimension[1] );
829 FT_TRACE0((
"ps_hints_open: invalid charstring type\n" ));
845 if ( dimension < 0 || dimension > 1 )
847 FT_TRACE0((
"ps_hints_stem: invalid dimension (%d) used\n",
849 dimension = ( dimension != 0 );
867 error = ps_dimension_add_t1stem(
872 FT_ERROR((
"ps_hints_stem: could not add stem" 873 " (%d,%d) to hints table\n", stems[0], stems[1] ));
883 FT_TRACE0((
"ps_hints_stem: called with invalid hint type (%d)\n",
909 if ( dimension < 0 || dimension > 1 )
911 FT_TRACE0((
"ps_hints_t1stem3: invalid dimension (%d) used\n",
913 dimension = ( dimension != 0 );
922 for ( count = 0; count < 3; count++, stems += 2 )
924 error = ps_dimension_add_t1stem( dim,
927 memory, &idx[count] );
933 error = ps_dimension_add_counter( dim, idx[0], idx[1], idx[2],
940 FT_ERROR((
"ps_hints_t1stem3: called with invalid hint type\n" ));
941 error =
FT_THROW( Invalid_Argument );
949 FT_ERROR((
"ps_hints_t1stem3: could not add counter stems to table\n" ));
969 error = ps_dimension_reset_mask( &hints->
dimension[0],
974 error = ps_dimension_reset_mask( &hints->
dimension[1],
982 error =
FT_THROW( Invalid_Argument );
1003 if ( !hints->
error )
1012 if ( bit_count != count1 + count2 )
1015 " called with invalid bitcount %d (instead of %d)\n",
1016 bit_count, count1 + count2 ));
1023 error = ps_dimension_set_mask_bits( &dim[0], bytes, count2, count1,
1024 end_point, memory );
1028 error = ps_dimension_set_mask_bits( &dim[1], bytes, 0, count2,
1029 end_point, memory );
1041 ps_hints_t2counter(
PS_Hints hints,
1048 if ( !hints->
error )
1057 if ( bit_count != count1 + count2 )
1060 " called with invalid bitcount %d (instead of %d)\n",
1061 bit_count, count1 + count2 ));
1068 error = ps_dimension_set_mask_bits( &dim[0], bytes, 0, count1,
1073 error = ps_dimension_set_mask_bits( &dim[1], bytes, count1, count2,
1093 error = hints->
error;
1100 error = ps_dimension_end( &dim[0], end_point, memory );
1103 error = ps_dimension_end( &dim[1], end_point, memory );
1109 ps_debug_hints = hints;
1140 ps_hints_stem( (
PS_Hints)hints, dimension, 1, stems );
1192 for ( n = 0; n <
count * 2; n++ )
1199 for ( n = 0; n < count * 2; n += 2 )
1200 stems[n + 1] = stems[n + 1] - stems[n];
1203 ps_hints_stem( (
PS_Hints)hints, dimension, count, stems );
void(* T1_Hints_SetStem3Func)(T1_Hints hints, FT_UInt dimension, FT_Fixed *coords)
typedefFT_BEGIN_HEADER struct PS_HintRec_ * PS_Hint
FT_BEGIN_HEADER typedef signed long FT_Pos
void(* T2_Hints_CounterFunc)(T2_Hints hints, FT_UInt bit_count, const FT_Byte *bytes)
int write(int fd, const char *buf, int nbytes)
int read(int fd, char *buf, int nbytes)
#define FT_MEM_ZERO(dest, count)
struct T2_HintsRec_ * T2_Hints
GLint GLint GLint GLint GLint GLint y
void(* T1_Hints_SetStemFunc)(T1_Hints hints, FT_UInt dimension, FT_Fixed *coords)
return FT_THROW(Missing_Property)
GLsizei GLsizei GLchar * source
void(* T1_Hints_ResetFunc)(T1_Hints hints, FT_UInt end_point)
void(* T2_Hints_OpenFunc)(T2_Hints hints)
ps_hints_init(PS_Hints hints, FT_Memory memory)
#define FT_ERROR(varformat)
#define FT_PAD_CEIL(x, n)
PS_DimensionRec dimension[2]
ps_hints_done(PS_Hints hints)
#define FT_RENEW_ARRAY(ptr, curcnt, newcnt)
void(* T2_Hints_MaskFunc)(T2_Hints hints, FT_UInt end_point, FT_UInt bit_count, const FT_Byte *bytes)
FT_Error(* T1_Hints_CloseFunc)(T1_Hints hints, FT_UInt end_point)
struct T1_HintsRec_ * T1_Hints
PS_Mask_TableRec counters
t2_hints_funcs_init(T2_Hints_FuncsRec *funcs)
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
FT_Error ps_hints_apply(PS_Hints ps_hints, FT_Outline *outline, PSH_Globals globals, FT_Render_Mode hint_mode)
enum PS_Hint_Type_ PS_Hint_Type
FT_Error(* T2_Hints_CloseFunc)(T2_Hints hints, FT_UInt end_point)
t1_hints_funcs_init(T1_Hints_FuncsRec *funcs)
void(* T1_Hints_OpenFunc)(T1_Hints hints)
FT_Error(* T1_Hints_ApplyFunc)(T1_Hints hints, FT_Outline *outline, PSH_Globals globals, FT_Render_Mode hint_mode)
void(* T2_Hints_StemsFunc)(T2_Hints hints, FT_UInt dimension, FT_UInt count, FT_Fixed *coordinates)
GLuint GLuint GLsizei count
FT_TRACE0(("cff_property_set: missing property `%s'\, property_name))
FT_Error(* T2_Hints_ApplyFunc)(T2_Hints hints, FT_Outline *outline, PSH_Globals globals, FT_Render_Mode hint_mode)
GLenum GLsizei GLenum GLenum const GLvoid * table