~ubuntu-branches/ubuntu/precise/cuneiform/precise

« back to all changes in this revision

Viewing changes to cuneiform_src/Kern/rstr/src/diffrv.c

  • Committer: Bazaar Package Importer
  • Author(s): Jakub Wilk, c-assert.diff, slovenian-slv.diff
  • Date: 2011-01-26 21:53:07 UTC
  • mfrom: (5.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20110126215307-62x61mcesr607qb7
Tags: 1.0.0+dfsg-2
* Upload to unstable.
* Explicitly build-depend on pkg-config. Thanks to Stefano Rivera for the
  bug report.
* Add Vcs-* fields.
* Use the standard C assert() macro, rather than custom Cuneiform one.
  [c-assert.diff]
* Pass CFLAGS, CXXFLAGS and LDFLAGS (get from dpkg-buildflags) to cmake
  (closes: #608345). Thanks to Sami Liedes for the bug report.
  + Build depend on dpkg-dev (>= 1.15.7).
* Pass --parallel to dh.
  + Bump debhelper minimum version to 7.4.10.
* Update debian/copyright to the latest DEP-5 version.
* Bump year in debian/copyright.
* Explicitly link to GraphicsMagick (rather than via the ImageMagick
  compatibility layer).
* Don't ship /usr/lib/cuneiform/*.so symlinks. These libraries are
  considered private, at least until #598616 is fixed.
* Rename some private variables in debian/rules to make them lowercase.
* Update patch headers.
* Provide proper ‘build-arch’ and ‘build-indep’ targets in debian/rules.
* Document input format in the manual page (closes: #572061). Thanks to
  Janusz S. Bień for the bug report.
* Use ‘slv’ (rather than ‘slo’) as language code for Slovenian.
  [slovenian-slv.diff]
* Fix package description: Slovenian is supported, Slovak is not.
* Improve documentation of the language (-l) option (closes: #602512).
  Thanks to Jari Aalto for the bug report.
* Install reasons file for vrms.

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
#include <stdlib.h>
60
60
 
61
61
 
62
 
#include "nt_types.h"
63
62
#include "struct.h"
64
63
#include "lang_def.h"
65
64
#include "func.h"
67
66
#include "ligas.h"
68
67
#include "linutil.h"
69
68
#include "tuner.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"
74
 
//#include "sfont.h"
75
72
#include "p2libr.h"
76
73
#include "status.h"
77
74
 
78
75
#include "compat_defs.h"
79
76
 
80
 
extern BYTE digital_string_penalty;
 
77
extern uchar digital_string_penalty;
81
78
//AK for debug
82
 
static LONG * AK_deb;
 
79
static int32_t * AK_deb;
83
80
/*============ Import functions ==================*/
84
 
BOOL test_alphabet_elem(BYTE let);
85
 
 
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);
91
 
 
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);
 
82
 
 
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);
 
88
 
 
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);
96
93
 
97
94
/*============ Export functions ==================*/
98
95
 
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,
103
 
        INT sh,INT swb);
 
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 ===================*/
106
103
 
107
104
 
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);
150
147
/*----*/
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);
176
173
 
177
174
/*========== Import global data ===================*/
178
175
 
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
182
 
 
183
 
extern BYTE broken_flag  ;    // broken raster discrim safety
184
 
extern BYTE broken_ii    ;    // two sticks flag for rus discr
185
 
 
186
 
extern BYTE work_raster[];
187
 
extern BYTE work_raster_1[];
188
 
extern INT iFont;
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
 
179
 
 
180
extern uchar broken_flag  ;    // broken raster discrim safety
 
181
extern uchar broken_ii    ;    // two sticks flag for rus discr
 
182
 
 
183
extern uchar work_raster[];
 
184
extern uchar work_raster_1[];
 
185
extern int16_t iFont;
 
186
/*extern*/ uchar *segment_pool;
190
187
 
191
188
/*========= Global data ===================*/
192
189
 
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
205
 
static WORD dens;
 
201
static int16_t   nstick;       // number of sticks in letter
 
202
static uint16_t dens;
206
203
static s_glue glc;
207
204
//AK!
208
 
static INT l_abris[80],r_abris[80];
 
205
static int16_t l_abris[80],r_abris[80];
209
206
 
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;
213
 
INT up_jack;
 
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;
 
210
int16_t up_jack;
214
211
/*
215
212
 number of foots < 16 +
216
213
 iclineness :
220
217
 64 - any incline
221
218
 128 - must match number of foots and his incline
222
219
 */
223
 
static BYTE let_stick[256] = {
 
220
static uchar let_stick[256] = {
224
221
   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
225
222
   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
226
223
   0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
255
252
/*********************************************************start r_criteria*/
256
253
void r_criteria(cell *c, const s_glue * gl)              //10.02.97
257
254
{
258
 
 extern BOOL TM_check_active;
 
255
 extern Bool TM_check_active;
259
256
 version *v0;
260
 
 LONG    d,d_ang,d_cun,d_abris,i,dd;                       //change from INT
261
 
 CHAR    snap[380],*s=snap;
 
257
 int32_t    d,d_ang,d_cun,d_abris,i,dd;                       //change from int16_t
 
258
 char    snap[380],*s=snap;
262
259
 struct rst _rst;
263
260
 MN *    mn;
264
261
 cell *  cc=NULL;
265
 
 BYTE    pen_m=0,flag_m=0,maxprob;
266
 
 LONG     inc=0 ;                                          //change from INT
 
262
 uchar    pen_m=0,flag_m=0,maxprob;
 
263
 int32_t     inc=0 ;                                          //change from int16_t
267
264
 version    save[VERS_IN_CELL];
268
 
 INT    snvers;
 
265
 int16_t    snvers;
269
266
 
270
267
 // Nick 20.02.2001 - add *sizeof(version) !!!
271
268
if( c->nvers>0 )
306
303
 dnri_hook = check_dnri_hook( &glc, c );
307
304
 upri_hook = check_upri_hook_cell( c );
308
305
 uple_hook = check_uple_hook_cell( c );
309
 
 up_jack   = RE_rus_Ge(hist_n, hist_d, (INT)(c->h<30?4:6),c->w);
 
306
 up_jack   = RE_rus_Ge(hist_n, hist_d, (int16_t)(c->h<30?4:6),c->w);
310
307
 
311
308
 init_diskrim(_rst.raster,_rst.h,_rst.w);
312
309
 _init_();
316
313
  else
317
314
    {
318
315
     cell * cp;
319
 
     INT h;
 
316
     int16_t h;
320
317
     for(i=0,h=0;i < gl->ncell ;i++)
321
318
       if( gl->celist[i]->flg & (c_f_let | c_f_bad)
322
319
           && gl->celist[i]->env != NULL
330
327
     cc = cp; // set main comp
331
328
    }
332
329
 abris_reset();
333
 
 mn = c_locomp(_rst.raster,(INT)((_rst.w + 7)>>3),_rst.h,0,0);
 
330
 mn = c_locomp(_rst.raster,(int16_t)((_rst.w + 7)>>3),_rst.h,0,0);
334
331
 segment_pool = EVN_GetSegmentPool();
335
332
 make_white_hist(segment_pool,_rst.h);
336
333
 dens = internal_filling((segment*)segment_pool,_rst.h,_rst.w);
338
335
//#pragma warning       ( disable : 4047 4024 )                            //AK 11.03.97
339
336
 
340
337
 calc_angles(&_rst,segment_pool,/*&*/corners,              //AK 04.03.97 ? for address
341
 
              (BYTE)(c->cg_flag&c_cg_cutl),(BYTE)(c->cg_flag&c_cg_cutr));
 
338
              (uchar)(c->cg_flag&c_cg_cutl),(uchar)(c->cg_flag&c_cg_cutr));
342
339
 abris_online = TRUE;
343
340
 calc_abris(segment_pool,_rst.h);
344
341
 
349
346
    if( v0->let == r_cu_m && (!broken_flag || !inc) )
350
347
      { // Analize m
351
348
       cell C=*c;
352
 
       BYTE p=v0->prob;
 
349
       uchar p=v0->prob;
353
350
 
354
351
       flag_m=TRUE;
355
352
       C.vers[0].let='m';
365
362
   {
366
363
    if( !broken_ii && broken_flag ) // Oleg : 1-07-1994 : set signum two sticks
367
364
      {
368
 
       INT num;
 
365
       int16_t num;
369
366
       for(num=0,i=0;i < gl->ncell ;i++)
370
367
         if(   gl->celist[i]->flg & (c_f_let | c_f_bad) &&
371
368
               gl->celist[i]->env != NULL  &&
401
398
    if( dd )
402
399
      switch(v0->let)
403
400
       {
404
 
        case  (BYTE)'$':
 
401
        case  (uchar)'$':
405
402
            if( i == 1 )
406
403
                    {                        /*c->vers[0].let == '$' ){*/
407
 
                INT  i,dl=0,dr=0;
 
404
                int16_t  i,dl=0,dr=0;
408
405
                if( c->prevl->flg & c_f_let )
409
406
                        {
410
407
                    for(i=0;i<c->prevl->nvers;i++)
437
434
                    }
438
435
                }/* if unique $ */
439
436
            break;
440
 
        case  (BYTE)'�':
441
 
        case  (BYTE)'�':
442
 
        case  (BYTE)'�':
443
 
        case  (BYTE)'�':
 
437
        case  (uchar)'�':
 
438
        case  (uchar)'�':
 
439
        case  (uchar)'�':
 
440
        case  (uchar)'�':
444
441
            if(cc && !broken_flag)
445
442
                d_cun += check_tg( cc, v0->let,_rst.raster,_rst.w,_rst.h);
446
443
            if( cc && dust_near_rusG(cc) )
447
444
                d += 80;
448
445
            break;
449
 
        case  (BYTE)'�':
450
 
        case  (BYTE)'�':
 
446
        case  (uchar)'�':
 
447
        case  (uchar)'�':
451
448
            if(cc)
452
449
                    d_cun += check_EK(v0->let,cc);
453
450
            break;
454
 
        case  (BYTE)'�':
 
451
        case  (uchar)'�':
455
452
            d_cun += check_veza(cc,(segment*)segment_pool,_rst.h,_rst.w,v0->let);
456
453
            break;
457
 
        case  (BYTE)'�':
458
 
        case  (BYTE) UKR_e:
 
454
        case  (uchar)'�':
 
455
        case  (uchar) UKR_e:
459
456
            if(cc && (cc->recsource & c_rs_ev))
460
457
                break;
461
458
            d_cun += check_veza(cc,(segment*)segment_pool,_rst.h,_rst.w,'�');
462
459
            break;
463
 
        case  (BYTE)'�':
 
460
        case  (uchar)'�':
464
461
            if(cc)
465
462
                    d_cun += check_nn(cc);
466
463
            break;
467
 
        case  (BYTE)'�':
 
464
        case  (uchar)'�':
468
465
            if(cc)
469
466
                d_cun += check_AL(cc,v0->let);
470
467
            break;
471
 
        case  (BYTE)'�':
 
468
        case  (uchar)'�':
472
469
            if(cc)
473
470
                d_cun += check_AL(cc,v0->let);
474
 
        case  (BYTE)'�':
475
 
        case  (BYTE)'�':
476
 
        case  (BYTE)'�':
 
471
        case  (uchar)'�':
 
472
        case  (uchar)'�':
 
473
        case  (uchar)'�':
477
474
            if(cc)
478
475
                    d_cun += check_pl( cc,c, v0->let,&_rst);
479
476
                if( broken_flag && glc.ncell==2 &&
480
477
                        dust_in_glue(cc,&glc,33,33,66,66) )
481
478
             d_cun += 80;
482
479
             break;
483
 
        case  (BYTE)'�':
 
480
        case  (uchar)'�':
484
481
            if( cc )
485
482
                if(  !(erection_enable && (cc->pos_inc&erect_rot))  )
486
483
                    d_cun = check_oa( cc,'�',&_rst);
487
484
            break;
488
 
        case  (BYTE)'�':
 
485
        case  (uchar)'�':
489
486
            d_cun += check_veza(cc,(segment*)segment_pool,_rst.h,_rst.w,v0->let);
490
487
            break;
491
 
        case  (BYTE)'�':
 
488
        case  (uchar)'�':
492
489
                                                // � ���������� ��� ��. 08.09.2000 E.P.
493
490
                        if (language==LANG_RUSSIAN && langBul)
494
491
                                {d_cun = 200;break;}
497
494
            if( cc )
498
495
                d_cun += check_ee(cc);
499
496
            break;
500
 
        case  (BYTE)'�':
 
497
        case  (uchar)'�':
501
498
            d_cun += check_veza(cc,(segment*)segment_pool,_rst.h,_rst.w,v0->let);
502
499
            if(cc) d_cun += check_zz(cc);
503
500
                if( cc )
504
501
                    d_cun += check_ee(cc);
505
502
            break;
506
 
        case  (BYTE)'�':
 
503
        case  (uchar)'�':
507
504
            if(cc)
508
505
                    d_cun = check_ya( cc );
509
506
            break;
510
 
        case  (BYTE)'�':
511
 
        case  (BYTE)'�':
 
507
        case  (uchar)'�':
 
508
        case  (uchar)'�':
512
509
            if(cc && !broken_flag)
513
510
                    d_cun = check_iee( cc,v0->let );
514
511
            break;
515
 
        case  (BYTE)'�':
 
512
        case  (uchar)'�':
516
513
            if(cc)
517
514
                    d_cun += check_xX( cc );
518
515
                d_cun += check_xk(_rst.h,v0->let);
519
516
            break;
520
 
        case  (BYTE)'�':
 
517
        case  (uchar)'�':
521
518
            if(cc) d_cun = check_xX( cc );
522
519
         break;
523
 
        case  (BYTE)'�':
 
520
        case  (uchar)'�':
524
521
            d_cun += check_xk(_rst.h,v0->let);
525
522
            if( inc && !(corners[0]==128 && corners[2]==128) )
526
523
                if( dnri_hook && !upri_hook )
527
524
                    d_cun+=40;
528
525
            break;
529
 
        case  (BYTE)'�':
 
526
        case  (uchar)'�':
530
527
            d_cun = check_bb();
531
 
        case  (BYTE)'�':
 
528
        case  (uchar)'�':
532
529
            if( dust_in_glue(cc,&glc,60,0,100,33) )
533
530
                    d += 80;
534
531
            break;
535
 
        case  (BYTE)'�':
536
 
        case  (BYTE)'�':
 
532
        case  (uchar)'�':
 
533
        case  (uchar)'�':
537
534
            d_cun = cut_by_pos_ii(&glc,v0->let);
538
535
            break;
539
 
        case  (BYTE)'�':
540
 
        case  (BYTE)'�':
 
536
        case  (uchar)'�':
 
537
        case  (uchar)'�':
541
538
            if( dust_in_glue(cc,&glc,0-20,66-20,33,100) )
542
539
                    d += 80;
543
540
            break;
544
 
        case  (BYTE)'�':
545
 
        case  (BYTE)'�' :
 
541
        case  (uchar)'�':
 
542
        case  (uchar)'�' :
546
543
            if( cc && dust_in_glue(cc,NULL,25,33,75,66) )
547
544
                d += 80;
548
545
            break;
549
 
        case (BYTE)r_cu_a:
 
546
        case (uchar)r_cu_a:
550
547
            if(cc)
551
548
                    d_cun += check_oa( cc,'�',&_rst);
552
549
            break;
553
 
        case (BYTE)r_cu_u:
 
550
        case (uchar)r_cu_u:
554
551
            d_cun = check_uu( cc,_rst.h );
555
552
            break;
556
 
        case (BYTE)r_cu_m:
 
553
        case (uchar)r_cu_m:
557
554
            d_abris = pen_m;
558
555
            if(cc&&!(c->pos_inc&(erect_rot|erect_zero)))
559
556
                    d_cun = check_m(cc);
560
557
            if(cc&&(c->pos_inc&erect_zero))
561
558
                    d_cun += 80;
562
559
            break;
563
 
        case (BYTE)'|':
 
560
        case (uchar)'|':
564
561
            d_cun = stick_bI(c);
565
562
            break;
566
 
        case (BYTE)'!':
567
 
        case (BYTE)'>':
568
 
        case (BYTE)'<':
 
563
        case (uchar)'!':
 
564
        case (uchar)'>':
 
565
        case (uchar)'<':
569
566
                                    d_cun = check_I_dot(c,v0->let);
570
567
                 break;
571
568
 
572
569
                // 31.08.2000 E.P.
573
 
        case (BYTE)liga_exm_usual:
 
570
        case (uchar)liga_exm_usual:
574
571
                 if (liga_exm_usual == liga_exm)
575
572
            d_cun = check_I_dot(c,v0->let);
576
573
                 break;
577
574
 
578
 
        case (BYTE)liga_exm_latin:
 
575
        case (uchar)liga_exm_latin:
579
576
                 if (liga_exm_latin == liga_exm)
580
577
            d_cun = check_I_dot(c,v0->let);
581
578
                 break;
582
579
 
583
 
        case (BYTE)'1':
 
580
        case (uchar)'1':
584
581
           d_cun = check_I_dot(c,v0->let);
585
582
         break;
586
583
       }
590
587
      if( !test_alphabet_elem(v0->let) )
591
588
        dd=digital_string_penalty;
592
589
    if( dd<0 )
593
 
      dd = Diskrim(v0->let,_rst.raster,_rst.w,0,0,_rst.w,_rst.h,c->cg_flag,(INT)inc);
 
590
      dd = Diskrim(v0->let,_rst.raster,_rst.w,0,0,_rst.w,_rst.h,c->cg_flag,(int16_t)inc);
594
591
 
595
592
    if( dd<0 )
596
593
      {       // Bonus ��� 2-� ����� ���
606
603
      }
607
604
     else
608
605
       d += dd;
609
 
    d_ang = discr_angles(v0->let,_rst.h,(INT)(cc?(cc->pos_inc&erect_rot):0)); // rotation
 
606
    d_ang = discr_angles(v0->let,_rst.h,(int16_t)(cc?(cc->pos_inc&erect_rot):0)); // rotation
610
607
    if( flag_m && pen_m == 0 && (d != 0 || v0->prob < 232) &&
611
608
        memchr("��",v0->let,3))
612
609
      d_cun += 60;
613
610
    if(memchr(rus_like,v0->let,sizeof rus_like))
614
611
      {      // Here abris discrim for rus letters that looks like english
615
 
       BYTE ch,ds;
616
 
       ch = emu_like[(PBYTE)memchr(rus_like,v0->let,sizeof rus_like) - rus_like];
617
 
       ds=(BYTE)abris(&glc,c,ch,v0->prob);
 
612
       uchar ch,ds;
 
613
       ch = emu_like[(puchar)memchr(rus_like,v0->let,sizeof rus_like) - rus_like];
 
614
       ds=(uchar)abris(&glc,c,ch,v0->prob);
618
615
       d_abris = v0->prob - ds;
619
616
      }
620
617
 
627
624
            (memchr("�",v0->let,2) && suspect_italic_III_bend(cc)==0) ||
628
625
            (memchr("�",v0->let,2) && suspect_italic_ce(cc)==0))
629
626
          {
630
 
           d_cun += check_cursiv( cc,v0->let,(INT)d ,_rst.raster);
 
627
           d_cun += check_cursiv( cc,v0->let,(int16_t)d ,_rst.raster);
631
628
           d_ang =  discr_angles(v0->let,_rst.h,1);
632
629
           d = 0;
633
630
          }
651
648
    d += d_cun;
652
649
    d += d_abris; // sum penalty
653
650
    if ( TM_check_active &&
654
 
         (v0->let=='T' || v0->let=='t' || v0->let==(BYTE)'�' || v0->let==(BYTE)'�'
655
 
         || v0->let=='M' || v0->let=='m' || v0->let==(BYTE)'�' || v0->let==(BYTE)'�'))
 
651
         (v0->let=='T' || v0->let=='t' || v0->let==(uchar)'�' || v0->let==(uchar)'�'
 
652
         || v0->let=='M' || v0->let=='m' || v0->let==(uchar)'�' || v0->let==(uchar)'�'))
656
653
       v0->prob=MAX_TM_PROB;
657
654
     else
658
655
      {
659
656
       if(v0->prob < d)
660
657
         v0->prob = 0;
661
658
        else
662
 
         v0->prob-= (BYTE)d;
 
659
         v0->prob-= (uchar)d;
663
660
      }
664
661
   }        // for by vers
665
662
 sort_vers(c);
684
681
/************************************************end r_criteria**/
685
682
/*=============== Discriminators for letters =====================*/
686
683
 
687
 
WORD check_xX(cell * c)
 
684
uint16_t check_xX(cell * c)
688
685
{
689
686
lnhead *line;
690
 
INT l;
691
 
WORD nl=0,pen=0;
 
687
int16_t l;
 
688
uint16_t nl=0,pen=0;
692
689
 
693
 
 for (line=(lnhead *)((PCHAR)(c->env)+c->env->lines+sizeof(INT));
694
 
                        (l=line->lth)>0; line=(lnhead *)((PCHAR)line+l))
 
690
 for (line=(lnhead *)((pchar)(c->env)+c->env->lines+sizeof(int16_t));
 
691
                        (l=line->lth)>0; line=(lnhead *)((pchar)line+l))
695
692
  if (line->h > 2 || !(line->flg & (l_fbeg | l_fend)) ) nl++;
696
693
  if( nl == 1 ) pen+=220;
697
694
   return pen;
698
695
}
699
696
///////////////////////////////////////////////////////////////////
700
697
// check 'k','x' abris
701
 
WORD check_xk(INT h,BYTE let)
 
698
uint16_t check_xk(int16_t h,uchar let)
702
699
{
703
 
 WORD max,index,pen_lx,pen_lk,pen_rk,pen_rx;
704
 
 BYTE hist[128];
705
 
 INT jump[128]={0};
706
 
 INT i,smooth,mono;
 
700
 uint16_t max,index,pen_lx,pen_lk,pen_rk,pen_rx;
 
701
 uchar hist[128];
 
702
 int16_t jump[128]={0};
 
703
 int16_t i,smooth,mono;
707
704
        // only stright 'k','x'
708
705
        // calc histgramm
709
706
 if( ! abris_online )
776
773
 
777
774
  if( pen_rk == 0 )
778
775
     { // try to find meandr in right
779
 
      INT min,max,j,pos,neg;
 
776
      int16_t min,max,j,pos,neg;
780
777
      for(i=h/5+1,j=0,min=max=r_abris[h/5];i < h*4/5 ;i++,j++)
781
778
             {
782
779
          min = MIN(min,r_abris[i]);
806
803
         }
807
804
     }
808
805
 
809
 
 return let == (BYTE)'�' ? pen_rx + pen_lx : pen_rk + pen_lk;
 
806
 return let == (uchar)'�' ? pen_rx + pen_lx : pen_rk + pen_lk;
810
807
}
811
808
/////////////////////////////////////////////////////////////////////
812
809
// '�' refuse with 'a' that have no upper bend
813
 
WORD check_bb(void)
 
810
uint16_t check_bb(void)
814
811
{
815
812
if( dens > 210 ) return 80;
816
813
else if( dens >= BOLD ) return 60;
818
815
}
819
816
 
820
817
/* Analize '<<' and '>>' abris */
821
 
static BYTE dh1[8]={ 0,0,0,1,1,2,2,3 };
822
 
static BYTE dh2[8]={ 0,0,1,1,1,2,2,3 };
823
 
INT chkquocks2(cell * c,PBYTE rstr,INT h,INT w,INT d)
 
818
static uchar dh1[8]={ 0,0,0,1,1,2,2,3 };
 
819
static uchar dh2[8]={ 0,0,1,1,1,2,2,3 };
 
820
int16_t chkquocks2(cell * c,puchar rstr,int16_t h,int16_t w,int16_t d)
824
821
{
825
 
INT i,i1,i2,extr1,ln,ln1,h1,h2;
826
 
INT tanx,tany,sum1,sum2;
 
822
int16_t i,i1,i2,extr1,ln,ln1,h1,h2;
 
823
int16_t tanx,tany,sum1,sum2;
827
824
MN *mn;
828
 
CHAR buf[200],tmp[200];
829
 
  mn = c_locomp(rstr,(INT)((w + 7)>>3),h,0,0);
 
825
char buf[200],tmp[200];
 
826
  mn = c_locomp(rstr,(int16_t)((w + 7)>>3),h,0,0);
830
827
  if(mn){
831
828
  segment_pool = EVN_GetSegmentPool();
832
829
  abris_online = TRUE;
909
906
}
910
907
 
911
908
// Addition to atlant
912
 
WORD check_m( cell * c)
 
909
uint16_t check_m( cell * c)
913
910
{
914
 
WORD pen=0;
915
 
INT i;
 
911
uint16_t pen=0;
 
912
int16_t i;
916
913
    stick_online(c);
917
914
   if( nstick < 0 ) return 0;
918
915
   if( nstick == 1 )
934
931
 return pen;
935
932
}
936
933
/*
937
 
WORD check_ss(cell * c,PBYTE pint,INT height)
 
934
uint16_t check_ss(cell * c,puchar pint,int16_t height)
938
935
{
939
936
segment * segm;
940
 
INT i,j,col,prev_col;
941
 
WORD d=0,gaps=0;
 
937
int16_t i,j,col,prev_col;
 
938
uint16_t d=0,gaps=0;
942
939
 
943
940
  if( c ) // 'c' mustn't have a hole
944
941
  gaps = ((c_comp*)c->env)->nl - ((c_comp*)c->env)->begs - ((c_comp*)c->env)->ends + 1;
961
958
 return d;
962
959
}
963
960
*/
964
 
WORD check_AL(cell * c,BYTE let)
 
961
uint16_t check_AL(cell * c,uchar let)
965
962
{
966
 
INT gaps;
 
963
int16_t gaps;
967
964
lnhead *line;
968
 
INT l;
 
965
int16_t l;
969
966
  gaps = ((c_comp*)c->env)->nl - ((c_comp*)c->env)->begs - ((c_comp*)c->env)->ends + 1;
970
967
 if( gaps > 0)
971
 
 for (line=(lnhead *)((PCHAR)(c->env)+c->env->lines+sizeof(INT));
972
 
                        (l=line->lth)>0; line=(lnhead *)((PCHAR)line+l))
 
968
 for (line=(lnhead *)((pchar)(c->env)+c->env->lines+sizeof(int16_t));
 
969
                        (l=line->lth)>0; line=(lnhead *)((pchar)line+l))
973
970
  if(!(line->flg & (l_fend | l_fbeg)) )
974
971
   if(line->h == 1) gaps--; // skip non valueble lines
975
972
   else if(line->row > c->h/2 && line->h < 3) gaps--;
976
973
 
977
 
  if( let == (BYTE)'�' && gaps != 1 ) return 40;
978
 
  if( let == (BYTE)'�' && gaps > 0  ) return 40;
 
974
  if( let == (uchar)'�' && gaps != 1 ) return 40;
 
975
  if( let == (uchar)'�' && gaps > 0  ) return 40;
979
976
  return 0;
980
977
}
981
978
 
982
 
WORD check_EK(BYTE let,cell * c)
 
979
uint16_t check_EK(uchar let,cell * c)
983
980
{
984
981
 lnhead *line;
985
 
 INT l;
986
 
 WORD pen_E=0,pen_K=0;
 
982
 int16_t l;
 
983
 uint16_t pen_E=0,pen_K=0;
987
984
 
988
985
 if(((c_comp*)c->env)->nl == 1) pen_K = 200;
989
986
 
990
 
 for (line=(lnhead *)((PCHAR)(c->env)+c->env->lines+sizeof(INT));
991
 
                        (l=line->lth)>0; line=(lnhead *)((PCHAR)line+l))
 
987
 for (line=(lnhead *)((pchar)(c->env)+c->env->lines+sizeof(int16_t));
 
988
                        (l=line->lth)>0; line=(lnhead *)((pchar)line+l))
992
989
  if (line->row < c->h/3 && !(line->flg&l_fend) && line->h > c->h/4 )
993
990
     pen_E += 100;
994
991
 
995
992
 switch( let ){
996
 
 case (BYTE)'�' :  return (pen_K + ( pen_E == 0 ? 100 : 0 )); break;
997
 
 case (BYTE)'�' :  return pen_E; break;
 
993
 case (uchar)'�' :  return (pen_K + ( pen_E == 0 ? 100 : 0 )); break;
 
994
 case (uchar)'�' :  return pen_E; break;
998
995
 }
999
996
 
1000
997
  return 0;
1001
998
}
1002
999
// �
1003
 
WORD check_iee(cell * c,BYTE let)
 
1000
uint16_t check_iee(cell * c,uchar let)
1004
1001
{
1005
1002
 lnhead *line;
1006
 
 INT l;
1007
 
 WORD pen=0,gaps;
 
1003
 int16_t l;
 
1004
 uint16_t pen=0,gaps;
1008
1005
 
1009
1006
  gaps = ((c_comp*)c->env)->nl - ((c_comp*)c->env)->begs - ((c_comp*)c->env)->ends + 1;
1010
 
  if( gaps == 0 && let == (BYTE)'�') return 10;
1011
 
  else if ( gaps == 0 && let == (BYTE)'�' ) return 60;
 
1007
  if( gaps == 0 && let == (uchar)'�') return 10;
 
1008
  else if ( gaps == 0 && let == (uchar)'�' ) return 60;
1012
1009
     // hole in top right square
1013
 
 for (line=(lnhead *)((PCHAR)(c->env)+c->env->lines+sizeof(INT));
1014
 
                        (l=line->lth)>0; line=(lnhead *)((PCHAR)line+l))
 
1010
 for (line=(lnhead *)((pchar)(c->env)+c->env->lines+sizeof(int16_t));
 
1011
                        (l=line->lth)>0; line=(lnhead *)((pchar)line+l))
1015
1012
  if (line->row < c->h/2 &&  line->h < c->h/4 &&
1016
1013
  (!(line->flg&l_fend) && !(line->flg&l_fbeg))  )
1017
1014
     pen += 60;
1019
1016
  return pen;
1020
1017
}
1021
1018
 
1022
 
WORD check_ya( cell * c)
 
1019
uint16_t check_ya( cell * c)
1023
1020
{
1024
1021
 lnhead *line;
1025
 
 INT l,suspect=0,strong=0;
1026
 
 WORD pen=0,gaps;
 
1022
 int16_t l,suspect=0,strong=0;
 
1023
 uint16_t pen=0,gaps;
1027
1024
   gaps = ((c_comp*)c->env)->nl - ((c_comp*)c->env)->begs - ((c_comp*)c->env)->ends + 1;
1028
 
 for (line=(lnhead *)((PCHAR)(c->env)+c->env->lines+sizeof(INT));
1029
 
                        (l=line->lth)>0; line=(lnhead *)((PCHAR)line+l))
 
1025
 for (line=(lnhead *)((pchar)(c->env)+c->env->lines+sizeof(int16_t));
 
1026
                        (l=line->lth)>0; line=(lnhead *)((pchar)line+l))
1030
1027
  if ( (line->flg & (l_fbeg | l_fend)) == 0 )
1031
1028
   if (line->row > c->h/3) suspect++;
1032
1029
   else                    strong++;
1039
1036
 
1040
1037
// Andrew zone
1041
1038
static STICK st[30],*stickLP;
1042
 
static INT nstickLP;
 
1039
static int16_t nstickLP;
1043
1040
 
1044
 
WORD check_pl( cell * c, cell * ci,BYTE let,struct rst * const rst )
 
1041
uint16_t check_pl( cell * c, cell * ci,uchar let,struct rst * const rst )
1045
1042
{
1046
 
CHAR  maxL=0,maxR=0;
1047
 
INT i,j1,j2,j,sym,nInvest;
1048
 
WORD penL=0,penP=0,pen=0,top=0,meanLetter,meanLetter0;
1049
 
WORD left=0,right=0,mean=0,D_X;
1050
 
INT begin0,begin;
1051
 
BYTE  *RAST,*RASTR,saveR[5];
 
1043
char  maxL=0,maxR=0;
 
1044
int16_t i,j1,j2,j,sym,nInvest;
 
1045
uint16_t penL=0,penP=0,pen=0,top=0,meanLetter,meanLetter0;
 
1046
uint16_t left=0,right=0,mean=0,D_X;
 
1047
int16_t begin0,begin;
 
1048
uchar  *RAST,*RASTR,saveR[5];
1052
1049
MN *mn;
1053
1050
cell * cc=NULL;
1054
 
INT dx,dy;
1055
 
INT pen_serif = 0;
 
1051
int16_t dx,dy;
 
1052
int16_t pen_serif = 0;
1056
1053
 
1057
1054
dx = rst->w;   dy = rst->h;   RASTR=rst->raster;
1058
1055
D_X = (dx+7)>>3;
1084
1081
    nInvest = dy/4;
1085
1082
  for(RAST=RASTR+(dy-1)*D_X,i=0;i<dy/4;i++,RAST-=D_X)
1086
1083
    {
1087
 
    if( SumIntervalBits(RAST,0,(INT)(dx/3)) < 3*stick[0].w/2 )
 
1084
    if( SumIntervalBits(RAST,0,(int16_t)(dx/3)) < 3*stick[0].w/2 )
1088
1085
      {
1089
1086
      nInvest++;
1090
1087
                        }
1114
1111
    if( begin <= 0 )
1115
1112
      j1 = 0;
1116
1113
    left += j1;
1117
 
    j2 = SumIntervalBits(RAST,(INT)(begin+stick[0].w),meanLetter);
1118
 
    if( ! SumIntervalBits(RAST,(INT)(begin+stick[0].w),(INT)(begin+stick[0].w+1)) )
 
1114
    j2 = SumIntervalBits(RAST,(int16_t)(begin+stick[0].w),meanLetter);
 
1115
    if( ! SumIntervalBits(RAST,(int16_t)(begin+stick[0].w),(int16_t)(begin+stick[0].w+1)) )
1119
1116
      j2 = 0;
1120
 
    if( ! SumIntervalBits(RAST,(INT)(begin+stick[0].w-1),(INT)(begin+stick[0].w)) )
 
1117
    if( ! SumIntervalBits(RAST,(int16_t)(begin+stick[0].w-1),(int16_t)(begin+stick[0].w)) )
1121
1118
      j2 = 0;
1122
1119
    right += j2;
1123
 
    j = 3*stick[0].w-SumIntervalBits(RAST,begin,(INT)(begin+stick[0].w));
1124
 
    if( SumIntervalBits(RAST,0,(INT)(begin+stick[0].w)) < 3*stick[0].w/2 )
 
1120
    j = 3*stick[0].w-SumIntervalBits(RAST,begin,(int16_t)(begin+stick[0].w));
 
1121
    if( SumIntervalBits(RAST,0,(int16_t)(begin+stick[0].w)) < 3*stick[0].w/2 )
1125
1122
      {
1126
1123
      j = 0;
1127
1124
      mean = 0;
1130
1127
                        }
1131
1128
    mean += j;
1132
1129
    if( maxL < j1 )
1133
 
      maxL = (BYTE)j1;
 
1130
      maxL = (uchar)j1;
1134
1131
    if( maxR < j2 )
1135
 
      maxR = (BYTE)j2;
 
1132
      maxR = (uchar)j2;
1136
1133
    }
1137
1134
 
1138
1135
   if( (c->cg_flag_fine&c_cg_cut_bl) && stick[0].bot<0 ||
1139
1136
     (c->cg_flag_fine==0)&&(c->cg_flag&c_cg_cutl) && stick[0].bot<0 )
1140
1137
    {
1141
 
    INT n=dy/4, num, old, e;
1142
 
    INT r0=VertSum(RASTR,D_X,dy,(INT)(dx-1));
1143
 
    INT r1=VertSum(RASTR,D_X,dy,(INT)(dx-2));
1144
 
    INT r2=VertSum(RASTR,D_X,dy,(INT)(dx-3));
 
1138
    int16_t n=dy/4, num, old, e;
 
1139
    int16_t r0=VertSum(RASTR,D_X,dy,(int16_t)(dx-1));
 
1140
    int16_t r1=VertSum(RASTR,D_X,dy,(int16_t)(dx-2));
 
1141
    int16_t r2=VertSum(RASTR,D_X,dy,(int16_t)(dx-3));
1145
1142
    if( r0<dy && r1<=dy-2 && r1>dy-4 && r2>dy-2 )
1146
1143
      r1=r2;
1147
1144
    old=EndBlackInterval(RASTR+(dy-1)*D_X, D_X);
1236
1233
  }
1237
1234
 
1238
1235
//cut  1/4  down  part  to  calculate   sticks  for  �  without  errors
1239
 
mn = c_locomp(rst->raster,D_X,(INT)(dy-dy/4),0,0);
 
1236
mn = c_locomp(rst->raster,D_X,(int16_t)(dy-dy/4),0,0);
1240
1237
if(mn) cc=create_cell(mn,ci,0,0);
1241
1238
//recover  after  for  not  cut  left  black  rectangle
1242
1239
for(i=0;( (i<D_X) && (i<5) );i++)
1277
1274
  nInvest = dy/4;
1278
1275
for(RAST=RASTR+(dy-1)*D_X,i=0;i<dy/4;i++,RAST-=D_X)
1279
1276
  {
1280
 
  if( SumIntervalBits(RAST,0,(INT)(dx/3)) < 3*stickLP[0].w/2 )
 
1277
  if( SumIntervalBits(RAST,0,(int16_t)(dx/3)) < 3*stickLP[0].w/2 )
1281
1278
    {
1282
1279
    nInvest++;
1283
1280
    }
1307
1304
  if( begin <= 0 )
1308
1305
    j1 = 0;
1309
1306
  left += j1;
1310
 
  j2 = SumIntervalBits(RAST,(INT)(begin+stickLP[0].w),meanLetter);
1311
 
  if( ! SumIntervalBits(RAST,(INT)(begin+stickLP[0].w),(INT)(begin+stickLP[0].w+1)) )
 
1307
  j2 = SumIntervalBits(RAST,(int16_t)(begin+stickLP[0].w),meanLetter);
 
1308
  if( ! SumIntervalBits(RAST,(int16_t)(begin+stickLP[0].w),(int16_t)(begin+stickLP[0].w+1)) )
1312
1309
    j2 = 0;
1313
 
  if( ! SumIntervalBits(RAST,(INT)(begin+stickLP[0].w-1),(INT)(begin+stickLP[0].w)) )
 
1310
  if( ! SumIntervalBits(RAST,(int16_t)(begin+stickLP[0].w-1),(int16_t)(begin+stickLP[0].w)) )
1314
1311
    j2 = 0;
1315
1312
      right += j2;
1316
 
  j = 3*stickLP[0].w-SumIntervalBits(RAST,begin,(INT)(begin+stickLP[0].w));
1317
 
  if( SumIntervalBits(RAST,0,(INT)(begin+stickLP[0].w)) < 3*stickLP[0].w/2 )
 
1313
  j = 3*stickLP[0].w-SumIntervalBits(RAST,begin,(int16_t)(begin+stickLP[0].w));
 
1314
  if( SumIntervalBits(RAST,0,(int16_t)(begin+stickLP[0].w)) < 3*stickLP[0].w/2 )
1318
1315
    {
1319
1316
    j = 0;
1320
1317
    mean = 0;
1323
1320
    }
1324
1321
  mean += j;
1325
1322
  if( maxL < j1 )
1326
 
    maxL = (BYTE)j1;
 
1323
    maxL = (uchar)j1;
1327
1324
  if( maxR < j2 )
1328
 
    maxR = (BYTE)j2;
 
1325
    maxR = (uchar)j2;
1329
1326
  }
1330
1327
 
1331
1328
if( !left && !right )
1413
1410
 
1414
1411
switch( let )
1415
1412
  {
1416
 
  case (BYTE)'�':  case (BYTE)'�':
 
1413
  case (uchar)'�':  case (uchar)'�':
1417
1414
    return  penP+pen_serif;
1418
 
  case (BYTE)'�':  case (BYTE)'�':
 
1415
  case (uchar)'�':  case (uchar)'�':
1419
1416
    return  penL;
1420
1417
  }/* switch let */
1421
1418
 
1422
1419
return pen;
1423
1420
}/*check_pl*/
1424
1421
 
1425
 
WORD check_tg( cell * c, BYTE let, PBYTE RASTR, INT dx, INT dy )
 
1422
uint16_t check_tg( cell * c, uchar let, puchar RASTR, int16_t dx, int16_t dy )
1426
1423
{
1427
 
BYTE  j,n4=dy>>2,D_X=(dx+7)/8;
1428
 
CHAR  beg,end;
1429
 
INT   i,k,piece2=0,piece3=0;
1430
 
INT   left=0,right=0,sum=0,tg=0;
1431
 
BYTE  *RAST;
 
1424
uchar  j,n4=dy>>2,D_X=(dx+7)/8;
 
1425
char  beg,end;
 
1426
int16_t   i,k,piece2=0,piece3=0;
 
1427
int16_t   left=0,right=0,sum=0,tg=0;
 
1428
uchar  *RAST;
1432
1429
 
1433
1430
stick_online(c);
1434
1431
if( nstick < 0 ) return 0;
1437
1434
beg = stick[0].x+(dy-stick[0].y)*stick[0].incl/2048-stick[0].w/2;
1438
1435
if( beg < 0 )   beg = 0;
1439
1436
end = beg+stick[0].w;
1440
 
if( beg > dx )  beg = (BYTE)dx;
1441
 
if( end > dx )  end = (BYTE)dx;
 
1437
if( beg > dx )  beg = (uchar)dx;
 
1438
if( end > dx )  end = (uchar)dx;
1442
1439
 
1443
1440
/* calculate  symmetric  of  top */
1444
1441
for (RAST=RASTR,i=0;i<2*n4;i++,RAST+=D_X)
1460
1457
 
1461
1458
for (RAST=RASTR+i*D_X,k=i;k<(i+2*n4);k++,RAST+=D_X)
1462
1459
  {
1463
 
  j=(BYTE)NumHorizInterval( RAST, D_X );
 
1460
  j=(uchar)NumHorizInterval( RAST, D_X );
1464
1461
  if( j == 2 )
1465
1462
    piece2++;
1466
1463
  if( j == 3 )
1481
1478
    else
1482
1479
      tg = 0;
1483
1480
    break;
1484
 
  case (BYTE)'�':  case (BYTE)'�':
 
1481
  case (uchar)'�':  case (uchar)'�':
1485
1482
    if( !((c->cg_flag_fine&c_cg_cut_tl) && left<right) ||
1486
1483
        !((c->cg_flag_fine==0) && (c->cg_flag&c_cg_cutl) && left<right) )
1487
1484
      {
1498
1495
    if( left > 2*right )
1499
1496
      tg += ( 40+5*(left-2*right) );
1500
1497
    break;
1501
 
   case (BYTE)'�':  case (BYTE)'�':
 
1498
   case (uchar)'�':  case (uchar)'�':
1502
1499
      if( tg<0 )
1503
1500
         tg = 20*(2-tg);
1504
1501
      else
1513
1510
 
1514
1511
// End of Andrew zone
1515
1512
 
1516
 
WORD check_zz( cell * c)
 
1513
uint16_t check_zz( cell * c)
1517
1514
{
1518
 
INT i;
1519
 
WORD pen=0;
 
1515
int16_t i;
 
1516
uint16_t pen=0;
1520
1517
      stick_online(c);
1521
1518
     if( nstick <= 0 ) return 0; // error or no sticks
1522
1519
 
1526
1523
  return pen;
1527
1524
}
1528
1525
 
1529
 
WORD check_uu( cell * c,INT h)
 
1526
uint16_t check_uu( cell * c,int16_t h)
1530
1527
{
1531
 
WORD pen;
 
1528
uint16_t pen;
1532
1529
 lnhead *line;
1533
 
 INT l,cnt=0;
 
1530
 int16_t l,cnt=0;
1534
1531
   pen  = check_num_foots(2,h);
1535
1532
   if( !c ) return pen;
1536
1533
if( !(c->pos_inc&erect_rot) )
1537
1534
   pen += check_inc_foots(c,2);
1538
1535
 
1539
 
 for (line=(lnhead *)((PCHAR)(c->env)+c->env->lines+sizeof(INT));
1540
 
                        (l=line->lth)>0; line=(lnhead *)((PCHAR)line+l))
 
1536
 for (line=(lnhead *)((pchar)(c->env)+c->env->lines+sizeof(int16_t));
 
1537
                        (l=line->lth)>0; line=(lnhead *)((pchar)line+l))
1541
1538
  if ( line->h*3 >= c->h*2 && line->row+line->h >= c->h*2/3 ) cnt++;
1542
1539
  switch(cnt){
1543
1540
  case 0        : pen += 100;break;
1549
1546
 
1550
1547
// Oleg zone
1551
1548
 
1552
 
BOOL check_uple_hook_cell( cell * c )
 
1549
Bool check_uple_hook_cell( cell * c )
1553
1550
{
1554
1551
 lnhead *line;
1555
 
 INT l,h,ind,wid, av;
 
1552
 int16_t l,h,ind,wid, av;
1556
1553
 interval *i;
1557
 
 for (line=(lnhead *)((PCHAR)(c->env)+c->env->lines+sizeof(INT));
1558
 
                        (l=line->lth)>0; line=(lnhead *)((PCHAR)line+l)){
1559
 
   i=(interval *)((PCHAR)line+sizeof(lnhead));
 
1554
 for (line=(lnhead *)((pchar)(c->env)+c->env->lines+sizeof(int16_t));
 
1555
                        (l=line->lth)>0; line=(lnhead *)((pchar)line+l)){
 
1556
   i=(interval *)((pchar)line+sizeof(lnhead));
1560
1557
   wid = i->l;
1561
1558
   if( line->row<2 && line->h*2<=c->h && (i->e-i->l)*4<c->w && line->h>2 &&
1562
1559
         (line->flg & l_fend)  )
1579
1576
return FALSE;
1580
1577
}
1581
1578
 
1582
 
BOOL check_upri_hook_cell( cell * c )
 
1579
Bool check_upri_hook_cell( cell * c )
1583
1580
{
1584
1581
 lnhead *line;
1585
 
 INT l,h,ind,wid;
 
1582
 int16_t l,h,ind,wid;
1586
1583
 interval *i;
1587
 
 for (line=(lnhead *)((PCHAR)(c->env)+c->env->lines+sizeof(INT));
1588
 
                        (l=line->lth)>0; line=(lnhead *)((PCHAR)line+l)){
1589
 
   i=(interval *)((PCHAR)line+sizeof(lnhead));
 
1584
 for (line=(lnhead *)((pchar)(c->env)+c->env->lines+sizeof(int16_t));
 
1585
                        (l=line->lth)>0; line=(lnhead *)((pchar)line+l)){
 
1586
   i=(interval *)((pchar)line+sizeof(lnhead));
1590
1587
   wid = i->l;
1591
1588
   if( line->row<2 && line->h*2<=c->h && (i->e-i->l)*4>c->w*3 && line->h>2 &&
1592
1589
         (line->flg & l_fend)  )
1608
1605
}
1609
1606
 
1610
1607
 
1611
 
BOOL check_dnri_hook_cell( cell * c , INT w)
 
1608
Bool check_dnri_hook_cell( cell * c , int16_t w)
1612
1609
{
1613
1610
 lnhead *line;
1614
 
 INT l,h,ind, ri;
 
1611
 int16_t l,h,ind, ri;
1615
1612
 interval *i;
1616
 
 for (line=(lnhead *)((PCHAR)(c->env)+c->env->lines+sizeof(INT));
1617
 
      (l=line->lth)>0; line=(lnhead *)((PCHAR)line+l))
 
1613
 for (line=(lnhead *)((pchar)(c->env)+c->env->lines+sizeof(int16_t));
 
1614
      (l=line->lth)>0; line=(lnhead *)((pchar)line+l))
1618
1615
  {
1619
 
  i=(interval *)((PCHAR)line+sizeof(lnhead));
 
1616
  i=(interval *)((pchar)line+sizeof(lnhead));
1620
1617
  if( line->row >= c->h/2 && line->h*3 <= c->h &&
1621
1618
      (line->flg & l_fbeg) && i->l <= c->w/3  )
1622
1619
    {
1642
1639
return FALSE;
1643
1640
}
1644
1641
 
1645
 
BOOL check_dnri_hook( s_glue *GL, cell *s)
 
1642
Bool check_dnri_hook( s_glue *GL, cell *s)
1646
1643
{
1647
1644
cell *c;
1648
 
INT ncells=0, maxc=-1;
 
1645
int16_t ncells=0, maxc=-1;
1649
1646
 
1650
1647
if( GL == NULL )
1651
1648
        {
1652
1649
        if( s )
1653
 
    return (check_dnri_hook_cell(s, (INT)(s->col+s->w)));
 
1650
    return (check_dnri_hook_cell(s, (int16_t)(s->col+s->w)));
1654
1651
        else
1655
1652
                return FALSE;
1656
1653
        }
1671
1668
}
1672
1669
 
1673
1670
 
1674
 
BOOL suspect_italic_kk(void)
 
1671
Bool suspect_italic_kk(void)
1675
1672
{
1676
1673
if( nstick == 2)
1677
1674
 if( stick[0].incl==0 )    return TRUE;
1678
1675
 return FALSE;
1679
1676
}
1680
1677
 
1681
 
BOOL suspect_italic_tche(void)
 
1678
Bool suspect_italic_tche(void)
1682
1679
{
1683
1680
if( nstick == 1)
1684
1681
 if( stick[0].incl<=200 )    return TRUE;
1685
1682
 return FALSE;
1686
1683
}
1687
1684
 
1688
 
BOOL suspect_italic_nn(void)
 
1685
Bool suspect_italic_nn(void)
1689
1686
{
1690
1687
if(  nstick>3 )                  return TRUE;
1691
1688
if(  nstick==1 && !broken_flag ) return TRUE;
1697
1694
     MIN(stick[0].w,stick[1].w) > 2) return TRUE;
1698
1695
 return FALSE;
1699
1696
}
1700
 
BOOL suspect_italic_ii(void)
 
1697
Bool suspect_italic_ii(void)
1701
1698
{
1702
1699
if( nstick>3 )                  return TRUE;
1703
1700
if( nstick==1 && !broken_flag ) return TRUE;
1710
1707
     stick[1].incl==0 && stick[0].incl<=200 ) return TRUE;
1711
1708
 return FALSE;
1712
1709
}
1713
 
BOOL suspect_italic_III(cell * c)
 
1710
Bool suspect_italic_III(cell * c)
1714
1711
{
1715
 
INT s=0;
 
1712
int16_t s=0;
1716
1713
 
1717
1714
     stick_online(c);
1718
1715
     if( nstick != 3 ) return TRUE; // error or no sticks
1721
1718
        s+= ( stick[0].incl==0)+( stick[1].incl==0 )+( stick[2].incl==0 ) ;
1722
1719
 return s>1;
1723
1720
}
1724
 
BOOL suspect_italic_III_bend(cell * c)
 
1721
Bool suspect_italic_III_bend(cell * c)
1725
1722
{
1726
 
INT s=0;
 
1723
int16_t s=0;
1727
1724
 
1728
1725
     stick_online(c);
1729
1726
     if( nstick != 3 && nstick!=4 ) return TRUE; // error or no sticks
1732
1729
s+= ( stick[0].incl==0)+( stick[1].incl==0 )+( stick[2].incl==0 ) ;
1733
1730
 return s>0;
1734
1731
}
1735
 
BOOL suspect_italic_ce(cell * c)
 
1732
Bool suspect_italic_ce(cell * c)
1736
1733
{
1737
 
INT s=0,h=c->h,i;
 
1734
int16_t s=0,h=c->h,i;
1738
1735
 
1739
1736
     stick_online(c);
1740
1737
     if( nstick !=2  && nstick !=3 ) return TRUE; // error or no sticks
1751
1748
 return s>0;
1752
1749
}
1753
1750
 
1754
 
BOOL suspect_italic_iee(void)
 
1751
Bool suspect_italic_iee(void)
1755
1752
{
1756
1753
if( nstick == 3)
1757
1754
 if( stick[0].incl==0 && stick[2].incl==0  ) return TRUE;
1758
1755
 return FALSE;
1759
1756
}
1760
1757
 
1761
 
INT check_italic_ch(INT h)
 
1758
int16_t check_italic_ch(int16_t h)
1762
1759
{
1763
 
INT i,cnt=0;
 
1760
int16_t i,cnt=0;
1764
1761
if( nstick > 1)
1765
1762
for(i=0;i<nstick;i++)
1766
1763
  if( stick[i].l*4 > h*3 ) cnt++;
1768
1765
}
1769
1766
 
1770
1767
static int nstick_broken;
1771
 
BOOL two_stick_online(s_glue *GL,INT *dest_foot, INT *wid_foot)
 
1768
Bool two_stick_online(s_glue *GL,int16_t *dest_foot, int16_t *wid_foot)
1772
1769
{
1773
1770
STICK  *s[2],ss[2];
1774
1771
cell *c,*cc[2];
1775
 
INT ncells=0,i,j,ns,save_flg,save_cg_flag;
 
1772
int16_t ncells=0,i,j,ns,save_flg,save_cg_flag;
1776
1773
 
1777
1774
nstick_broken=0;
1778
1775
if( GL == NULL )        return FALSE;
1794
1791
        save_flg=cc[i]->flg; save_cg_flag=cc[i]->cg_flag;
1795
1792
        cc[i]->flg=cc[i]->cg_flag=0;
1796
1793
        ns = sticks_in_letter(cc[i],0,&s[i]);
1797
 
        cc[i]->flg=save_flg; cc[i]->cg_flag=(BYTE)save_cg_flag;
 
1794
        cc[i]->flg=save_flg; cc[i]->cg_flag=(uchar)save_cg_flag;
1798
1795
        if( ns != 1 )
1799
1796
                return FALSE;   /* � �᪮��� �� ���� ���� ! */
1800
1797
        memcpy(&ss[i],s[i],sizeof(STICK));
1810
1807
return TRUE;
1811
1808
}
1812
1809
 
1813
 
BOOL broken_sym_italic(s_glue *GL,BYTE let)
 
1810
Bool broken_sym_italic(s_glue *GL,uchar let)
1814
1811
{
1815
1812
STICK  *s[2];
1816
1813
cell *c,*cc[2];
1817
 
INT ncells=0,i,j,ns,save_flg,save_cg_flag,cs;
 
1814
int16_t ncells=0,i,j,ns,save_flg,save_cg_flag,cs;
1818
1815
 
1819
1816
if( ! let_stick[let] ) return FALSE;
1820
1817
 
1839
1836
        save_flg=cc[i]->flg; save_cg_flag=cc[i]->cg_flag;
1840
1837
        cc[i]->flg=cc[i]->cg_flag=0;
1841
1838
        ns = sticks_in_letter(cc[i],0,&s[0]);
1842
 
        cc[i]->flg=save_flg; cc[i]->cg_flag=(BYTE)save_cg_flag;
 
1839
        cc[i]->flg=save_flg; cc[i]->cg_flag=(uchar)save_cg_flag;
1843
1840
        if( ns != 1 )
1844
1841
                return FALSE;   /* � �᪮��� �� ���� ���� ! */
1845
1842
        if( s[0]->l*5 >= cc[i]->h*4 )
1849
1846
return (cs>0);
1850
1847
}
1851
1848
 
1852
 
WORD check_cursiv( cell * c,BYTE let,INT old_diskr,BYTE *rast)
 
1849
uint16_t check_cursiv( cell * c,uchar let,int16_t old_diskr,uchar *rast)
1853
1850
{
1854
 
WORD pen=0;
1855
 
INT i,j,foot_wid,ind,t;   /* �।��� �ਭ� ���� */
1856
 
INT dest_foot[4]={0};
 
1851
uint16_t pen=0;
 
1852
int16_t i,j,foot_wid,ind,t;   /* �।��� �ਭ� ���� */
 
1853
int16_t dest_foot[4]={0};
1857
1854
 
1858
1855
     stick_online(c);
1859
1856
     if( nstick <= 0 ) return 0; // error or no sticks
1881
1878
        dest_foot[0]=calc_dest_foot(c->h,c->w,dest_foot,foot_wid);
1882
1879
 
1883
1880
  switch( let ){
1884
 
  case  (BYTE)'�'     :
1885
 
  case  (BYTE)'�'     :
 
1881
  case  (uchar)'�'     :
 
1882
  case  (uchar)'�'     :
1886
1883
          if(suspect_italic_III(c))
1887
1884
            {
1888
1885
                 pen += old_diskr;
1890
1887
            }
1891
1888
          pen = check_III(c,foot_wid,dest_foot);
1892
1889
     break;
1893
 
  case  (BYTE)'�'     :
1894
 
  case  (BYTE)'�'     :
 
1890
  case  (uchar)'�'     :
 
1891
  case  (uchar)'�'     :
1895
1892
          if(suspect_italic_III_bend(c))
1896
1893
            {
1897
1894
                 pen += old_diskr;
1899
1896
            }
1900
1897
                pen = check_III_bend(c,dest_foot);
1901
1898
           break;
1902
 
  case  (BYTE)'�'     :
1903
 
  case  (BYTE)'�'     :
 
1899
  case  (uchar)'�'     :
 
1900
  case  (uchar)'�'     :
1904
1901
          if(suspect_italic_nn()&&!dnri_hook)
1905
1902
            {
1906
1903
                 pen += old_diskr;
1910
1907
                pen += check_inc_foots(c,2);
1911
1908
      pen += check_cursiv_inp(rast,c->w,c->h,foot_wid,dest_foot[0],'�');
1912
1909
     break;
1913
 
  case  (BYTE)'�'     :
1914
 
  case  (BYTE)'�'     : if(suspect_italic_ii()){ pen += old_diskr;break; }
 
1910
  case  (uchar)'�'     :
 
1911
  case  (uchar)'�'     : if(suspect_italic_ii()){ pen += old_diskr;break; }
1915
1912
                  pen += check_cursiv_inp(rast,c->w,c->h,foot_wid,dest_foot[0],'�');
1916
1913
                   break;
1917
 
  case  (BYTE)'�'     :
1918
 
  case  (BYTE)'�'     : if(suspect_italic_nn()){ pen += old_diskr;break; }
 
1914
  case  (uchar)'�'     :
 
1915
  case  (uchar)'�'     : if(suspect_italic_nn()){ pen += old_diskr;break; }
1919
1916
                  pen += check_cursiv_inp(rast,c->w,c->h,foot_wid,dest_foot[0],let);
1920
1917
                    break;
1921
 
  case  (BYTE)'�'     :
 
1918
  case  (uchar)'�'     :
1922
1919
  case  '4'     :
1923
 
  case  (BYTE)'�'     : if(suspect_italic_tche()){ pen += old_diskr;break; }
 
1920
  case  (uchar)'�'     : if(suspect_italic_tche()){ pen += old_diskr;break; }
1924
1921
                        pen = check_italic_ch(c->h);
1925
1922
                        break;
1926
 
  case  (BYTE)'�'     :
1927
 
  case  (BYTE)'�'     : pen = old_diskr + suspect_italic_iee(); /* ??? */
1928
 
                  break;
1929
 
  case  (BYTE)'�'     :
1930
 
  case  (BYTE)'�'     : pen = old_diskr;
1931
 
                  break;
1932
 
  case (BYTE)'�'  :
1933
 
  case (BYTE)'�'  :
 
1923
  case  (uchar)'�'     :
 
1924
  case  (uchar)'�'     : pen = old_diskr + suspect_italic_iee(); /* ??? */
 
1925
                  break;
 
1926
  case  (uchar)'�'     :
 
1927
  case  (uchar)'�'     : pen = old_diskr;
 
1928
                  break;
 
1929
  case (uchar)'�'  :
 
1930
  case (uchar)'�'  :
1934
1931
                if(suspect_italic_kk()){ pen += old_diskr;break; }
1935
1932
                pen = check_kk(c->h);
1936
1933
                if( nstick==2 || nstick_broken==2 )
1943
1940
return pen;
1944
1941
}
1945
1942
 
1946
 
WORD check_III_bend(cell *c,INT dest_foot[])
 
1943
uint16_t check_III_bend(cell *c,int16_t dest_foot[])
1947
1944
{
1948
 
WORD pen=0;
1949
 
INT w=c->w,h=c->h,i,j,hh=c->h>>1,num;
 
1945
uint16_t pen=0;
 
1946
int16_t w=c->w,h=c->h,i,j,hh=c->h>>1,num;
1950
1947
if( broken_flag )
1951
1948
        return 0;
1952
1949
   stick_online(c);
1982
1979
  return pen;
1983
1980
}
1984
1981
 
1985
 
WORD check_III(cell *c,INT wid_foot,INT dest_foot[])
 
1982
uint16_t check_III(cell *c,int16_t wid_foot,int16_t dest_foot[])
1986
1983
{
1987
 
INT dy=c->h;
1988
 
INT i=dy*3/8;
1989
 
INT h=dy-dy*3/8,s2,ss,d;
1990
 
WORD pen=0;
 
1984
int16_t dy=c->h;
 
1985
int16_t i=dy*3/8;
 
1986
int16_t h=dy-dy*3/8,s2,ss,d;
 
1987
uint16_t pen=0;
1991
1988
 
1992
1989
stick_online(c);
1993
1990
if( nstick != 3 && !broken_flag) return 60;
2020
2017
 
2021
2018
/* ����� ���� ����� ��㣮��� ���� */
2022
2019
 
2023
 
INT triangle_bottom(BYTE *raster,INT dx, INT dy, INT wid)
 
2020
int16_t triangle_bottom(uchar *raster,int16_t dx, int16_t dy, int16_t wid)
2024
2021
{
2025
 
INT BD_X = (dx+7)>>3;
 
2022
int16_t BD_X = (dx+7)>>3;
2026
2023
 
2027
 
BYTE *R = &raster[(dy-1)*BD_X];
2028
 
INT bx = 0, ex = (dx>>1)-1, H = dy / 3;
2029
 
INT old,new,s,i;
2030
 
INT good_inc;
 
2024
uchar *R = &raster[(dy-1)*BD_X];
 
2025
int16_t bx = 0, ex = (dx>>1)-1, H = dy / 3;
 
2026
int16_t old,new,s,i;
 
2027
int16_t good_inc;
2031
2028
 
2032
2029
for(good_inc=s=old=i=0;i<H && s<4; i++, R-=BD_X)
2033
2030
        {
2047
2044
}
2048
2045
 
2049
2046
/* �ࠢ�� ���� ����� ��㣮��� ���� */
2050
 
INT triangle_top(BYTE *raster,INT dx, INT dy, INT wid)
 
2047
int16_t triangle_top(uchar *raster,int16_t dx, int16_t dy, int16_t wid)
2051
2048
{
2052
 
INT BD_X = (dx+7)>>3;
2053
 
BYTE *R = &raster[0];
2054
 
INT bx = (dx>>1), ex = dx-1, H = dy / 3;
2055
 
INT old,new,s,i;
2056
 
INT good_inc;
 
2049
int16_t BD_X = (dx+7)>>3;
 
2050
uchar *R = &raster[0];
 
2051
int16_t bx = (dx>>1), ex = dx-1, H = dy / 3;
 
2052
int16_t old,new,s,i;
 
2053
int16_t good_inc;
2057
2054
 
2058
2055
 
2059
2056
for(good_inc=s=old=i=0;i<H && s<4; i++, R+=BD_X)
2074
2071
return(s>3 && (old<wid+2||good_inc>2)  );
2075
2072
}
2076
2073
 
2077
 
INT    calc_dest_foot(INT h,INT w,INT *dest_foot,INT wid_foot)
 
2074
int16_t    calc_dest_foot(int16_t h,int16_t w,int16_t *dest_foot,int16_t wid_foot)
2078
2075
{
2079
 
INT i,beg=h>>2,end=h-beg,p;
2080
 
INT n[256],n_max;
 
2076
int16_t i,beg=h>>2,end=h-beg,p;
 
2077
int16_t n[256],n_max;
2081
2078
if( w>sizeof(n)/sizeof(n[0]) )
2082
2079
  return *dest_foot;
2083
2080
memset(n,0,2*w);
2100
2097
return n_max>3 ? p : *dest_foot ;
2101
2098
}
2102
2099
 
2103
 
BOOL up_ii_config(INT i)
 
2100
Bool up_ii_config(int16_t i)
2104
2101
{
2105
2102
if( hist_white[i]==0 )i--;
2106
2103
return( hist_white[i-2]<5 &&
2107
2104
    hist_white[i-1]<hist_white[i-2] &&
2108
2105
                hist_white[i]<hist_white[i-1] );
2109
2106
}
2110
 
BOOL down_ii_config(INT i)
 
2107
Bool down_ii_config(int16_t i)
2111
2108
{
2112
2109
if( hist_white[i]==0 )i++;
2113
2110
return( hist_white[i+2]<5 &&
2115
2112
                hist_white[i]<hist_white[i+1] );
2116
2113
}
2117
2114
 
2118
 
INT    check_cursiv_inp(BYTE *raster,INT w,INT h,INT foot_wid,INT dest_foot,
2119
 
                        BYTE let)
 
2115
int16_t    check_cursiv_inp(uchar *raster,int16_t w,int16_t h,int16_t foot_wid,int16_t dest_foot,
 
2116
                        uchar let)
2120
2117
{
2121
 
INT i,j,beg=h>>2,end=h-beg;
2122
 
INT lim ,n_long,n_3,pen=0,p,n_1,n_long_p;
2123
 
INT up_n_signum=0,down_n_signum=0,dop=h>22?3:2;
2124
 
INT stair=0,old,new,similar_n=0,similar_i=0,min_dest;
2125
 
INT lstairs,rstairs,n_empty;
2126
 
INT up_stair=0;
 
2118
int16_t i,j,beg=h>>2,end=h-beg;
 
2119
int16_t lim ,n_long,n_3,pen=0,p,n_1,n_long_p;
 
2120
int16_t up_n_signum=0,down_n_signum=0,dop=h>22?3:2;
 
2121
int16_t stair=0,old,new,similar_n=0,similar_i=0,min_dest;
 
2122
int16_t lstairs,rstairs,n_empty;
 
2123
int16_t up_stair=0;
2127
2124
 
2128
2125
if( dest_foot==0 )
2129
2126
        return 0;/* ���� �� ����ﭨ� 0 */
2303
2300
 
2304
2301
switch( let )
2305
2302
        {
2306
 
        case (BYTE)'�': case (BYTE)'�':
 
2303
        case (uchar)'�': case (uchar)'�':
2307
2304
                if( n_long_p>2 )
2308
2305
                        pen += 80;
2309
2306
                if( n_3>3 )
2315
2312
 
2316
2313
                break;
2317
2314
 
2318
 
        case (BYTE)'�': case (BYTE)'�':
 
2315
        case (uchar)'�': case (uchar)'�':
2319
2316
                if( n_long==0 )
2320
2317
                        pen += 160;
2321
2318
                if( p )
2322
2319
                        pen += 160;     /* similar to � */
2323
2320
    if( similar_n<2 )   pen += /*30**/similar_i;
2324
2321
                break;
2325
 
  case (BYTE)'�': case (BYTE)'�':
 
2322
  case (uchar)'�': case (uchar)'�':
2326
2323
                if( !p )
2327
2324
                {
2328
2325
                if( n_3==0 && n_long==0 )
2358
2355
                else if( similar_n && n_1>3 && stair<3 )
2359
2356
                        pen += 60;
2360
2357
                break;
2361
 
  case (BYTE)'�' : case (BYTE)'�' :
 
2358
  case (uchar)'�' : case (uchar)'�' :
2362
2359
    if( !(stick[0].incl!=stick[1].incl&&uple_hook&&dnri_hook) )
2363
2360
    if( nstick==2 && stick[1].incl || nstick_broken==2   )
2364
2361
      {
2366
2363
        pen += 80;
2367
2364
      if( down_n_signum && dest_foot-dop>=2 )
2368
2365
        pen += 80;
2369
 
      if( let==(BYTE)'�' )
 
2366
      if( let==(uchar)'�' )
2370
2367
        pen >>= 1;
2371
2368
      }
2372
2369
      break;
2376
2373
return pen ;
2377
2374
}
2378
2375
 
2379
 
INT    check_kk(INT h)
 
2376
int16_t    check_kk(int16_t h)
2380
2377
{
2381
 
INT i,lim,beg=h>>2,end=h-beg,n_3;
 
2378
int16_t i,lim,beg=h>>2,end=h-beg,n_3;
2382
2379
 
2383
2380
if( nstick==1 )
2384
2381
        return 0;
2397
2394
 
2398
2395
 
2399
2396
// End of Oleg zone
2400
 
WORD check_inc_foots(cell * c,INT nums)
 
2397
uint16_t check_inc_foots(cell * c,int16_t nums)
2401
2398
{
2402
 
INT i,dis=0;
 
2399
int16_t i,dis=0;
2403
2400
 
2404
2401
      stick_online(c);
2405
2402
      if( nstick != nums && !broken_flag ) return 40;
2408
2405
  return dis;
2409
2406
}
2410
2407
 
2411
 
WORD check_num_foots(INT nums,INT dy)
 
2408
uint16_t check_num_foots(int16_t nums,int16_t dy)
2412
2409
{
2413
 
INT i=dy/3,dis=0;
2414
 
INT h=i+dy/3,s2,ss;
 
2410
int16_t i=dy/3,dis=0;
 
2411
int16_t h=i+dy/3,s2,ss;
2415
2412
 
2416
2413
for(s2=ss=0;i < h;i++)
2417
2414
        if (hist_n[i]==nums)       s2++;
2426
2423
 
2427
2424
// a, cursiv a and o heuristic
2428
2425
 
2429
 
WORD check_oa( cell * c,BYTE let,struct rst * const rst)
 
2426
uint16_t check_oa( cell * c,uchar let,struct rst * const rst)
2430
2427
{
2431
 
INT r,gaps;
2432
 
WORD pen_a=0,pen_o=0,futuris=0;
 
2428
int16_t r,gaps;
 
2429
uint16_t pen_a=0,pen_o=0,futuris=0;
2433
2430
 
2434
2431
gaps = ((c_comp*)c->env)->nl - ((c_comp*)c->env)->begs - ((c_comp*)c->env)->ends + 1;
2435
2432
if( gaps > 1 ) return 0;
2437
2434
   futuris = check_futuris_aa( rst );
2438
2435
   pen_o  += futuris;
2439
2436
 
2440
 
   if( let == (BYTE)'�' && (corner_type(corners[0])==SERIF ||
 
2437
   if( let == (uchar)'�' && (corner_type(corners[0])==SERIF ||
2441
2438
     corner_type(corners[0])==NON_CURVE) ) pen_a += 80;
2442
2439
 
2443
2440
 if ((r=short_lines2(c))>0)
2450
2447
    else          pen_o += 10; // 1 short line
2451
2448
    }
2452
2449
  }
2453
 
   if(let == (BYTE)'�' && !check_bend_up(c) && !check_bend_dn(c)
 
2450
   if(let == (uchar)'�' && !check_bend_up(c) && !check_bend_dn(c)
2454
2451
      && corner_type(corners[3]) == CURVE  && futuris < 50 )
2455
2452
     pen_a +=  r>0 ? 80 : 90;// 'a' bend
2456
2453
   else
2457
 
    if(let == (BYTE)'�' && !check_bend_up(c) && !check_bend_dn(c) &&
 
2454
    if(let == (uchar)'�' && !check_bend_up(c) && !check_bend_dn(c) &&
2458
2455
       futuris < 50 ) pen_a += o_symmetric(c->h,c->w);
2459
2456
 
2460
 
 return (let == (BYTE)'�') ? pen_a : pen_o ;
 
2457
 return (let == (uchar)'�') ? pen_a : pen_o ;
2461
2458
 }
2462
 
INT o_symmetric(INT h,INT w)
 
2459
int16_t o_symmetric(int16_t h,int16_t w)
2463
2460
{
2464
 
INT  i,asym=0,center_l,center_r;
 
2461
int16_t  i,asym=0,center_l,center_r;
2465
2462
 if(w%2==0)center_l=center_r=w/2;
2466
2463
 else{ center_l=w/2; center_r=w/2+1; } // exclude center column
2467
2464
 for(i=h*2/3;i < ((h < 16) ? h : h-1) ; i++)
2469
2466
  return (asym < h/5)*40;
2470
2467
}
2471
2468
/////////////////////////////////////////////////////////////////////
2472
 
void calc_abris(PBYTE pint,INT height )
 
2469
void calc_abris(puchar pint,int16_t height )
2473
2470
{
2474
 
 INT col,i,ndx;
 
2471
 int16_t col,i,ndx;
2475
2472
 segment * segm = (segment*)pint;
2476
2473
 
2477
2474
 memset(l_abris,0x33,sizeof l_abris );
2502
2499
        }
2503
2500
}
2504
2501
////////////////////////////////////////////////////////////////////
2505
 
BOOL valid_line(segment * segm)
 
2502
Bool valid_line(segment * segm)
2506
2503
{
2507
 
WORD vl=0;
 
2504
uint16_t vl=0;
2508
2505
 
2509
2506
do
2510
2507
 if(segm->segblack > 1) vl++;
2512
2509
return (vl > 0);
2513
2510
}
2514
2511
 
2515
 
static BYTE futuris[]={ 30,90,140,210 };
 
2512
static uchar futuris[]={ 30,90,140,210 };
2516
2513
 
2517
 
WORD check_futuris_aa(struct rst * const rst)
 
2514
uint16_t check_futuris_aa(struct rst * const rst)
2518
2515
{
2519
 
INT i,pen=0,h,max_value;
2520
 
WORD max,index;
2521
 
BYTE hist[128]={0};
 
2516
int16_t i,pen=0,h,max_value;
 
2517
uint16_t max,index;
 
2518
uchar hist[128]={0};
2522
2519
        if( ! abris_online ){ abris_online = TRUE;
2523
2520
          calc_abris(segment_pool,rst->h);
2524
2521
        }
2556
2553
        if(r_abris[i] - r_abris[i+1] < 0 ||
2557
2554
           r_abris[i] - r_abris[i+1]  > 2) break;
2558
2555
      if( i >= h*6/7){ // ����⮭�� ������ �뢠�� ! � ��᪮�쪮 ࠢ����୮ ?
2559
 
        INT tan,lbound = i,sum=0;
 
2556
        int16_t tan,lbound = i,sum=0;
2560
2557
  tan =(i-max_value) / (r_abris[max_value]-r_abris[i]) +
2561
2558
       ((i-max_value) % (r_abris[max_value]-r_abris[i]))/((i-max_value)/2);
2562
2559
         for(i=max_value;i < lbound;i++)
2571
2568
 return pen;
2572
2569
}
2573
2570
 
2574
 
BOOL check_bend_up( cell * c )
 
2571
Bool check_bend_up( cell * c )
2575
2572
{
2576
2573
 lnhead *line;
2577
 
 INT l;
 
2574
 int16_t l;
2578
2575
 interval *i;
2579
 
 for (line=(lnhead *)((PCHAR)(c->env)+c->env->lines+sizeof(INT));
2580
 
                        (l=line->lth)>0; line=(lnhead *)((PCHAR)line+l)){
2581
 
 i=(interval *)((PCHAR)line+sizeof(lnhead));
 
2576
 for (line=(lnhead *)((pchar)(c->env)+c->env->lines+sizeof(int16_t));
 
2577
                        (l=line->lth)>0; line=(lnhead *)((pchar)line+l)){
 
2578
 i=(interval *)((pchar)line+sizeof(lnhead));
2582
2579
  if( line->row > c->h/2 && line->h*4 <= c->h && i->e-i->l > 3*c->w/4 &&
2583
2580
      line->flg & l_fbeg )
2584
2581
        return TRUE;
2585
2582
                        }
2586
2583
   return FALSE;
2587
2584
}
2588
 
BOOL check_bend_dn( cell * c )
 
2585
Bool check_bend_dn( cell * c )
2589
2586
{
2590
2587
 lnhead *line;
2591
 
 INT l;
 
2588
 int16_t l;
2592
2589
 interval *i;
2593
 
 for (line=(lnhead *)((PCHAR)(c->env)+c->env->lines+sizeof(INT));
2594
 
                        (l=line->lth)>0; line=(lnhead *)((PCHAR)line+l)){
2595
 
 i=(interval *)((PCHAR)line+sizeof(lnhead));
 
2590
 for (line=(lnhead *)((pchar)(c->env)+c->env->lines+sizeof(int16_t));
 
2591
                        (l=line->lth)>0; line=(lnhead *)((pchar)line+l)){
 
2592
 i=(interval *)((pchar)line+sizeof(lnhead));
2596
2593
  if( line->row > 2*c->h/3 && line->h*4 <= c->h && (i->e-i->l)*2 > c->w &&
2597
2594
      (line->flg & l_fend || line->flg & l_fbeg) && i->l <= c->w/3 &&
2598
2595
      ( (line->h == 1 && i->l > 3 && line->row != c->h-1) ||
2602
2599
                        }
2603
2600
   return FALSE;
2604
2601
}
2605
 
 INT short_lines2(cell *c)
 
2602
 int16_t short_lines2(cell *c)
2606
2603
 {
2607
2604
 lnhead *line;
2608
2605
 interval *intval;
2609
 
 INT l,row,col,h,w,a;
2610
 
 BYTE flg;
 
2606
 int16_t l,row,col,h,w,a;
 
2607
 uchar flg;
2611
2608
 
2612
 
 for (a=0,line=(lnhead *)((PCHAR)(c->env)+c->env->lines+sizeof(INT));
2613
 
                       (l=line->lth)>0; line=(lnhead *)((PCHAR)line+l)    )
 
2609
 for (a=0,line=(lnhead *)((pchar)(c->env)+c->env->lines+sizeof(int16_t));
 
2610
                       (l=line->lth)>0; line=(lnhead *)((pchar)line+l)    )
2614
2611
  if ((h=line->h)<=2)
2615
2612
   {
2616
2613
   flg=line->flg;
2617
2614
   row=line->row;
2618
 
   intval=(interval *)((PCHAR)line+sizeof(lnhead));
 
2615
   intval=(interval *)((pchar)line+sizeof(lnhead));
2619
2616
   if (h==2 && flg&l_fend) {intval++; row++;}
2620
2617
   w=intval->l;
2621
2618
   col=intval->e-w;
2630
2627
 
2631
2628
/* return dens = black*256/(black+white) */
2632
2629
/*******************************************************internal_filling*/
2633
 
static WORD internal_filling(segment * segm,INT h,INT w)
 
2630
static uint16_t internal_filling(segment * segm,int16_t h,int16_t w)
2634
2631
{
2635
 
 DWORD  fill=0;
2636
 
 LONG start, end, col;
2637
 
 LONG row,left,right,upper,lower;
 
2632
 uint32_t fill=0;
 
2633
 int32_t start, end, col;
 
2634
 int32_t row,left,right,upper,lower;
2638
2635
 
2639
2636
 if (h <= 4 || w <= 4) return 0;
2640
2637
 
2674
2671
     }
2675
2672
 }
2676
2673
 row=(h-2) * (w-left*left);
2677
 
 if ( fill >= 0x1000 ) return (WORD)(fill/(row >> 8));
2678
 
 if ( fill >= 0x100) return (WORD)((fill<<4)/(row>>4));
2679
 
 return (WORD)(( ( (WORD)fill ) << 8)/row); // (WORD)
 
2674
 if ( fill >= 0x1000 ) return (uint16_t)(fill/(row >> 8));
 
2675
 if ( fill >= 0x100) return (uint16_t)((fill<<4)/(row>>4));
 
2676
 return (uint16_t)(( ( (uint16_t)fill ) << 8)/row); // (uint16_t)
2680
2677
}
2681
2678
/**********************************************end of internal_filling*/
2682
2679
 
2683
 
WORD check_veza(cell * c,segment * segm,INT h,INT w,BYTE let)
 
2680
uint16_t check_veza(cell * c,segment * segm,int16_t h,int16_t w,uchar let)
2684
2681
{
2685
 
WORD pen_a,pen_e,pen_z,pen_v,pen_ie;
2686
 
INT gaps=-1,l;
2687
 
INT i,tresh,smooth,cnt;
 
2682
uint16_t pen_a,pen_e,pen_z,pen_v,pen_ie;
 
2683
int16_t gaps=-1,l;
 
2684
int16_t i,tresh,smooth,cnt;
2688
2685
lnhead *line;
2689
2686
interval *in;
2690
2687
 
2692
2689
 
2693
2690
     if(c)
2694
2691
 gaps = ((c_comp*)c->env)->nl - ((c_comp*)c->env)->begs - ((c_comp*)c->env)->ends + 1;
2695
 
 if( let == (BYTE)'�' && gaps == 1 && c->recsource & c_rs_ev )
 
2692
 if( let == (uchar)'�' && gaps == 1 && c->recsource & c_rs_ev )
2696
2693
        goto ret; // I trust events
2697
 
    if(!abris_online){  calc_abris((PBYTE)segm,h); abris_online=TRUE;  }
 
2694
    if(!abris_online){  calc_abris((puchar)segm,h); abris_online=TRUE;  }
2698
2695
if(!broken_flag){
2699
 
if(c && let != (BYTE)'�' && check_bend_up(c)){ pen_v+=80; pen_z+=80;pen_ie+=80; }
2700
 
if(c && let != (BYTE)'�' && check_bend_dn(c))
 
2696
if(c && let != (uchar)'�' && check_bend_up(c)){ pen_v+=80; pen_z+=80;pen_ie+=80; }
 
2697
if(c && let != (uchar)'�' && check_bend_dn(c))
2701
2698
 { pen_v+=80; pen_z+=80; pen_ie+=80; }
2702
2699
}
2703
2700
if( c && !check_bend_dn(c) && corner_type(corners[3]) == CURVE) pen_a += 60;
2709
2706
  if( dens > BOLD ){ pen_v += 100; pen_e += 80; }
2710
2707
  else if( dens > THIN ){ pen_v += 40; pen_e +=30; }
2711
2708
 
2712
 
  if( let == (BYTE)'�' && dens > BOLD && gaps == 2 &&
 
2709
  if( let == (uchar)'�' && dens > BOLD && gaps == 2 &&
2713
2710
      corner_type(corners[3]) != CURVE ) pen_e += 40;
2714
2711
 
2715
2712
  if(corner_type(corners[0]) == NON_CURVE &&   // refuse � -- �
2720
2717
  // h=i; // real height
2721
2718
 tresh = h/10 + h%10/5;  smooth=0;
2722
2719
 /* find  left pad */
2723
 
       if( let == (BYTE)'�' ){
2724
 
       CHAR jm1,jm2,jm3,jm4,pn;
 
2720
       if( let == (uchar)'�' ){
 
2721
       char jm1,jm2,jm3,jm4,pn;
2725
2722
            jm1=jm2=jm3=jm4=pn=0;
2726
2723
       for(i=h/4+h%4/2,cnt=0;i< h*3/4-1;i++)
2727
2724
        if(l_abris[i+1] - l_abris[i] > 0 )
2741
2738
        }
2742
2739
       pen_v += pn;
2743
2740
       }
2744
 
 if(let == (BYTE)'�' && c && dens > BOLD   && gaps == 2 &&
 
2741
 if(let == (uchar)'�' && c && dens > BOLD   && gaps == 2 &&
2745
2742
    corner_type(corners[0]) == CURVE &&
2746
2743
    corner_type(corners[2]) == CURVE
2747
2744
   ){ // refuse � -- blood � with 2 gaps
2748
 
 for (line=(lnhead *)((PCHAR)(c->env)+c->env->lines+sizeof(INT));
2749
 
                        (l=line->lth)>0; line=(lnhead *)((PCHAR)line+l)){
2750
 
 in=(interval *)((PCHAR)line+sizeof(lnhead));
 
2745
 for (line=(lnhead *)((pchar)(c->env)+c->env->lines+sizeof(int16_t));
 
2746
                        (l=line->lth)>0; line=(lnhead *)((pchar)line+l)){
 
2747
 in=(interval *)((pchar)line+sizeof(lnhead));
2751
2748
  if( !(line->flg & l_fbeg) && !(line->flg & l_fend) &&
2752
2749
     line->row > h/3 )
2753
2750
   for(i=0;i < line->h;i++,in++)
2761
2758
ret:
2762
2759
 // get out result
2763
2760
    switch(let){
2764
 
    case (BYTE)'�'  : return pen_a;
2765
 
    case (BYTE)'�'  : return pen_v;
2766
 
    case (BYTE)'�'  : return pen_z;
2767
 
    case (BYTE)'�'  :
 
2761
    case (uchar)'�'  : return pen_a;
 
2762
    case (uchar)'�'  : return pen_v;
 
2763
    case (uchar)'�'  : return pen_z;
 
2764
    case (uchar)'�'  :
2768
2765
                           // � ���������� ��� �. 08.09.2000 E.P.
2769
2766
           if (language==LANG_RUSSIAN && langBul)
2770
2767
                        return 200;
2771
2768
 
2772
2769
                return pen_ie;
2773
2770
 
2774
 
    case (BYTE)'�'  : return pen_e;
 
2771
    case (uchar)'�'  : return pen_e;
2775
2772
     default    : return 0;
2776
2773
    }
2777
2774
}
2778
2775
 
2779
 
static WORD check_ee( cell * c)
 
2776
static uint16_t check_ee( cell * c)
2780
2777
{
2781
 
INT    i, num;
 
2778
int16_t    i, num;
2782
2779
 
2783
2780
for(num=0,i=0;i<c->h; i++)
2784
2781
  num +=(hist_n[i]==2);
2788
2785
 
2789
2786
 
2790
2787
 
2791
 
WORD check_nn(cell * c)
 
2788
uint16_t check_nn(cell * c)
2792
2789
{
2793
 
INT gaps=-1,pen=0;
 
2790
int16_t gaps=-1,pen=0;
2794
2791
 
2795
2792
 if(c) gaps = ((c_comp*)c->env)->nl - ((c_comp*)c->env)->begs - ((c_comp*)c->env)->ends + 1;
2796
2793
 
2804
2801
/*============== Sources level 2 ========================*/
2805
2802
 
2806
2803
 
2807
 
static BOOL valid_inc( WORD inc )
 
2804
static Bool valid_inc( uint16_t inc )
2808
2805
{
2809
 
INT ret=0;
 
2806
int16_t ret=0;
2810
2807
 if( inc == 0 || inc > 800) ret = 0;
2811
2808
 else if( inc == 200 ) ret = 1;
2812
2809
      else             ret = 2;
2813
2810
return ret;
2814
2811
}
2815
2812
 
2816
 
extern INT nIncline;
 
2813
extern int16_t nIncline;
2817
2814
 
2818
 
INT sym_italic( cell * c ,BYTE let)
 
2815
int16_t sym_italic( cell * c ,uchar let)
2819
2816
{
2820
 
INT i,cs=0;
 
2817
int16_t i,cs=0;
2821
2818
   if( ! let_stick[let] ) return FALSE;
2822
2819
   stick_online(c);
2823
2820
  for(i=0;i < nstick;i++)
2834
2831
stick = NULL;nstickLP=0;stickLP=NULL;
2835
2832
}
2836
2833
 
2837
 
BOOL stick_online(cell * c)
 
2834
Bool stick_online(cell * c)
2838
2835
{
2839
2836
STICK * s;
2840
2837
if( stick || !c)
2848
2845
  stick = stic;
2849
2846
  if( nstick>0 && nstick<4 )
2850
2847
    {
2851
 
    c->n_baton = (BYTE)nstick;
 
2848
    c->n_baton = (uchar)nstick;
2852
2849
    memcpy(c->save_baton,s,nstick*sizeof(STICK));
2853
2850
    }
2854
2851
  else if( nstick==0 )
2868
2865
return stick != NULL;
2869
2866
}
2870
2867
 
2871
 
segment * go_line(segment * seg_pool,WORD ln)
 
2868
segment * go_line(segment * seg_pool,uint16_t ln)
2872
2869
{
2873
 
INT i;
 
2870
int16_t i;
2874
2871
for(i=0,seg_pool++;i < ln;i++) // skip lines
2875
2872
while((seg_pool++)->segwhite != 0x9000);
2876
2873
return seg_pool;
2884
2881
#define DB_TIF_COL 2            // first column in tif window
2885
2882
#define DB_TIF_H 13             // height of tif window
2886
2883
#define DB_TIF_W 40             // width of tif window
2887
 
void add_raster(PBYTE target,INT wb,INT row,INT col,PBYTE source,INT h,INT w);
 
2884
void add_raster(puchar target,int16_t wb,int16_t row,int16_t col,puchar source,int16_t h,int16_t w);
2888
2885
 
2889
2886
struct rst create_raster(cell * c, const s_glue * gl)
2890
2887
{
2891
2888
c_comp * cp;
2892
 
INT i,right,bottom,left,upper,wb;
 
2889
int16_t i,right,bottom,left,upper,wb;
2893
2890
struct rst _rst={0};
2894
 
PBYTE rast;
 
2891
puchar rast;
2895
2892
    if(gl != NULL){
2896
2893
    left=upper=30000U; right=bottom=0; i=0;
2897
2894
    while((cp = gl->complist[i++]) != NULL){
2909
2906
    while((cp = gl->complist[i++]) != NULL){
2910
2907
    online_comp(cp);
2911
2908
    rast = make_raster();
2912
 
    c_add_raster(work_raster_1,wb,(INT)(cp->upper - upper),(INT)(cp->left - left),
2913
 
               rast,cp->h,(INT)((cp->w+7)/8));
 
2909
    c_add_raster(work_raster_1,wb,(int16_t)(cp->upper - upper),(int16_t)(cp->left - left),
 
2910
               rast,cp->h,(int16_t)((cp->w+7)/8));
2914
2911
    }
2915
2912
     if(db_status && snap_activity(db_pass)){
2916
2913
     snap_show_raster(work_raster_1,_rst.h,_rst.w);
2934
2931
 
2935
2932
#define copy_byte       *t++=0xff
2936
2933
 
2937
 
void c_add_raster(PBYTE target,INT wb,INT y,INT col,PBYTE source,INT sh,INT swb)
 
2934
void c_add_raster(puchar target,int16_t wb,int16_t y,int16_t col,puchar source,int16_t sh,int16_t swb)
2938
2935
{
2939
 
BYTE m0,m1;
2940
 
PBYTE t;
2941
 
PBYTE s=source;
2942
 
INT i;
 
2936
uchar m0,m1;
 
2937
puchar t;
 
2938
puchar s=source;
 
2939
int16_t i;
2943
2940
         if( wb < swb ) return; // wider that target raster
2944
2941
        t=target+wb*y+col/8;   // offset in target raster
2945
2942
        col%=8;
2965
2962
/* hist_d - number of bits      in row          */
2966
2963
/*      return height of multicell              */
2967
2964
/*                                              */
2968
 
INT multicell_hist(cell *base_c, const s_glue *GL,INT hist_n[], INT hist_d[])
 
2965
int16_t multicell_hist(cell *base_c, const s_glue *GL,int16_t hist_n[], int16_t hist_d[])
2969
2966
{
2970
2967
cell *c;
2971
 
INT i,minrow,maxrow,ncells=0,dy;
 
2968
int16_t i,minrow,maxrow,ncells=0,dy;
2972
2969
 
2973
2970
if( base_c==NULL && GL==NULL )
2974
2971
        return 0;
3005
3002
        {
3006
3003
        if( (c=GL->celist[i])->env==NULL )
3007
3004
                continue;              /* no enviroment   */
3008
 
        add_cell_to_hist(c,(INT)(c->row-minrow),hist_n,hist_d);
 
3005
        add_cell_to_hist(c,(int16_t)(c->row-minrow),hist_n,hist_d);
3009
3006
        }
3010
3007
 
3011
3008
return dy;
3013
3010
 
3014
3011
/* add_cell_to_hist : �������� ���⮣ࠬ�� �� ���ࢠ��� ���⪨  */
3015
3012
/*      off_str - ᬥ饭�� ���⪨ �� ����                     */
3016
 
void add_cell_to_hist(cell *c,INT off_str,INT hist_n[],INT hist_d[])
 
3013
void add_cell_to_hist(cell *c,int16_t off_str,int16_t hist_n[],int16_t hist_d[])
3017
3014
{
3018
 
 INT ll,ind,h;
 
3015
 int16_t ll,ind,h;
3019
3016
 lnhead   *line;
3020
3017
 interval *inter;
3021
3018
 
3022
 
for (line=(lnhead *)((PCHAR)(c->env)+c->env->lines+sizeof(INT));
3023
 
                (ll=line->lth)>0; line=(lnhead *)((PCHAR)line+ll))
 
3019
for (line=(lnhead *)((pchar)(c->env)+c->env->lines+sizeof(int16_t));
 
3020
                (ll=line->lth)>0; line=(lnhead *)((pchar)line+ll))
3024
3021
        {
3025
3022
        h=line->h;
3026
3023
        for( ind=off_str+line->row,
3027
 
             inter=(interval *)((PCHAR)line+sizeof(lnhead));
 
3024
             inter=(interval *)((pchar)line+sizeof(lnhead));
3028
3025
             h ;ind++,h--,inter++)              /* one line     */
3029
3026
                {
3030
3027
                hist_d[ind] += inter->l;/* number of bits      in row */
3035
3032
return;
3036
3033
}
3037
3034
/***************************************** start make_white_hist */
3038
 
void make_white_hist(PBYTE pint,INT height)
 
3035
void make_white_hist(puchar pint,int16_t height)
3039
3036
{
3040
3037
 segment * segm;
3041
 
 LONG i;                                                 //change from INT
 
3038
 int32_t i;                                                 //change from int16_t
3042
3039
 
3043
3040
 memset(hist_white,0,height<<1);
3044
3041
 for(i=0,segm = (segment*)pint,segm++;i < height;i++)
3060
3057
/**************************************** end of make_white_hist */
3061
3058
 
3062
3059
// Miscellaneous
3063
 
WORD stick_bI(cell * cl)
 
3060
uint16_t stick_bI(cell * cl)
3064
3061
{
3065
3062
cell *  c, sc;
3066
 
INT     dist;
 
3063
int16_t     dist;
3067
3064
 
3068
3065
c = cl->prevl;
3069
3066
if( c )
3085
3082
}
3086
3083
 
3087
3084
// similar to true stick '|' or not
3088
 
BOOL    test_I(cell *c)
 
3085
Bool    test_I(cell *c)
3089
3086
{
3090
3087
cell    sc;
3091
3088
if( c->nvers<1 || c->vers[0].let!='1' )
3098
3095
return (sc.vers[0].prob>220);
3099
3096
}
3100
3097
 
3101
 
void proc_bI(INT pass)
 
3098
void proc_bI(int16_t pass)
3102
3099
{
3103
3100
cell * c,*clist[8];
3104
 
BYTE let;
 
3101
uchar let;
3105
3102
 
3106
3103
c = cell_f();
3107
3104
while((c=c->nextl) != NULL )
3131
3128
        clist[0]=c;
3132
3129
        clist[1]=c->nextl;
3133
3130
        compose_cell(2,clist,c);
3134
 
        let = is_lower(let) ? (BYTE)'�' : (BYTE)'�';
 
3131
        let = is_lower(let) ? (uchar)'�' : (uchar)'�';
3135
3132
        c->vers[0].let = let;
3136
3133
            c->recsource = 0; // artifact
3137
3134
            c->dens = 255; // undef
3141
3138
return;
3142
3139
}
3143
3140
 
3144
 
WORD check_I_dot(cell * c,BYTE let)
 
3141
uint16_t check_I_dot(cell * c,uchar let)
3145
3142
{
3146
3143
 switch( let ){ // !,1,! with dot :  can't be pasted
3147
3144
 case '1'       : return (c->cg_flag & c_cg_cut) ? 80  : 0;
3170
3167
/*      s - ������ ���⪠ ᪫���� GL; [(c1,r1),(c2,r2)] - �������   */
3171
3168
/*      c1,c2,r1,r2 - ���न���� ����७���� ��אַ㣮�쭨��               */
3172
3169
/*              ��ࠦ���� � ��業�� (�� ࠧ��஢ �����窨)                */
3173
 
BOOL dust_in_glue( cell *s, s_glue *GL,INT c1,INT r1,INT c2, INT r2)
 
3170
Bool dust_in_glue( cell *s, s_glue *GL,int16_t c1,int16_t r1,int16_t c2, int16_t r2)
3174
3171
{
3175
3172
cell *c,*ss=NULL;
3176
 
INT ncells,maxrow,minrow,maxcol,mincol,h,w;
 
3173
int16_t ncells,maxrow,minrow,maxcol,mincol,h,w;
3177
3174
 
3178
3175
if( GL==NULL && s==NULL )       return FALSE;
3179
3176
 
3246
3243
return FALSE;
3247
3244
}
3248
3245
 
3249
 
BOOL dust_near_rusG(cell *cc)
 
3246
Bool dust_near_rusG(cell *cc)
3250
3247
{
3251
3248
cell *c;
3252
 
INT dw,dh;
 
3249
int16_t dw,dh;
3253
3250
 
3254
3251
if( cc==NULL )  return FALSE;
3255
3252
c = cc->prev;
3276
3273
return ;
3277
3274
}
3278
3275
 
3279
 
INT RE_rus_Ge(INT hist[], INT histd[], INT hei, INT wid)
 
3276
int16_t RE_rus_Ge(int16_t hist[], int16_t histd[], int16_t hei, int16_t wid)
3280
3277
{
3281
 
INT i,num;
 
3278
int16_t i,num;
3282
3279
 
3283
3280
wid = (wid >> 1)+(wid >> 2);
3284
3281
for(num=i=0;i<hei;i++)
3301
3298
return num;
3302
3299
}
3303
3300
 
3304
 
BOOL similar_S( INT hist_n[],INT hist_d[], INT w,INT h)
 
3301
Bool similar_S( int16_t hist_n[],int16_t hist_d[], int16_t w,int16_t h)
3305
3302
{
3306
 
INT i,ii,p,pp;
 
3303
int16_t i,ii,p,pp;
3307
3304
for(ii=h-1,p=pp=i=0;i<3;i++,ii--)
3308
3305
  {
3309
3306
  p  += (hist_n[i]==1  && hist_d[i]>w);
3313
3310
return( p==3 && pp==3 );
3314
3311
}
3315
3312
 
3316
 
BOOL similar_R( INT hist_n[], INT h)
 
3313
Bool similar_R( int16_t hist_n[], int16_t h)
3317
3314
{
3318
 
INT i,ii,p;
 
3315
int16_t i,ii,p;
3319
3316
for(ii=h-1,p=i=0;i<h/2;i++,ii--)
3320
3317
  p  += (hist_n[i]==2);
3321
3318
 
3324
3321
 
3325
3322
void RE_final_descr(cell *c)
3326
3323
{
3327
 
INT F;
 
3324
int16_t F;
3328
3325
struct rst _rst;
3329
3326
 
3330
3327
if( !memchr(Rus_similar_Eng,c->vers[0].let,sizeof(Rus_similar_Eng)) ||
3335
3332
 
3336
3333
switch( c->vers[0].let )
3337
3334
  {
3338
 
  case (BYTE)'�' :
 
3335
  case (uchar)'�' :
3339
3336
            if( c->nvers==1 && c->vers[0].prob==254
3340
3337
                && similar_R( hist_n, c->h) )
3341
3338
                down_all_versions(c, 40);
3342
3339
             break;
3343
 
  case (BYTE)'�' : case (BYTE)'�' :
 
3340
  case (uchar)'�' : case (uchar)'�' :
3344
3341
             if( c->nvers==1 && c->vers[0].prob==254 )
3345
3342
                r_criteria(c,NULL);
3346
3343
             break;
3347
 
  case (BYTE)'$' :
3348
 
             if( c->h>15 && similar_S( hist_n, hist_d, (INT)(c->w/4), c->h) )
 
3344
  case (uchar)'$' :
 
3345
             if( c->h>15 && similar_S( hist_n, hist_d, (int16_t)(c->w/4), c->h) )
3349
3346
                down_all_versions(c, 40);
3350
3347
             break;
3351
3348
 
3352
 
  case (BYTE)'�' :
3353
 
  case (BYTE)'�' :
3354
 
             if( (F=RE_rus_Ge(hist_n, hist_d,(INT)(c->h<30?4:6),c->w))>0 )
3355
 
                down_all_versions(c, (INT)(2 + F*20));
3356
 
             break;
3357
 
  case (BYTE)'n' :
3358
 
  case (BYTE)'r' :
3359
 
             if( (F=RE_rus_Ge(hist_n, hist_d,(INT)(c->h<30?4:6),c->w))<0 )
3360
 
                down_all_versions(c, (INT)(2-F*20));
3361
 
             break;
3362
 
  case (BYTE)'N':
 
3349
  case (uchar)'�' :
 
3350
  case (uchar)'�' :
 
3351
             if( (F=RE_rus_Ge(hist_n, hist_d,(int16_t)(c->h<30?4:6),c->w))>0 )
 
3352
                down_all_versions(c, (int16_t)(2 + F*20));
 
3353
             break;
 
3354
  case (uchar)'n' :
 
3355
  case (uchar)'r' :
 
3356
             if( (F=RE_rus_Ge(hist_n, hist_d,(int16_t)(c->h<30?4:6),c->w))<0 )
 
3357
                down_all_versions(c, (int16_t)(2-F*20));
 
3358
             break;
 
3359
  case (uchar)'N':
3363
3360
             _rst = create_raster(c,NULL);
3364
3361
             if(_rst.raster )
3365
3362
                {
3366
 
                INT pen =
3367
 
             Diskrim((BYTE)'N',_rst.raster,_rst.w,0,0,_rst.w,_rst.h,c->cg_flag,
3368
 
                   (INT)(c->save_stick_inc!=NO_INCLINE?c->save_stick_inc:0));
 
3363
                int16_t pen =
 
3364
             Diskrim((uchar)'N',_rst.raster,_rst.w,0,0,_rst.w,_rst.h,c->cg_flag,
 
3365
                   (int16_t)(c->save_stick_inc!=NO_INCLINE?c->save_stick_inc:0));
3369
3366
             if(  pen )
3370
 
                down_all_versions(c, (INT)(pen));
 
3367
                down_all_versions(c, (int16_t)(pen));
3371
3368
                }
3372
3369
             break;
3373
3370
  default :  break;