ReactOS 0.4.16-dev-2354-g16de117
pshrec.c File Reference
#include <freetype/freetype.h>
#include <freetype/internal/ftobjs.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftcalc.h>
#include "pshrec.h"
#include "pshalgo.h"
#include "pshnterr.h"
Include dependency graph for pshrec.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define FT_COMPONENT   pshrec
 

Functions

static void ps_hint_table_done (PS_Hint_Table table, FT_Memory memory)
 
static FT_Error ps_hint_table_ensure (PS_Hint_Table table, FT_UInt count, FT_Memory memory)
 
static FT_Error ps_hint_table_alloc (PS_Hint_Table table, FT_Memory memory, PS_Hint *ahint)
 
static void ps_mask_done (PS_Mask mask, FT_Memory memory)
 
static FT_Error ps_mask_ensure (PS_Mask mask, FT_UInt count, FT_Memory memory)
 
static FT_Int ps_mask_test_bit (PS_Mask mask, FT_Int idx)
 
static void ps_mask_clear_bit (PS_Mask mask, FT_UInt idx)
 
static FT_Error ps_mask_set_bit (PS_Mask mask, FT_UInt idx, FT_Memory memory)
 
static void ps_mask_table_done (PS_Mask_Table table, FT_Memory memory)
 
static FT_Error ps_mask_table_ensure (PS_Mask_Table table, FT_UInt count, FT_Memory memory)
 
static FT_Error ps_mask_table_alloc (PS_Mask_Table table, FT_Memory memory, PS_Mask *amask)
 
static FT_Error ps_mask_table_last (PS_Mask_Table table, FT_Memory memory, PS_Mask *amask)
 
static FT_Error ps_mask_table_set_bits (PS_Mask_Table table, const FT_Byte *source, FT_UInt bit_pos, FT_UInt bit_count, FT_Memory memory)
 
static FT_Int ps_mask_table_test_intersect (PS_Mask_Table table, FT_UInt index1, FT_UInt index2)
 
static FT_Error ps_mask_table_merge (PS_Mask_Table table, FT_UInt index1, FT_UInt index2, FT_Memory memory)
 
static FT_Error ps_mask_table_merge_all (PS_Mask_Table table, FT_Memory memory)
 
static void ps_dimension_done (PS_Dimension dimension, FT_Memory memory)
 
static void ps_dimension_init (PS_Dimension dimension)
 
static void ps_dimension_end_mask (PS_Dimension dim, FT_UInt end_point)
 
static FT_Error ps_dimension_reset_mask (PS_Dimension dim, FT_UInt end_point, FT_Memory memory)
 
static FT_Error ps_dimension_set_mask_bits (PS_Dimension dim, const FT_Byte *source, FT_UInt source_pos, FT_UInt source_bits, FT_UInt end_point, FT_Memory memory)
 
static FT_Error ps_dimension_add_t1stem (PS_Dimension dim, FT_Int pos, FT_Int len, FT_Memory memory, FT_Int *aindex)
 
static FT_Error ps_dimension_add_counter (PS_Dimension dim, FT_Int hint1, FT_Int hint2, FT_Int hint3, FT_Memory memory)
 
static FT_Error ps_dimension_end (PS_Dimension dim, FT_UInt end_point, FT_Memory memory)
 
 ps_hints_done (PS_Hints hints)
 
 ps_hints_init (PS_Hints hints, FT_Memory memory)
 
static void ps_hints_open (PS_Hints hints, PS_Hint_Type hint_type)
 
static void ps_hints_stem (PS_Hints hints, FT_UInt dimension, FT_Int count, FT_Long *stems)
 
static void ps_hints_t1stem3 (PS_Hints hints, FT_UInt dimension, FT_Fixed *stems)
 
static void ps_hints_t1reset (PS_Hints hints, FT_UInt end_point)
 
static void ps_hints_t2mask (PS_Hints hints, FT_UInt end_point, FT_UInt bit_count, const FT_Byte *bytes)
 
static void ps_hints_t2counter (PS_Hints hints, FT_UInt bit_count, const FT_Byte *bytes)
 
static FT_Error ps_hints_close (PS_Hints hints, FT_UInt end_point)
 
static void t1_hints_open (T1_Hints hints)
 
static void t1_hints_stem (T1_Hints hints, FT_UInt dimension, FT_Fixed *coords)
 
 t1_hints_funcs_init (T1_Hints_FuncsRec *funcs)
 
static void t2_hints_open (T2_Hints hints)
 
static void t2_hints_stems (T2_Hints hints, FT_UInt dimension, FT_Int count, FT_Fixed *coords)
 
 t2_hints_funcs_init (T2_Hints_FuncsRec *funcs)
 

Macro Definition Documentation

◆ FT_COMPONENT

#define FT_COMPONENT   pshrec

Definition at line 30 of file pshrec.c.

Function Documentation

◆ ps_dimension_add_counter()

static FT_Error ps_dimension_add_counter ( PS_Dimension  dim,
FT_Int  hint1,
FT_Int  hint2,
FT_Int  hint3,
FT_Memory  memory 
)
static

Definition at line 722 of file pshrec.c.

727 {
731
732
733 /* try to find an existing counter mask that already uses */
734 /* one of these stems here */
735 for ( ; count > 0; count--, counter++ )
736 {
737 if ( ps_mask_test_bit( counter, hint1 ) ||
738 ps_mask_test_bit( counter, hint2 ) ||
739 ps_mask_test_bit( counter, hint3 ) )
740 break;
741 }
742
743 /* create a new counter when needed */
744 if ( count == 0 )
745 {
747 if ( error )
748 goto Exit;
749 }
750
751 /* now, set the bits for our hints in the counter mask */
752 if ( hint1 >= 0 )
753 {
755 if ( error )
756 goto Exit;
757 }
758
759 if ( hint2 >= 0 )
760 {
762 if ( error )
763 goto Exit;
764 }
765
766 if ( hint3 >= 0 )
767 {
769 if ( error )
770 goto Exit;
771 }
772
773 Exit:
774 return error;
775 }
return FT_Err_Ok
Definition: ftbbox.c:526
int FT_Error
Definition: fttypes.h:299
unsigned int FT_UInt
Definition: fttypes.h:231
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define error(str)
Definition: mkdosfs.c:1605
static char memory[1024 *256]
Definition: process.c:122
static FT_Error ps_mask_set_bit(PS_Mask mask, FT_UInt idx, FT_Memory memory)
Definition: pshrec.c:184
static FT_Int ps_mask_test_bit(PS_Mask mask, FT_Int idx)
Definition: pshrec.c:156
static FT_Error ps_mask_table_alloc(PS_Mask_Table table, FT_Memory memory, PS_Mask *amask)
Definition: pshrec.c:250
static void Exit(void)
Definition: sock.c:1330
PS_Mask_TableRec counters
Definition: pshrec.h:118
PS_Mask masks
Definition: pshrec.h:108
FT_UInt num_masks
Definition: pshrec.h:106

Referenced by ps_hints_t1stem3().

◆ ps_dimension_add_t1stem()

static FT_Error ps_dimension_add_t1stem ( PS_Dimension  dim,
FT_Int  pos,
FT_Int  len,
FT_Memory  memory,
FT_Int aindex 
)
static

Definition at line 651 of file pshrec.c.

656 {
658 FT_UInt flags = 0;
659
660
661 /* detect ghost stem */
662 if ( len < 0 )
663 {
665 if ( len == -21 )
666 {
668 pos = ADD_INT( pos, len );
669 }
670 len = 0;
671 }
672
673 if ( aindex )
674 *aindex = -1;
675
676 /* now, lookup stem in the current hints table */
677 {
679 FT_UInt idx;
680 FT_UInt max = dim->hints.num_hints;
681 PS_Hint hint = dim->hints.hints;
682
683
684 for ( idx = 0; idx < max; idx++, hint++ )
685 {
686 if ( hint->pos == pos && hint->len == len )
687 break;
688 }
689
690 /* we need to create a new hint in the table */
691 if ( idx >= max )
692 {
694 if ( error )
695 goto Exit;
696
697 hint->pos = pos;
698 hint->len = len;
699 hint->flags = flags;
700 }
701
702 /* now, store the hint in the current mask */
704 if ( error )
705 goto Exit;
706
708 if ( error )
709 goto Exit;
710
711 if ( aindex )
712 *aindex = (FT_Int)idx;
713 }
714
715 Exit:
716 return error;
717 }
unsigned int idx
Definition: utils.c:41
#define ADD_INT(a, b)
Definition: ftcalc.h:463
signed int FT_Int
Definition: fttypes.h:220
GLenum GLint GLuint mask
Definition: glext.h:6028
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei len
Definition: glext.h:6722
static FT_Error ps_hint_table_alloc(PS_Hint_Table table, FT_Memory memory, PS_Hint *ahint)
Definition: pshrec.c:81
static FT_Error ps_mask_table_last(PS_Mask_Table table, FT_Memory memory, PS_Mask *amask)
Definition: pshrec.c:282
#define PS_HINT_FLAG_GHOST
Definition: pshrec.h:63
#define PS_HINT_FLAG_BOTTOM
Definition: pshrec.h:64
typedefFT_BEGIN_HEADER struct PS_HintRec_ * PS_Hint
Definition: pshrec.h:51
PS_Mask_TableRec masks
Definition: pshrec.h:117
PS_Hint_TableRec hints
Definition: pshrec.h:116
PS_Hint hints
Definition: pshrec.h:87
FT_UInt num_hints
Definition: pshrec.h:85
#define max(a, b)
Definition: svc.c:63
DWORD hint
Definition: vfdcmd.c:88

Referenced by ps_hints_stem(), and ps_hints_t1stem3().

◆ ps_dimension_done()

static void ps_dimension_done ( PS_Dimension  dimension,
FT_Memory  memory 
)
static

Definition at line 543 of file pshrec.c.

545 {
546 ps_mask_table_done( &dimension->counters, memory );
547 ps_mask_table_done( &dimension->masks, memory );
548 ps_hint_table_done( &dimension->hints, memory );
549 }
static void ps_hint_table_done(PS_Hint_Table table, FT_Memory memory)
Definition: pshrec.c:49
static void ps_mask_table_done(PS_Mask_Table table, FT_Memory memory)
Definition: pshrec.c:211

Referenced by ps_hints_done().

◆ ps_dimension_end()

static FT_Error ps_dimension_end ( PS_Dimension  dim,
FT_UInt  end_point,
FT_Memory  memory 
)
static

Definition at line 780 of file pshrec.c.

783 {
784 /* end hint mask table */
785 ps_dimension_end_mask( dim, end_point );
786
787 /* merge all counter masks into independent "paths" */
788 return ps_mask_table_merge_all( &dim->counters, memory );
789 }
static void ps_dimension_end_mask(PS_Dimension dim, FT_UInt end_point)
Definition: pshrec.c:589
static FT_Error ps_mask_table_merge_all(PS_Mask_Table table, FT_Memory memory)
Definition: pshrec.c:499

Referenced by ps_hints_close().

◆ ps_dimension_end_mask()

static void ps_dimension_end_mask ( PS_Dimension  dim,
FT_UInt  end_point 
)
static

Definition at line 589 of file pshrec.c.

591 {
593
594
595 if ( count > 0 )
596 {
597 PS_Mask mask = dim->masks.masks + count - 1;
598
599
600 mask->end_point = end_point;
601 }
602 }
FT_UInt end_point
Definition: pshrec.h:98

Referenced by ps_dimension_end(), and ps_dimension_reset_mask().

◆ ps_dimension_init()

static void ps_dimension_init ( PS_Dimension  dimension)
static

Definition at line 554 of file pshrec.c.

555 {
556 dimension->hints.num_hints = 0;
557 dimension->masks.num_masks = 0;
558 dimension->counters.num_masks = 0;
559 }

Referenced by ps_hints_open().

◆ ps_dimension_reset_mask()

static FT_Error ps_dimension_reset_mask ( PS_Dimension  dim,
FT_UInt  end_point,
FT_Memory  memory 
)
static

Definition at line 608 of file pshrec.c.

611 {
613
614
615 /* end current mask */
616 ps_dimension_end_mask( dim, end_point );
617
618 /* allocate new one */
619 return ps_mask_table_alloc( &dim->masks, memory, &mask );
620 }

Referenced by ps_dimension_set_mask_bits(), and ps_hints_t1reset().

◆ ps_dimension_set_mask_bits()

static FT_Error ps_dimension_set_mask_bits ( PS_Dimension  dim,
const FT_Byte source,
FT_UInt  source_pos,
FT_UInt  source_bits,
FT_UInt  end_point,
FT_Memory  memory 
)
static

Definition at line 625 of file pshrec.c.

631 {
633
634
635 /* reset current mask, if any */
636 error = ps_dimension_reset_mask( dim, end_point, memory );
637 if ( error )
638 goto Exit;
639
640 /* set bits in new mask */
642 source_pos, source_bits, memory );
643
644 Exit:
645 return error;
646 }
static FT_Error ps_mask_table_set_bits(PS_Mask_Table table, const FT_Byte *source, FT_UInt bit_pos, FT_UInt bit_count, FT_Memory memory)
Definition: pshrec.c:309
static FT_Error ps_dimension_reset_mask(PS_Dimension dim, FT_UInt end_point, FT_Memory memory)
Definition: pshrec.c:608

Referenced by ps_hints_t2counter(), and ps_hints_t2mask().

◆ ps_hint_table_alloc()

static FT_Error ps_hint_table_alloc ( PS_Hint_Table  table,
FT_Memory  memory,
PS_Hint ahint 
)
static

Definition at line 81 of file pshrec.c.

84 {
88
89
90 count = table->num_hints;
91 count++;
92
93 if ( count >= table->max_hints )
94 {
96 if ( error )
97 goto Exit;
98 }
99
100 hint = table->hints + count - 1;
101 hint->pos = 0;
102 hint->len = 0;
103 hint->flags = 0;
104
105 table->num_hints = count;
106
107 Exit:
108 *ahint = hint;
109 return error;
110 }
#define NULL
Definition: types.h:112
static FT_Error ps_hint_table_ensure(PS_Hint_Table table, FT_UInt count, FT_Memory memory)
Definition: pshrec.c:60

Referenced by ps_dimension_add_t1stem().

◆ ps_hint_table_done()

static void ps_hint_table_done ( PS_Hint_Table  table,
FT_Memory  memory 
)
static

Definition at line 49 of file pshrec.c.

51 {
52 FT_FREE( table->hints );
53 table->num_hints = 0;
54 table->max_hints = 0;
55 }
#define FT_FREE(ptr)
Definition: ftmemory.h:337

Referenced by ps_dimension_done().

◆ ps_hint_table_ensure()

static FT_Error ps_hint_table_ensure ( PS_Hint_Table  table,
FT_UInt  count,
FT_Memory  memory 
)
static

Definition at line 60 of file pshrec.c.

63 {
64 FT_UInt old_max = table->max_hints;
65 FT_UInt new_max = count;
67
68
69 if ( new_max > old_max )
70 {
71 /* try to grow the table */
72 new_max = FT_PAD_CEIL( new_max, 8 );
73 if ( !FT_RENEW_ARRAY( table->hints, old_max, new_max ) )
74 table->max_hints = new_max;
75 }
76 return error;
77 }
#define FT_RENEW_ARRAY(ptr, curcnt, newcnt)
Definition: ftmemory.h:344
#define FT_PAD_CEIL(x, n)
Definition: ftobjs.h:89

Referenced by ps_hint_table_alloc().

◆ ps_hints_close()

static FT_Error ps_hints_close ( PS_Hints  hints,
FT_UInt  end_point 
)
static

Definition at line 1082 of file pshrec.c.

1084 {
1086
1087
1088 error = hints->error;
1089 if ( !error )
1090 {
1091 FT_Memory memory = hints->memory;
1092 PS_Dimension dim = hints->dimension;
1093
1094
1095 error = ps_dimension_end( &dim[0], end_point, memory );
1096 if ( !error )
1097 {
1098 error = ps_dimension_end( &dim[1], end_point, memory );
1099 }
1100 }
1101
1102#ifdef DEBUG_HINTER
1103 if ( !error )
1104 ps_debug_hints = hints;
1105#endif
1106 return error;
1107 }
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:64
static FT_Error ps_dimension_end(PS_Dimension dim, FT_UInt end_point, FT_Memory memory)
Definition: pshrec.c:780
namespace GUID const ADDRINFOEXW * hints
Definition: sock.c:80

Referenced by t1_hints_funcs_init(), and t2_hints_funcs_init().

◆ ps_hints_done()

ps_hints_done ( PS_Hints  hints)

Definition at line 803 of file pshrec.c.

804 {
805 FT_Memory memory = hints->memory;
806
807
808 ps_dimension_done( &hints->dimension[0], memory );
809 ps_dimension_done( &hints->dimension[1], memory );
810
811 hints->error = FT_Err_Ok;
812 hints->memory = NULL;
813 }
static void ps_dimension_done(PS_Dimension dimension, FT_Memory memory)
Definition: pshrec.c:543

Referenced by ps_hinter_done().

◆ ps_hints_init()

ps_hints_init ( PS_Hints  hints,
FT_Memory  memory 
)

Definition at line 817 of file pshrec.c.

819 {
820 FT_ZERO( hints );
821 hints->memory = memory;
822 }
#define FT_ZERO(p)
Definition: ftmemory.h:246

Referenced by ps_hinter_init().

◆ ps_hints_open()

static void ps_hints_open ( PS_Hints  hints,
PS_Hint_Type  hint_type 
)
static

Definition at line 827 of file pshrec.c.

829 {
830 hints->error = FT_Err_Ok;
831 hints->hint_type = hint_type;
832
833 ps_dimension_init( &hints->dimension[0] );
834 ps_dimension_init( &hints->dimension[1] );
835 }
static void ps_dimension_init(PS_Dimension dimension)
Definition: pshrec.c:554

Referenced by t1_hints_open(), and t2_hints_open().

◆ ps_hints_stem()

static void ps_hints_stem ( PS_Hints  hints,
FT_UInt  dimension,
FT_Int  count,
FT_Long stems 
)
static

Definition at line 840 of file pshrec.c.

844 {
845 PS_Dimension dim;
846
847
848 if ( hints->error )
849 return;
850
851 /* limit "dimension" to 0..1 */
852 if ( dimension > 1 )
853 {
854 FT_TRACE0(( "ps_hints_stem: invalid dimension (%d) used\n",
855 dimension ));
856 dimension = ( dimension != 0 );
857 }
858
859 /* record the stems in the current hints/masks table */
860 /* (Type 1 & 2's `hstem' or `vstem' operators) */
861 dim = &hints->dimension[dimension];
862
863 for ( ; count > 0; count--, stems += 2 )
864 {
866 FT_Memory memory = hints->memory;
867
868
870 (FT_Int)stems[0],
871 (FT_Int)stems[1],
872 memory,
873 NULL );
874 if ( error )
875 {
876 FT_ERROR(( "ps_hints_stem: could not add stem"
877 " (%ld,%ld) to hints table\n", stems[0], stems[1] ));
878
879 hints->error = error;
880 return;
881 }
882 }
883 }
#define FT_TRACE0(varformat)
Definition: ftdebug.h:187
#define FT_ERROR(varformat)
Definition: ftdebug.h:211
static FT_Error ps_dimension_add_t1stem(PS_Dimension dim, FT_Int pos, FT_Int len, FT_Memory memory, FT_Int *aindex)
Definition: pshrec.c:651

Referenced by t1_hints_stem(), and t2_hints_stems().

◆ ps_hints_t1reset()

static void ps_hints_t1reset ( PS_Hints  hints,
FT_UInt  end_point 
)
static

Definition at line 951 of file pshrec.c.

953 {
955
956
957 if ( !hints->error )
958 {
959 FT_Memory memory = hints->memory;
960
961
962 if ( hints->hint_type == PS_HINT_TYPE_1 )
963 {
964 error = ps_dimension_reset_mask( &hints->dimension[0],
965 end_point, memory );
966 if ( error )
967 goto Fail;
968
969 error = ps_dimension_reset_mask( &hints->dimension[1],
970 end_point, memory );
971 if ( error )
972 goto Fail;
973 }
974 else
975 {
976 /* invalid hint type */
977 error = FT_THROW( Invalid_Argument );
978 goto Fail;
979 }
980 }
981 return;
982
983 Fail:
984 hints->error = error;
985 }
int Fail
Definition: ehthrow.cxx:24
#define FT_THROW(e)
Definition: ftdebug.h:243
@ PS_HINT_TYPE_1
Definition: pshrec.h:56

Referenced by t1_hints_funcs_init().

◆ ps_hints_t1stem3()

static void ps_hints_t1stem3 ( PS_Hints  hints,
FT_UInt  dimension,
FT_Fixed stems 
)
static

Definition at line 888 of file pshrec.c.

891 {
893
894
895 if ( !hints->error )
896 {
897 PS_Dimension dim;
898 FT_Memory memory = hints->memory;
900 FT_Int idx[3];
901
902
903 /* limit "dimension" to 0..1 */
904 if ( dimension > 1 )
905 {
906 FT_TRACE0(( "ps_hints_t1stem3: invalid dimension (%d) used\n",
907 dimension ));
908 dimension = ( dimension != 0 );
909 }
910
911 dim = &hints->dimension[dimension];
912
913 /* there must be 6 elements in the 'stem' array */
914 if ( hints->hint_type == PS_HINT_TYPE_1 )
915 {
916 /* add the three stems to our hints/masks table */
917 for ( count = 0; count < 3; count++, stems += 2 )
918 {
920 (FT_Int)FIXED_TO_INT( stems[0] ),
921 (FT_Int)FIXED_TO_INT( stems[1] ),
922 memory, &idx[count] );
923 if ( error )
924 goto Fail;
925 }
926
927 /* now, add the hints to the counters table */
928 error = ps_dimension_add_counter( dim, idx[0], idx[1], idx[2],
929 memory );
930 if ( error )
931 goto Fail;
932 }
933 else
934 {
935 FT_ERROR(( "ps_hints_t1stem3: called with invalid hint type\n" ));
936 error = FT_THROW( Invalid_Argument );
937 goto Fail;
938 }
939 }
940
941 return;
942
943 Fail:
944 FT_ERROR(( "ps_hints_t1stem3: could not add counter stems to table\n" ));
945 hints->error = error;
946 }
#define FIXED_TO_INT(x)
Definition: ftcalc.h:450
static FT_Error ps_dimension_add_counter(PS_Dimension dim, FT_Int hint1, FT_Int hint2, FT_Int hint3, FT_Memory memory)
Definition: pshrec.c:722

Referenced by t1_hints_funcs_init().

◆ ps_hints_t2counter()

static void ps_hints_t2counter ( PS_Hints  hints,
FT_UInt  bit_count,
const FT_Byte bytes 
)
static

Definition at line 1036 of file pshrec.c.

1039 {
1041
1042
1043 if ( !hints->error )
1044 {
1045 PS_Dimension dim = hints->dimension;
1046 FT_Memory memory = hints->memory;
1047 FT_UInt count1 = dim[0].hints.num_hints;
1048 FT_UInt count2 = dim[1].hints.num_hints;
1049
1050
1051 /* check bit count, must be equal to current total hint count */
1052 if ( bit_count != count1 + count2 )
1053 {
1054 FT_TRACE0(( "ps_hints_t2counter:"
1055 " called with invalid bitcount %d (instead of %d)\n",
1056 bit_count, count1 + count2 ));
1057
1058 /* simply ignore the operator */
1059 return;
1060 }
1061
1062 /* set-up new horizontal and vertical hint mask now */
1063 error = ps_dimension_set_mask_bits( &dim[0], bytes, 0, count1,
1064 0, memory );
1065 if ( error )
1066 goto Fail;
1067
1068 error = ps_dimension_set_mask_bits( &dim[1], bytes, count1, count2,
1069 0, memory );
1070 if ( error )
1071 goto Fail;
1072 }
1073 return;
1074
1075 Fail:
1076 hints->error = error;
1077 }
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
static FT_Error ps_dimension_set_mask_bits(PS_Dimension dim, const FT_Byte *source, FT_UInt source_pos, FT_UInt source_bits, FT_UInt end_point, FT_Memory memory)
Definition: pshrec.c:625

Referenced by t2_hints_funcs_init().

◆ ps_hints_t2mask()

static void ps_hints_t2mask ( PS_Hints  hints,
FT_UInt  end_point,
FT_UInt  bit_count,
const FT_Byte bytes 
)
static

Definition at line 990 of file pshrec.c.

994 {
996
997
998 if ( !hints->error )
999 {
1000 PS_Dimension dim = hints->dimension;
1001 FT_Memory memory = hints->memory;
1002 FT_UInt count1 = dim[0].hints.num_hints;
1003 FT_UInt count2 = dim[1].hints.num_hints;
1004
1005
1006 /* check bit count; must be equal to current total hint count */
1007 if ( bit_count != count1 + count2 )
1008 {
1009 FT_TRACE0(( "ps_hints_t2mask:"
1010 " called with invalid bitcount %d (instead of %d)\n",
1011 bit_count, count1 + count2 ));
1012
1013 /* simply ignore the operator */
1014 return;
1015 }
1016
1017 /* set-up new horizontal and vertical hint mask now */
1018 error = ps_dimension_set_mask_bits( &dim[0], bytes, count2, count1,
1019 end_point, memory );
1020 if ( error )
1021 goto Fail;
1022
1023 error = ps_dimension_set_mask_bits( &dim[1], bytes, 0, count2,
1024 end_point, memory );
1025 if ( error )
1026 goto Fail;
1027 }
1028 return;
1029
1030 Fail:
1031 hints->error = error;
1032 }

Referenced by t2_hints_funcs_init().

◆ ps_mask_clear_bit()

static void ps_mask_clear_bit ( PS_Mask  mask,
FT_UInt  idx 
)
static

Definition at line 168 of file pshrec.c.

170 {
171 FT_Byte* p;
172
173
174 if ( idx >= mask->num_bits )
175 return;
176
177 p = mask->bytes + ( idx >> 3 );
178 p[0] = (FT_Byte)( p[0] & ~( 0x80 >> ( idx & 7 ) ) );
179 }
unsigned char FT_Byte
Definition: fttypes.h:154
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by ps_mask_table_merge().

◆ ps_mask_done()

static void ps_mask_done ( PS_Mask  mask,
FT_Memory  memory 
)
static

Definition at line 123 of file pshrec.c.

125 {
126 FT_FREE( mask->bytes );
127 mask->num_bits = 0;
128 mask->max_bits = 0;
129 mask->end_point = 0;
130 }

Referenced by ps_mask_table_done().

◆ ps_mask_ensure()

static FT_Error ps_mask_ensure ( PS_Mask  mask,
FT_UInt  count,
FT_Memory  memory 
)
static

Definition at line 135 of file pshrec.c.

138 {
139 FT_UInt old_max = ( mask->max_bits + 7 ) >> 3;
140 FT_UInt new_max = ( count + 7 ) >> 3;
142
143
144 if ( new_max > old_max )
145 {
146 new_max = FT_PAD_CEIL( new_max, 8 );
147 if ( !FT_RENEW_ARRAY( mask->bytes, old_max, new_max ) )
148 mask->max_bits = new_max * 8;
149 }
150 return error;
151 }

Referenced by ps_mask_set_bit(), ps_mask_table_merge(), and ps_mask_table_set_bits().

◆ ps_mask_set_bit()

static FT_Error ps_mask_set_bit ( PS_Mask  mask,
FT_UInt  idx,
FT_Memory  memory 
)
static

Definition at line 184 of file pshrec.c.

187 {
189 FT_Byte* p;
190
191
192 if ( idx >= mask->num_bits )
193 {
195 if ( error )
196 goto Exit;
197
198 mask->num_bits = idx + 1;
199 }
200
201 p = mask->bytes + ( idx >> 3 );
202 p[0] = (FT_Byte)( p[0] | ( 0x80 >> ( idx & 7 ) ) );
203
204 Exit:
205 return error;
206 }
static FT_Error ps_mask_ensure(PS_Mask mask, FT_UInt count, FT_Memory memory)
Definition: pshrec.c:135

Referenced by ps_dimension_add_counter(), and ps_dimension_add_t1stem().

◆ ps_mask_table_alloc()

static FT_Error ps_mask_table_alloc ( PS_Mask_Table  table,
FT_Memory  memory,
PS_Mask amask 
)
static

Definition at line 250 of file pshrec.c.

253 {
256 PS_Mask mask = NULL;
257
258
259 count = table->num_masks;
260 count++;
261
262 if ( count > table->max_masks )
263 {
265 if ( error )
266 goto Exit;
267 }
268
269 mask = table->masks + count - 1;
270 mask->num_bits = 0;
271 mask->end_point = 0;
272 table->num_masks = count;
273
274 Exit:
275 *amask = mask;
276 return error;
277 }
DWORD amask
Definition: surface.c:189
static FT_Error ps_mask_table_ensure(PS_Mask_Table table, FT_UInt count, FT_Memory memory)
Definition: pshrec.c:229

Referenced by ps_dimension_add_counter(), ps_dimension_reset_mask(), and ps_mask_table_last().

◆ ps_mask_table_done()

static void ps_mask_table_done ( PS_Mask_Table  table,
FT_Memory  memory 
)
static

Definition at line 211 of file pshrec.c.

213 {
214 FT_UInt count = table->max_masks;
215 PS_Mask mask = table->masks;
216
217
218 for ( ; count > 0; count--, mask++ )
220
221 FT_FREE( table->masks );
222 table->num_masks = 0;
223 table->max_masks = 0;
224 }
static void ps_mask_done(PS_Mask mask, FT_Memory memory)
Definition: pshrec.c:123

Referenced by ps_dimension_done().

◆ ps_mask_table_ensure()

static FT_Error ps_mask_table_ensure ( PS_Mask_Table  table,
FT_UInt  count,
FT_Memory  memory 
)
static

Definition at line 229 of file pshrec.c.

232 {
233 FT_UInt old_max = table->max_masks;
234 FT_UInt new_max = count;
236
237
238 if ( new_max > old_max )
239 {
240 new_max = FT_PAD_CEIL( new_max, 8 );
241 if ( !FT_RENEW_ARRAY( table->masks, old_max, new_max ) )
242 table->max_masks = new_max;
243 }
244 return error;
245 }

Referenced by ps_mask_table_alloc().

◆ ps_mask_table_last()

static FT_Error ps_mask_table_last ( PS_Mask_Table  table,
FT_Memory  memory,
PS_Mask amask 
)
static

Definition at line 282 of file pshrec.c.

285 {
289
290
291 count = table->num_masks;
292 if ( count == 0 )
293 {
295 if ( error )
296 goto Exit;
297 }
298 else
299 mask = table->masks + count - 1;
300
301 Exit:
302 *amask = mask;
303 return error;
304 }

Referenced by ps_dimension_add_t1stem(), and ps_mask_table_set_bits().

◆ ps_mask_table_merge()

static FT_Error ps_mask_table_merge ( PS_Mask_Table  table,
FT_UInt  index1,
FT_UInt  index2,
FT_Memory  memory 
)
static

Definition at line 402 of file pshrec.c.

406 {
408
409
410 /* swap index1 and index2 so that index1 < index2 */
411 if ( index1 > index2 )
412 {
414
415
416 temp = index1;
417 index1 = index2;
418 index2 = temp;
419 }
420
421 if ( index1 < index2 && index2 < table->num_masks )
422 {
423 /* we need to merge the bitsets of index1 and index2 with a */
424 /* simple union */
425 PS_Mask mask1 = table->masks + index1;
426 PS_Mask mask2 = table->masks + index2;
427 FT_UInt count1 = mask1->num_bits;
428 FT_UInt count2 = mask2->num_bits;
429 FT_Int delta;
430
431
432 if ( count2 > 0 )
433 {
434 FT_UInt pos;
435 FT_Byte* read;
436 FT_Byte* write;
437
438
439 /* if "count2" is greater than "count1", we need to grow the */
440 /* first bitset, and clear the highest bits */
441 if ( count2 > count1 )
442 {
443 error = ps_mask_ensure( mask1, count2, memory );
444 if ( error )
445 goto Exit;
446
447 for ( pos = count1; pos < count2; pos++ )
448 ps_mask_clear_bit( mask1, pos );
449 }
450
451 /* merge (unite) the bitsets */
452 read = mask2->bytes;
453 write = mask1->bytes;
454 pos = ( count2 + 7 ) >> 3;
455
456 for ( ; pos > 0; pos-- )
457 {
458 write[0] = (FT_Byte)( write[0] | read[0] );
459 write++;
460 read++;
461 }
462 }
463
464 /* Now, remove "mask2" from the list. We need to keep the masks */
465 /* sorted in order of importance, so move table elements. */
466 mask2->num_bits = 0;
467 mask2->end_point = 0;
468
469 /* number of masks to move */
470 delta = (FT_Int)( table->num_masks - 1 - index2 );
471 if ( delta > 0 )
472 {
473 /* move to end of table for reuse */
474 PS_MaskRec dummy = *mask2;
475
476
477 ft_memmove( mask2,
478 mask2 + 1,
479 (FT_UInt)delta * sizeof ( PS_MaskRec ) );
480
481 mask2[delta] = dummy;
482 }
483
484 table->num_masks--;
485 }
486 else
487 FT_TRACE0(( "ps_mask_table_merge: ignoring invalid indices (%d,%d)\n",
488 index1, index2 ));
489
490 Exit:
491 return error;
492 }
#define read
Definition: acwin.h:96
#define write
Definition: acwin.h:97
#define ft_memmove
Definition: ftstdlib.h:83
static void ps_mask_clear_bit(PS_Mask mask, FT_UInt idx)
Definition: pshrec.c:168
static calc_node_t temp
Definition: rpn_ieee.c:38
FT_UInt num_bits
Definition: pshrec.h:95
FT_Byte * bytes
Definition: pshrec.h:97

Referenced by ps_mask_table_merge_all().

◆ ps_mask_table_merge_all()

static FT_Error ps_mask_table_merge_all ( PS_Mask_Table  table,
FT_Memory  memory 
)
static

Definition at line 499 of file pshrec.c.

501 {
502 FT_Int index1, index2;
504
505
506 /* both loops go down to 0, thus FT_Int for index1 and index2 */
507 for ( index1 = (FT_Int)table->num_masks - 1; index1 > 0; index1-- )
508 {
509 for ( index2 = index1 - 1; index2 >= 0; index2-- )
510 {
512 (FT_UInt)index1,
513 (FT_UInt)index2 ) )
514 {
516 (FT_UInt)index2,
517 (FT_UInt)index1,
518 memory );
519 if ( error )
520 goto Exit;
521
522 break;
523 }
524 }
525 }
526
527 Exit:
528 return error;
529 }
static FT_Int ps_mask_table_test_intersect(PS_Mask_Table table, FT_UInt index1, FT_UInt index2)
Definition: pshrec.c:370
static FT_Error ps_mask_table_merge(PS_Mask_Table table, FT_UInt index1, FT_UInt index2, FT_Memory memory)
Definition: pshrec.c:402

Referenced by ps_dimension_end().

◆ ps_mask_table_set_bits()

static FT_Error ps_mask_table_set_bits ( PS_Mask_Table  table,
const FT_Byte source,
FT_UInt  bit_pos,
FT_UInt  bit_count,
FT_Memory  memory 
)
static

Definition at line 309 of file pshrec.c.

314 {
317
318
320 if ( error )
321 goto Exit;
322
323 error = ps_mask_ensure( mask, bit_count, memory );
324 if ( error )
325 goto Exit;
326
327 mask->num_bits = bit_count;
328
329 /* now, copy bits */
330 {
331 FT_Byte* read = (FT_Byte*)source + ( bit_pos >> 3 );
332 FT_Int rmask = 0x80 >> ( bit_pos & 7 );
333 FT_Byte* write = mask->bytes;
334 FT_Int wmask = 0x80;
335 FT_Int val;
336
337
338 for ( ; bit_count > 0; bit_count-- )
339 {
340 val = write[0] & ~wmask;
341
342 if ( read[0] & rmask )
343 val |= wmask;
344
345 write[0] = (FT_Byte)val;
346
347 rmask >>= 1;
348 if ( rmask == 0 )
349 {
350 read++;
351 rmask = 0x80;
352 }
353
354 wmask >>= 1;
355 if ( wmask == 0 )
356 {
357 write++;
358 wmask = 0x80;
359 }
360 }
361 }
362
363 Exit:
364 return error;
365 }
DWORD rmask
Definition: surface.c:186
GLuint GLfloat * val
Definition: glext.h:7180

Referenced by ps_dimension_set_mask_bits().

◆ ps_mask_table_test_intersect()

static FT_Int ps_mask_table_test_intersect ( PS_Mask_Table  table,
FT_UInt  index1,
FT_UInt  index2 
)
static

Definition at line 370 of file pshrec.c.

373 {
374 PS_Mask mask1 = table->masks + index1;
375 PS_Mask mask2 = table->masks + index2;
376 FT_Byte* p1 = mask1->bytes;
377 FT_Byte* p2 = mask2->bytes;
378 FT_UInt count1 = mask1->num_bits;
379 FT_UInt count2 = mask2->num_bits;
381
382
383 count = FT_MIN( count1, count2 );
384 for ( ; count >= 8; count -= 8 )
385 {
386 if ( p1[0] & p2[0] )
387 return 1;
388
389 p1++;
390 p2++;
391 }
392
393 if ( count == 0 )
394 return 0;
395
396 return ( p1[0] & p2[0] ) & ~( 0xFF >> count );
397 }
#define FT_MIN(a, b)
Definition: ftobjs.h:70

Referenced by ps_mask_table_merge_all().

◆ ps_mask_test_bit()

static FT_Int ps_mask_test_bit ( PS_Mask  mask,
FT_Int  idx 
)
static

Definition at line 156 of file pshrec.c.

158 {
159 if ( (FT_UInt)idx >= mask->num_bits )
160 return 0;
161
162 return mask->bytes[idx >> 3] & ( 0x80 >> ( idx & 7 ) );
163 }

Referenced by ps_dimension_add_counter().

◆ t1_hints_funcs_init()

t1_hints_funcs_init ( T1_Hints_FuncsRec funcs)

Definition at line 1140 of file pshrec.c.

1141 {
1142 FT_ZERO( funcs );
1143
1150 }
void(* T1_Hints_SetStemFunc)(T1_Hints hints, FT_UInt dimension, FT_Fixed *coords)
Definition: pshints.h:178
void(* T1_Hints_OpenFunc)(T1_Hints hints)
Definition: pshints.h:138
void(* T1_Hints_SetStem3Func)(T1_Hints hints, FT_UInt dimension, FT_Fixed *coords)
Definition: pshints.h:212
FT_Error(* T1_Hints_CloseFunc)(T1_Hints hints, FT_UInt end_point)
Definition: pshints.h:265
FT_Error(* T1_Hints_ApplyFunc)(T1_Hints hints, FT_Outline *outline, PSH_Globals globals, FT_Render_Mode hint_mode)
Definition: pshints.h:304
void(* T1_Hints_ResetFunc)(T1_Hints hints, FT_UInt end_point)
Definition: pshints.h:236
FT_Error ps_hints_apply(PS_Hints ps_hints, FT_Outline *outline, PSH_Globals globals, FT_Render_Mode hint_mode)
Definition: pshalgo.c:2069
static void t1_hints_open(T1_Hints hints)
Definition: pshrec.c:1119
static FT_Error ps_hints_close(PS_Hints hints, FT_UInt end_point)
Definition: pshrec.c:1082
static void t1_hints_stem(T1_Hints hints, FT_UInt dimension, FT_Fixed *coords)
Definition: pshrec.c:1125
static void ps_hints_t1stem3(PS_Hints hints, FT_UInt dimension, FT_Fixed *stems)
Definition: pshrec.c:888
static void ps_hints_t1reset(PS_Hints hints, FT_UInt end_point)
Definition: pshrec.c:951
static struct __wine_debug_functions funcs
Definition: debug.c:48

Referenced by ps_hinter_init().

◆ t1_hints_open()

static void t1_hints_open ( T1_Hints  hints)
static

Definition at line 1119 of file pshrec.c.

1120 {
1122 }
static void ps_hints_open(PS_Hints hints, PS_Hint_Type hint_type)
Definition: pshrec.c:827

Referenced by t1_hints_funcs_init().

◆ t1_hints_stem()

static void t1_hints_stem ( T1_Hints  hints,
FT_UInt  dimension,
FT_Fixed coords 
)
static

Definition at line 1125 of file pshrec.c.

1128 {
1129 FT_Pos stems[2];
1130
1131
1132 stems[0] = FIXED_TO_INT( coords[0] );
1133 stems[1] = FIXED_TO_INT( coords[1] );
1134
1135 ps_hints_stem( (PS_Hints)hints, dimension, 1, stems );
1136 }
FT_BEGIN_HEADER typedef signed long FT_Pos
Definition: ftimage.h:57
GLuint coords
Definition: glext.h:7368
static void ps_hints_stem(PS_Hints hints, FT_UInt dimension, FT_Int count, FT_Long *stems)
Definition: pshrec.c:840

Referenced by t1_hints_funcs_init().

◆ t2_hints_funcs_init()

t2_hints_funcs_init ( T2_Hints_FuncsRec funcs)

Definition at line 1206 of file pshrec.c.

1207 {
1208 FT_ZERO( funcs );
1209
1216 }
FT_Error(* T2_Hints_CloseFunc)(T2_Hints hints, FT_UInt end_point)
Definition: pshints.h:579
void(* T2_Hints_CounterFunc)(T2_Hints hints, FT_UInt bit_count, const FT_Byte *bytes)
Definition: pshints.h:549
void(* T2_Hints_StemsFunc)(T2_Hints hints, FT_UInt dimension, FT_Int count, FT_Fixed *coordinates)
Definition: pshints.h:465
void(* T2_Hints_OpenFunc)(T2_Hints hints)
Definition: pshints.h:425
void(* T2_Hints_MaskFunc)(T2_Hints hints, FT_UInt end_point, FT_UInt bit_count, const FT_Byte *bytes)
Definition: pshints.h:507
FT_Error(* T2_Hints_ApplyFunc)(T2_Hints hints, FT_Outline *outline, PSH_Globals globals, FT_Render_Mode hint_mode)
Definition: pshints.h:617
static void ps_hints_t2mask(PS_Hints hints, FT_UInt end_point, FT_UInt bit_count, const FT_Byte *bytes)
Definition: pshrec.c:990
static void t2_hints_stems(T2_Hints hints, FT_UInt dimension, FT_Int count, FT_Fixed *coords)
Definition: pshrec.c:1169
static void ps_hints_t2counter(PS_Hints hints, FT_UInt bit_count, const FT_Byte *bytes)
Definition: pshrec.c:1036
static void t2_hints_open(T2_Hints hints)
Definition: pshrec.c:1162

Referenced by ps_hinter_init().

◆ t2_hints_open()

static void t2_hints_open ( T2_Hints  hints)
static

Definition at line 1162 of file pshrec.c.

1163 {
1165 }
@ PS_HINT_TYPE_2
Definition: pshrec.h:57

Referenced by t2_hints_funcs_init().

◆ t2_hints_stems()

static void t2_hints_stems ( T2_Hints  hints,
FT_UInt  dimension,
FT_Int  count,
FT_Fixed coords 
)
static

Definition at line 1169 of file pshrec.c.

1173 {
1174 FT_Pos stems[32], y;
1175 FT_Int total = count, n;
1176
1177
1178 y = 0;
1179 while ( total > 0 )
1180 {
1181 /* determine number of stems to write */
1182 count = total;
1183 if ( count > 16 )
1184 count = 16;
1185
1186 /* compute integer stem positions in font units */
1187 for ( n = 0; n < count * 2; n++ )
1188 {
1189 y = ADD_LONG( y, coords[n] );
1190 stems[n] = FIXED_TO_INT( y );
1191 }
1192
1193 /* compute lengths */
1194 for ( n = 0; n < count * 2; n += 2 )
1195 stems[n + 1] = stems[n + 1] - stems[n];
1196
1197 /* add them to the current dimension */
1198 ps_hints_stem( (PS_Hints)hints, dimension, count, stems );
1199
1200 total -= count;
1201 }
1202 }
#define ADD_LONG(a, b)
Definition: ftcalc.h:472
size_t total
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLdouble n
Definition: glext.h:7729

Referenced by t2_hints_funcs_init().