68
67
#include "linutil.h"
70
extern Word8 *EVN_GetSegmentPool (void);
71
//#include "Autofont.H"
69
extern uchar *EVN_GetSegmentPool (void);
72
70
#include "tm.h" //NB 4.4.95
73
71
#include "diffrb.h"
75
72
#include "p2libr.h"
76
73
#include "status.h"
78
75
#include "compat_defs.h"
80
extern BYTE digital_string_penalty;
77
extern uchar digital_string_penalty;
79
static int32_t * AK_deb;
83
80
/*============ Import functions ==================*/
84
BOOL test_alphabet_elem(BYTE let);
86
INT Diskrim(BYTE let,PBYTE raster,INT dw,INT x,INT y,INT dx,INT dy,BYTE cg,INT inc);
87
INT discr_angles(BYTE let, INT dy, INT type);
88
void init_diskrim(PBYTE r,INT h,INT w);
89
void calc_angles(struct rst *rast,PBYTE p,BYTE ang[],BYTE cflgl,BYTE cflgr);
90
BOOL snap_show_raster(PBYTE raster, INT height, INT width);
92
INT SumIntervalBits( BYTE *r, INT bx, INT ex);
93
INT NumHorizInterval( BYTE *r, INT );
94
INT corner_type(BYTE crn);
95
INT cut_by_pos_ii(s_glue * gl,BYTE let);
81
Bool test_alphabet_elem(uchar let);
83
int16_t Diskrim(uchar let,puchar raster,int16_t dw,int16_t x,int16_t y,int16_t dx,int16_t dy,uchar cg,int16_t inc);
84
int16_t discr_angles(uchar let, int16_t dy, int16_t type);
85
void init_diskrim(puchar r,int16_t h,int16_t w);
86
void calc_angles(struct rst *rast,puchar p,uchar ang[],uchar cflgl,uchar cflgr);
87
Bool snap_show_raster(puchar raster, int16_t height, int16_t width);
89
int16_t SumIntervalBits( uchar *r, int16_t bx, int16_t ex);
90
int16_t NumHorizInterval( uchar *r, int16_t );
91
int16_t corner_type(uchar crn);
92
int16_t cut_by_pos_ii(s_glue * gl,uchar let);
97
94
/*============ Export functions ==================*/
99
segment * go_line(segment * seg_pool,WORD ln);
100
void proc_bI(INT pass); // glue '�'
101
INT chkquocks2(cell * c,PBYTE r,INT h,INT w,INT d);
102
void c_add_raster(PBYTE target,INT wb,INT y,INT col,PBYTE source,
96
segment * go_line(segment * seg_pool,uint16_t ln);
97
void proc_bI(int16_t pass); // glue '�'
98
int16_t chkquocks2(cell * c,puchar r,int16_t h,int16_t w,int16_t d);
99
void c_add_raster(puchar target,int16_t wb,int16_t y,int16_t col,puchar source,
100
int16_t sh,int16_t swb);
104
101
struct rst create_raster(cell * c, const s_glue * gl);
105
102
/*========== Local functions ===================*/
108
static INT RE_rus_Ge(INT hist[], INT histd[], INT hei, INT wid);
105
static int16_t RE_rus_Ge(int16_t hist[], int16_t histd[], int16_t hei, int16_t wid);
109
106
static void RE_final_descr(cell *c);
110
static BOOL similar_S( INT hist_n[],INT hist_d[], INT w,INT h);
111
static BOOL similar_R( INT hist_n[],INT h);
112
static INT check_kk(INT h);
113
static INT short_lines2(cell * c);
114
static BOOL check_dnri_hook( s_glue *s, cell * c );
115
static BOOL check_dnri_hook_cell( cell * c , INT w);
116
static BOOL check_upri_hook_cell( cell * c );
117
static BOOL check_uple_hook_cell( cell * c );
118
static BOOL dust_in_glue( cell *s,s_glue *GL,INT c1,INT r1,INT c2, INT r2);
119
static BOOL dust_near_rusG(cell *cc);
120
static void adjust_left(PBYTE pint,INT height);
121
static void calc_data(PBYTE pint,INT height,INT width );
122
static INT discr_iot(cell * c,BYTE let,INT upper);
107
static Bool similar_S( int16_t hist_n[],int16_t hist_d[], int16_t w,int16_t h);
108
static Bool similar_R( int16_t hist_n[],int16_t h);
109
static int16_t check_kk(int16_t h);
110
static int16_t short_lines2(cell * c);
111
static Bool check_dnri_hook( s_glue *s, cell * c );
112
static Bool check_dnri_hook_cell( cell * c , int16_t w);
113
static Bool check_upri_hook_cell( cell * c );
114
static Bool check_uple_hook_cell( cell * c );
115
static Bool dust_in_glue( cell *s,s_glue *GL,int16_t c1,int16_t r1,int16_t c2, int16_t r2);
116
static Bool dust_near_rusG(cell *cc);
117
static void adjust_left(puchar pint,int16_t height);
118
static void calc_data(puchar pint,int16_t height,int16_t width );
119
static int16_t discr_iot(cell * c,uchar let,int16_t upper);
123
120
static void _init_(void);
124
static INT sym_italic( cell * c,BYTE let );
125
static BOOL valid_inc( WORD inc );
126
static WORD check_inc_foots(cell * c,INT nums);
127
static INT calc_dest_foot(INT h,INT w,INT *dest_foot,INT wid_foot);
128
static WORD check_num_foots(INT nums,INT h);
129
static INT check_cursiv_inp(BYTE *rast,INT w,INT h,INT foot_wid,INT dest,BYTE let);
130
static BOOL check_bend_up( cell * c );
131
static BOOL check_bend_dn( cell * c );
132
static INT multicell_hist(cell *base_c, const s_glue *GL,
133
INT hist_n[], INT hist_d[]);
134
static void add_cell_to_hist(cell *c,INT off_str,INT hist_n[],INT hist_d[]);
135
static void make_white_hist(PBYTE pint,INT height);
136
static void calc_abris(PBYTE pint,INT height );
137
static BOOL valid_line(segment * segm);
138
static INT triangle_bottom(BYTE *raster,INT dx, INT dy, INT wid);
139
static INT triangle_top(BYTE *raster,INT dx, INT dy, INT wid);
140
static WORD internal_filling(segment * segm,INT h,INT w);
141
static BOOL stick_online(cell * c);
142
static BOOL suspect_italic_iee(void);
143
static BOOL suspect_italic_tche(void);
144
static BOOL suspect_italic_ii(void);
145
static BOOL suspect_italic_III(cell*);
146
static BOOL suspect_italic_kk(void);
147
static BOOL suspect_italic_ce(cell *c);
148
static BOOL suspect_italic_III_bend(cell * c);
149
static INT o_symmetric(INT h,INT w);
121
static int16_t sym_italic( cell * c,uchar let );
122
static Bool valid_inc( uint16_t inc );
123
static uint16_t check_inc_foots(cell * c,int16_t nums);
124
static int16_t calc_dest_foot(int16_t h,int16_t w,int16_t *dest_foot,int16_t wid_foot);
125
static uint16_t check_num_foots(int16_t nums,int16_t h);
126
static int16_t check_cursiv_inp(uchar *rast,int16_t w,int16_t h,int16_t foot_wid,int16_t dest,uchar let);
127
static Bool check_bend_up( cell * c );
128
static Bool check_bend_dn( cell * c );
129
static int16_t multicell_hist(cell *base_c, const s_glue *GL,
130
int16_t hist_n[], int16_t hist_d[]);
131
static void add_cell_to_hist(cell *c,int16_t off_str,int16_t hist_n[],int16_t hist_d[]);
132
static void make_white_hist(puchar pint,int16_t height);
133
static void calc_abris(puchar pint,int16_t height );
134
static Bool valid_line(segment * segm);
135
static int16_t triangle_bottom(uchar *raster,int16_t dx, int16_t dy, int16_t wid);
136
static int16_t triangle_top(uchar *raster,int16_t dx, int16_t dy, int16_t wid);
137
static uint16_t internal_filling(segment * segm,int16_t h,int16_t w);
138
static Bool stick_online(cell * c);
139
static Bool suspect_italic_iee(void);
140
static Bool suspect_italic_tche(void);
141
static Bool suspect_italic_ii(void);
142
static Bool suspect_italic_III(cell*);
143
static Bool suspect_italic_kk(void);
144
static Bool suspect_italic_ce(cell *c);
145
static Bool suspect_italic_III_bend(cell * c);
146
static int16_t o_symmetric(int16_t h,int16_t w);
151
static WORD check_III(cell *c,INT foot_wid,INT dest[]);
152
static WORD check_III_bend(cell *c,INT dest[]);
153
static WORD check_futuris_aa(struct rst * const rst);
154
static WORD check_EK(BYTE let,cell * c);
155
static WORD check_tg( cell * c, BYTE let, PBYTE RASTR, INT dx, INT dy );
156
static WORD check_ya( cell * c);
157
static WORD check_zz( cell * c);
158
static WORD check_xX( cell * c);
159
static WORD check_xk(INT h,BYTE let) ;
160
static WORD check_pl( cell * cc, cell * ci,BYTE let,struct rst * const rst);
161
static WORD check_iee( cell * c,BYTE let);
162
static WORD check_oa( cell * c,BYTE let,struct rst * const rst);
163
static WORD check_ee( cell * c);
164
static WORD check_uu( cell * c,INT h);
165
//static WORD check_ss(cell * c,PBYTE pint,INT height);
166
static WORD check_veza(cell * c,segment * segm,INT h,INT w,BYTE let);
167
static WORD check_nn(cell * c);
168
static WORD check_m( cell * c);
169
static WORD check_AL(cell * c,BYTE let);
170
static WORD check_stick( cell * c,BYTE let );
171
static WORD check_cursiv( cell * c,BYTE let,INT old_diskr,BYTE *rast);
172
static WORD stick_bI(cell * cl);
173
static INT check_italic_ch(INT h);
174
static WORD check_I_dot(cell * c,BYTE let); // !
175
static WORD check_bb(void);
148
static uint16_t check_III(cell *c,int16_t foot_wid,int16_t dest[]);
149
static uint16_t check_III_bend(cell *c,int16_t dest[]);
150
static uint16_t check_futuris_aa(struct rst * const rst);
151
static uint16_t check_EK(uchar let,cell * c);
152
static uint16_t check_tg( cell * c, uchar let, puchar RASTR, int16_t dx, int16_t dy );
153
static uint16_t check_ya( cell * c);
154
static uint16_t check_zz( cell * c);
155
static uint16_t check_xX( cell * c);
156
static uint16_t check_xk(int16_t h,uchar let) ;
157
static uint16_t check_pl( cell * cc, cell * ci,uchar let,struct rst * const rst);
158
static uint16_t check_iee( cell * c,uchar let);
159
static uint16_t check_oa( cell * c,uchar let,struct rst * const rst);
160
static uint16_t check_ee( cell * c);
161
static uint16_t check_uu( cell * c,int16_t h);
162
//static uint16_t check_ss(cell * c,puchar pint,int16_t height);
163
static uint16_t check_veza(cell * c,segment * segm,int16_t h,int16_t w,uchar let);
164
static uint16_t check_nn(cell * c);
165
static uint16_t check_m( cell * c);
166
static uint16_t check_AL(cell * c,uchar let);
167
static uint16_t check_stick( cell * c,uchar let );
168
static uint16_t check_cursiv( cell * c,uchar let,int16_t old_diskr,uchar *rast);
169
static uint16_t stick_bI(cell * cl);
170
static int16_t check_italic_ch(int16_t h);
171
static uint16_t check_I_dot(cell * c,uchar let); // !
172
static uint16_t check_bb(void);
177
174
/*========== Import global data ===================*/
179
extern BYTE db_status ; // snap presence byte
180
extern BYTE db_trace_flag; // snap-detail presence byte
181
extern BYTE db_pass ; // snap-pass indicator
183
extern BYTE broken_flag ; // broken raster discrim safety
184
extern BYTE broken_ii ; // two sticks flag for rus discr
186
extern BYTE work_raster[];
187
extern BYTE work_raster_1[];
189
/*extern*/ BYTE *segment_pool;
176
extern uchar db_status ; // snap presence byte
177
extern uchar db_trace_flag; // snap-detail presence byte
178
extern uchar db_pass ; // snap-pass indicator
180
extern uchar broken_flag ; // broken raster discrim safety
181
extern uchar broken_ii ; // two sticks flag for rus discr
183
extern uchar work_raster[];
184
extern uchar work_raster_1[];
185
extern int16_t iFont;
186
/*extern*/ uchar *segment_pool;
191
188
/*========= Global data ===================*/
193
190
/*========= Local data ===================*/
194
static BYTE Rus_similar_Eng[]="��rn$痐";//"��rNn$痐";
195
static BYTE abris_online;
196
static BYTE corners[4];
197
static INT hist_n[128],hist_d[128];/* � ���ࢠ��� � ��ப� � ���⭮��� */
198
static INT hist_white[128]; /* ����ﭨ� ����� 1-�� � ��ன ������ */
199
static INT hist_black[128]; /* ����� 1-�� ����� */
200
static BYTE rus_like[]="�"; // "���"
201
static BYTE emu_like[]="x"; // "oOx"
191
static uchar Rus_similar_Eng[]="��rn$痐";//"��rNn$痐";
192
static uchar abris_online;
193
static uchar corners[4];
194
static int16_t hist_n[128],hist_d[128];/* � ���ࢠ��� � ��ப� � ���⭮��� */
195
static int16_t hist_white[128]; /* ����ﭨ� ����� 1-�� � ��ன ������ */
196
static int16_t hist_black[128]; /* ����� 1-�� ����� */
197
static uchar rus_like[]="�"; // "���"
198
static uchar emu_like[]="x"; // "oOx"
202
199
static STICK *stick; // pointer to array of stick if NULL no calculated stick
203
200
static STICK stic[30];
204
static INT nstick; // number of sticks in letter
201
static int16_t nstick; // number of sticks in letter
202
static uint16_t dens;
206
203
static s_glue glc;
208
static INT l_abris[80],r_abris[80];
205
static int16_t l_abris[80],r_abris[80];
210
INT dnri_hook, top_dnri_hook;// bootom right hook samll russian italic letters III,II
211
INT upri_hook, bot_upri_hook;
212
INT uple_hook, bot_uple_hook;
207
int16_t dnri_hook, top_dnri_hook;// bootom right hook samll russian italic letters III,II
208
int16_t upri_hook, bot_upri_hook;
209
int16_t uple_hook, bot_uple_hook;
215
212
number of foots < 16 +