62
62
#include "difdefs.h"
64
64
#include "minmax.h"
65
extern Word8 broken_flag;
66
Word8 rec5_flag=1,font_type=0,omni=1;
67
Int16 NumVertInterval(Word8 *RASTER,Int16 D_X, Int16 dy, Int16 i);
68
Int16 VertSum(Word8 *rastr,Int16 D_X, Int16 dy, Int16 i);
69
Int16 SumBits(Word8 *rastr,Int16 D_X);
70
Int16 NumHorizInterval(Word8 *,Int16);
71
Int16 FOOT(Word8 *raster,Int16 DX,Word8 dx,Word8 Ly,
73
Int16 FOOT3( Word8 *RASTER, Int16 Wx, Word8 START, Word8 NWIDTH, Word8 NLENGTH, Int16 SHIFT);
74
Int16 EndBlackInterval(Word8 *RASTER, Int16 NWIDTH);
75
Int16 FOOT3_2( Word8 *RASTER, Int16 Wx, Word8 NWIDTH, Word8 NLENGTH);
76
Int16 FOOT_HEI( Word8 *RASTER, Int16 Wx, Word8 NWIDTH, Word8 NLENGTH);
78
Int16 MinMaxLeft( Word8 *RASTER, Int16 Wx, Word8 NWIDTH, Word8 NHEIGHT,
79
Int16 *Pmin, Int16 *Pmax);
80
Int16 MinMaxRight( Word8 *RASTER, Int16 Wx, Word8 NWIDTH, Word8 NHEIGHT,
81
Int16 *Pmin, Int16 *Pmax);
82
Int16 DiskrRight(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 dy,Int16 L);
83
Int16 Num2Interval(Word8 *r,Int16 D_X,Int16 dx,Int16 dy);
84
Int16 broken_M(Word8 * r,Int16 D_X,Int16 dy,Int16 left_lim,Int16 ll);
85
Int16 FOOT_A(Word8 *raster,Int16 DX,Word8 dx,Word8 Ly);
86
Int16 fill_center_zone(Word8 *raster,Int16 D_X,Int16 dy,
87
Int16 beg, Int16 end, Int16 II);
88
Int16 up_down_hist_M(Word8 *rastr,Int16 D_X, Int16 Dx,Int16 dy);
89
Int16 small_density(Word8 *RAST,Int16 n,Int16 D_X,Int16 bw);
90
Int16 LeftDistance(Word8 *RASTER,Int16 dx);
91
Int16 RightDistance(Word8 *RASTER,Int16 dx);
92
Int16 SumIntervalBits(Word8 *RASTER,Int16 bx,Int16 ex);
93
Int16 CenterVertInterval(Word8 *,Int16 ,Int16 ,Int16, Int16 *,Int16 *);
94
void init_diskrim(Word8* raster,Int16 height ,Int16 width);
95
Int16 DiskrLeftBig(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 dy, Int16 L);
96
Int16 DiskrRightBig(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 dy,Int16 L);
98
static void DiskrIN(Word8 *RASTR,Int16 D_X,Int16 dy, Int16 wb,Int16 dx);
99
static Int16 DiskrHorizIN(Word8 *RASTR,Int16 D_X,Int16 dy);
100
Int16 no_serific(Word8 *RASTR,Int16 dy,Int16 dx,Int16 wb);
65
extern uchar broken_flag;
66
uchar rec5_flag=1,font_type=0,omni=1;
67
int16_t NumVertInterval(uchar *RASTER,int16_t D_X, int16_t dy, int16_t i);
68
int16_t VertSum(uchar *rastr,int16_t D_X, int16_t dy, int16_t i);
69
int16_t SumBits(uchar *rastr,int16_t D_X);
70
int16_t NumHorizInterval(uchar *,int16_t);
71
int16_t FOOT(uchar *raster,int16_t DX,uchar dx,uchar Ly,
73
int16_t FOOT3( uchar *RASTER, int16_t Wx, uchar START, uchar NWIDTH, uchar NLENGTH, int16_t SHIFT);
74
int16_t EndBlackInterval(uchar *RASTER, int16_t NWIDTH);
75
int16_t FOOT3_2( uchar *RASTER, int16_t Wx, uchar NWIDTH, uchar NLENGTH);
76
int16_t FOOT_HEI( uchar *RASTER, int16_t Wx, uchar NWIDTH, uchar NLENGTH);
78
int16_t MinMaxLeft( uchar *RASTER, int16_t Wx, uchar NWIDTH, uchar NHEIGHT,
79
int16_t *Pmin, int16_t *Pmax);
80
int16_t MinMaxRight( uchar *RASTER, int16_t Wx, uchar NWIDTH, uchar NHEIGHT,
81
int16_t *Pmin, int16_t *Pmax);
82
int16_t DiskrRight(uchar *RASTR,int16_t D_X,int16_t dx,int16_t dy,int16_t L);
83
int16_t Num2Interval(uchar *r,int16_t D_X,int16_t dx,int16_t dy);
84
int16_t broken_M(uchar * r,int16_t D_X,int16_t dy,int16_t left_lim,int16_t ll);
85
int16_t FOOT_A(uchar *raster,int16_t DX,uchar dx,uchar Ly);
86
int16_t fill_center_zone(uchar *raster,int16_t D_X,int16_t dy,
87
int16_t beg, int16_t end, int16_t II);
88
int16_t up_down_hist_M(uchar *rastr,int16_t D_X, int16_t Dx,int16_t dy);
89
int16_t small_density(uchar *RAST,int16_t n,int16_t D_X,int16_t bw);
90
int16_t LeftDistance(uchar *RASTER,int16_t dx);
91
int16_t RightDistance(uchar *RASTER,int16_t dx);
92
int16_t SumIntervalBits(uchar *RASTER,int16_t bx,int16_t ex);
93
int16_t CenterVertInterval(uchar *,int16_t ,int16_t ,int16_t, int16_t *,int16_t *);
94
void init_diskrim(uchar* raster,int16_t height ,int16_t width);
95
int16_t DiskrLeftBig(uchar *RASTR,int16_t D_X,int16_t dx,int16_t dy, int16_t L);
96
int16_t DiskrRightBig(uchar *RASTR,int16_t D_X,int16_t dx,int16_t dy,int16_t L);
98
static void DiskrIN(uchar *RASTR,int16_t D_X,int16_t dy, int16_t wb,int16_t dx);
99
static int16_t DiskrHorizIN(uchar *RASTR,int16_t D_X,int16_t dy);
100
int16_t no_serific(uchar *RASTR,int16_t dy,int16_t dx,int16_t wb);
102
102
#define bytlen(bits) (REC_GW_WORD8(bits))
104
extern Word8 BUFFER[256]; /* ���⨪��쭠� ��o���� */
105
extern Word8 LOCAL[50]; /* ���न���� ��� */
106
extern Word8 LOCAL_W[50]; /* �ਭ� ��� */
107
extern Word8 end1,beg2; /* ����� 1 � ��砫� 2-�� ��� ��� */
104
extern uchar BUFFER[256]; /* ���⨪��쭠� ��o���� */
105
extern uchar LOCAL[50]; /* ���न���� ��� */
106
extern uchar LOCAL_W[50]; /* �ਭ� ��� */
107
extern uchar end1,beg2; /* ����� 1 � ��砫� 2-�� ��� ��� */
108
108
extern broken_ii; /* 䫠� ���� ����� */
109
extern Int16 dnri_hook; // bottom right hook in small russian italic II,III
110
extern Int16 uple_hook; // bottom left hook in small russian italic II,III
111
extern Int16 up_jack ; // upper jack
109
extern int16_t dnri_hook; // bottom right hook in small russian italic II,III
110
extern int16_t uple_hook; // bottom left hook in small russian italic II,III
111
extern int16_t up_jack ; // upper jack
113
static Int16 upper_skip_lines,lower_skip_lines;
114
static Int16 diskr_f2,diskr_tsh,diskr_ii,
113
static int16_t upper_skip_lines,lower_skip_lines;
114
static int16_t diskr_f2,diskr_tsh,diskr_ii,
115
115
diskr_sh,diskr_g,diskr_tsh,diskr_ju,diskr_m,diskr_ii,diskr_p,diskr_N,
116
116
diskr_c, diskr_o, diskr_e,diskr_b,diskr_3,
117
117
IN_N_Bonus,IN_equ,IN_P_Bonus,
118
118
IN_I_Bonus,IN_IN_Monus,IN_dis,diskr_i,diskr_n,IN_N,IN_I,IN_M,IN_pics,
121
Int16 left_dist[4], right_dist[4], num_foot, c_or_e,d_c,d_e,
121
int16_t left_dist[4], right_dist[4], num_foot, c_or_e,d_c,d_e,
122
122
right_max,left_max,left_line,right_line,
123
123
left_dist_big[4], right_dist_big[4],lower_long_line;
124
Int16 av_tl, av_bl,av_br, rotate;
124
int16_t av_tl, av_bl,av_br, rotate;
125
125
/* g-�, sh-�, b-B, k-K, ju-�, f2-���, tsh-�, ii-�, o-O, c-C, e-E,
126
126
h-�, ja-�, z-�, ee-�, d-�, ce-� */
127
Int16 fill_center,up_down_serif,up_down_serif_B,IN_horiz_dis,broken_M_pen;
127
int16_t fill_center,up_down_serif,up_down_serif_B,IN_horiz_dis,broken_M_pen;
129
static Int16 DiskrSymSh( Word8 *RASTER, Int16 Wx, Word8 NWIDTH, Word8 NLENGTH);
130
static Int16 DiskrSh(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 Ly);
131
static Int16 DiskrLeft(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 dy, Int16 L);
132
static Int16 DiskrSh0(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 dy,Int16 dx0);
133
static Int16 DiskrJ0(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 Ly,Int16 lim);
134
static Int16 DiskrJ(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 dy);
135
static Int16 DiskrTsh(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 dy,Int16 Dx);
136
static Int16 average_br_angle(Word8 *RASTER, Int16 D_X, Int16 dx, Int16 dy,Int16 t);
137
static Int16 average_angle(Word8 *RASTER, Int16 D_X, Int16 dx, Int16 dy,
138
Int16 (*Distance)(Word8 *, Int16), Int16 t);
139
static Int16 DiskrJu(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 Ly);
140
static Int16 DiskrimM1(Word8 *RAST,Int16 D_X,Int16 dx,Int16 dy);
141
static Int16 DiskrimM(Word8 *RAST,Int16 D_X,Int16 dx,Int16 dy);
142
static Int16 whiteMeanBitRight(Word8 *RAST,Int16 D_X,Int16 dx,Int16 meanBit);
143
static Int16 whiteMeanBitLeft(Word8 *RAST,Int16 D_X,Int16 meanBit);
144
static Int16 up_down_zones(Word8 *raster, Int16 D_X, Int16 dx, Int16 dx0,
145
Int16 start1, Int16 stop1, Int16 start2, Int16 stop2);
146
static Int16 DiskrVertCE(Word8 *RASTR,Int16 D_X,Int16 dx,Int16 dy,Int16 X,
147
Word8 let, Word8 inc);
148
static Int16 AngleBottomRight(Word8 *raster,Int16 D_X,Int16 hei);
149
static Int16 AngleTopRight(Word8 *raster,Int16 D_X,Int16 hei);
150
static Int16 BonusAnglesCurve(Word8 *raster,Int16 D_X,Int16 dy);
151
static Bool32 DiskrJuCut(Int16 nfoot, Int16 dx);
129
static int16_t DiskrSymSh( uchar *RASTER, int16_t Wx, uchar NWIDTH, uchar NLENGTH);
130
static int16_t DiskrSh(uchar *RASTR,int16_t D_X,int16_t dx,int16_t Ly);
131
static int16_t DiskrLeft(uchar *RASTR,int16_t D_X,int16_t dx,int16_t dy, int16_t L);
132
static int16_t DiskrSh0(uchar *RASTR,int16_t D_X,int16_t dx,int16_t dy,int16_t dx0);
133
static int16_t DiskrJ0(uchar *RASTR,int16_t D_X,int16_t dx,int16_t Ly,int16_t lim);
134
static int16_t DiskrJ(uchar *RASTR,int16_t D_X,int16_t dx,int16_t dy);
135
static int16_t DiskrTsh(uchar *RASTR,int16_t D_X,int16_t dx,int16_t dy,int16_t Dx);
136
static int16_t average_br_angle(uchar *RASTER, int16_t D_X, int16_t dx, int16_t dy,int16_t t);
137
static int16_t average_angle(uchar *RASTER, int16_t D_X, int16_t dx, int16_t dy,
138
int16_t (*Distance)(uchar *, int16_t), int16_t t);
139
static int16_t DiskrJu(uchar *RASTR,int16_t D_X,int16_t dx,int16_t Ly);
140
static int16_t DiskrimM1(uchar *RAST,int16_t D_X,int16_t dx,int16_t dy);
141
static int16_t DiskrimM(uchar *RAST,int16_t D_X,int16_t dx,int16_t dy);
142
static int16_t whiteMeanBitRight(uchar *RAST,int16_t D_X,int16_t dx,int16_t meanBit);
143
static int16_t whiteMeanBitLeft(uchar *RAST,int16_t D_X,int16_t meanBit);
144
static int16_t up_down_zones(uchar *raster, int16_t D_X, int16_t dx, int16_t dx0,
145
int16_t start1, int16_t stop1, int16_t start2, int16_t stop2);
146
static int16_t DiskrVertCE(uchar *RASTR,int16_t D_X,int16_t dx,int16_t dy,int16_t X,
147
uchar let, uchar inc);
148
static int16_t AngleBottomRight(uchar *raster,int16_t D_X,int16_t hei);
149
static int16_t AngleTopRight(uchar *raster,int16_t D_X,int16_t hei);
150
static int16_t BonusAnglesCurve(uchar *raster,int16_t D_X,int16_t dy);
151
static Bool32 DiskrJuCut(int16_t nfoot, int16_t dx);
153
153
/* clear diskrimination flags */
154
void init_diskrim(Word8* raster,Int16 height ,Int16 width)
154
void init_diskrim(uchar* raster,int16_t height ,int16_t width)
156
Int16 i, D_X=bytlen(width);
156
int16_t i, D_X=bytlen(width);
160
160
diskr_f2=diskr_ii=