2
Copyright (c) 1993-2008, Cognitive Technologies
5
����������� ��������� ��������������� � ������������� ��� � ���� ��������� ����,
6
��� � � �������� �����, � ����������� ��� ���, ��� ���������� ��������� �������:
8
* ��� ��������� ��������������� ��������� ���� ������ ���������� ���������
9
���� ����������� �� ��������� �����, ���� ������ ������� � �����������
11
* ��� ��������� ��������������� ��������� ���� � ������������ �/��� �
12
������ ����������, ������������ ��� ���������������, ������ �����������
13
��������� ���� ���������� �� ��������� �����, ���� ������ ������� �
14
����������� ����� �� ��������.
15
* �� �������� Cognitive Technologies, �� ����� �� ����������� �� �����
16
���� ������������ � �������� �������� ��������� �/��� �����������
17
���������, ���������� �� ���� ��, ��� ���������������� �����������
20
��� ��������� ������������� ����������� ��������� ���� �/��� ������� ������ "���
21
��� ����" ��� ������-���� ���� ��������, ���������� ���� ��� ���������������,
22
������� �������� ������������ �������� � ����������� ��� ���������� ����, �� ��
23
������������� ���. �� �������� ��������� ���� � �� ���� ������ ����, �������
24
����� �������� �/��� �������� �������������� ���������, �� � ���� ������ ��
25
��Ѩ� ���������������, ������� ����� �����, ���������, ����������� ���
26
������������� ������, ��������� � �������������� ��� ���������� ����������
27
������������� ������������� ��������� (������� ������ ������, ��� ������,
28
������� ���������, ��� ������ �/��� ������ �������, ���������� ��-�� ��������
29
������� ��� �/��� ������ ��������� �������� ��������� � ������� �����������,
30
�� �� ������������� ����� ��������), �� �� ������������� ���, ���� ���� �����
31
�������� ��� ������ ���� ���� �������� � ����������� ����� ������� � ������.
33
Redistribution and use in source and binary forms, with or without modification,
34
are permitted provided that the following conditions are met:
36
* Redistributions of source code must retain the above copyright notice,
37
this list of conditions and the following disclaimer.
38
* Redistributions in binary form must reproduce the above copyright notice,
39
this list of conditions and the following disclaimer in the documentation
40
and/or other materials provided with the distribution.
41
* Neither the name of the Cognitive Technologies nor the names of its
42
contributors may be used to endorse or promote products derived from this
43
software without specific prior written permission.
45
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
46
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
47
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
48
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
49
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
51
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
52
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
53
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
54
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
71
#include "compat_defs.h"
73
extern BOOL line_readyBL;
74
extern BYTE p2_active;
76
extern INT page_nIncline;
77
extern BYTE line_scale;
78
extern WORD actual_resolution;
82
struct word_inf {cell *c; INT dens,n;} bld[WORDMAX];
85
static void italic(cell *);
86
static INT linerev(INT,INT *);
87
static LONG inclin(INT,INT *);
88
static void serif(cell *);
89
static void underline();
90
static BYTE keg_word(cell *,cell *,INT,B_LINES *);
91
static void bold_word(cell *,cell *,struct word_inf *);
92
static INT dens_let(cell *);
96
extern BYTE line_tabcell;
98
static BYTE bad_italic[]="03���������eocOC"; // a g m u..."03���������eocOC"
99
static BYTE nei_italic[]="02356789()%����������"; // "02356789()%����������"
100
static BYTE one_italic[]="��"; // "��"
104
struct B { INT mid; // �ࠪ���⨪�
109
typedef struct B STAT;
111
STAT stat_tabgi[256];
112
STAT stat_tabss[256];
113
STAT stat_tabgs[256];
114
STAT stat_tabcr[256];
115
STAT stat_tabmd[256];
118
void print_stat(FILE * f,STAT * stat)
124
// ������ ⮫쪮 �� ����� ��ப�
125
BYTE * byte = (BYTE *)(stat+i*16+j);
126
for(k=0;k<sizeof(STAT);k++)
129
fprintf(f, "\n\n "); for(j=0;j<16;j++)fprintf(f," %3c",i*16+j);
130
fprintf(f, "\nmid "); for(j=0;j<16;j++)fprintf(f," %3i",stat[i*16+j].mid);
131
fprintf(f, "\nreal"); for(j=0;j<16;j++)fprintf(f," %3i",stat[i*16+j].real);
132
fprintf(f, "\nmax "); for(j=0;j<16;j++)fprintf(f," %3i",stat[i*16+j].max);
133
fprintf(f, "\nmin "); for(j=0;j<16;j++)fprintf(f," %3i",stat[i*16+j].min);
134
fprintf(f," \nn "); for(j=0;j<16;j++)fprintf(f," %3i",stat[i*16+j].n);
139
memset(stat,0,sizeof(STAT)*256);// ���ᨢ ����� ���� �ᯮ�짮��� �������
147
for (c=(cell_f())->next; c->next!=NULL; c=c->next)
148
if (c->flg&c_f_let && tsimple(c))
156
if( snap_activity('i') ){
157
snap_newcell((cell_f())->next);
158
snap_show_text("FOR ITALIC DEBUG");
164
static BYTE twinsl[]={"cCpPsSvVwVxXzZ0O1l"};
165
static BYTE twinsr[]={"�������������������������������������������"};
166
// "����������������������������������������������������������
168
#define NVAR 256 // Valdemar & Oleg
171
#define f_italic_add 6
172
#define f_italic_lst 20
173
#define PROBMIN 30000
176
static BYTE solid_italic[]="������"; // a g m u...
177
static BYTE strong_italic[]="�����"; // a is not strong
178
//static BYTE non_inclinable_letters[]="�Ꭾ�";
179
static void italic(cell *c)
189
INT nansw,maxi,maxni,l;
190
extern PCHAR tableBOX;
191
INT sv_pos_inc , sv_stick_inc, sv_save_stick_inc;
192
BOOL bad_cur_ge, disable_it=FALSE;
194
if( c->pos_inc==erect_no )
197
sv_pos_inc = c->pos_inc ;
198
sv_stick_inc = c->stick_inc ;
199
sv_save_stick_inc = c->save_stick_inc ;
201
c->save_stick_inc = c->stick_inc;
202
c->stick_inc = (INT)0x8000;
203
bad_cur_ge = (c->vers[0].let==r_cu_z &&
204
(c->recsource==c_rs_ev || c->recsource==(c_rs_ev|c_rs_deskr)) &&
205
c->vers[0].prob==254);
206
if(language==LANG_RUSSIAN &&
207
(memchr(solid_italic,c->vers[0].let,sizeof(solid_italic))||
208
p2_active&&sv_save_stick_inc>250&&sv_save_stick_inc!=NO_INCLINE)&&
212
c->stick_inc |= 0x4000;
215
if( c->save_stick_inc == NO_INCLINE )
218
if( c->save_stick_inc != NO_INCLINE &&
219
!memchr("$ā/",c->vers[0].let,7) &&
220
!(language==LANG_RUSSIAN && c->vers[0].let==r_cu_z) ){
221
if( c->save_stick_inc > 250 /*&& !disable_it */)
226
c->stick_inc |= 0x2000;
231
c->font_new |= c_fp_it;
239
GL.complist[0]=c->env;
242
if ((s=make_broken_raster(&GL,1))!=NULL)
244
let=let_sans_acc[c->vers[0].let];
248
// let>=ligas_beg && let<=ligas_end ||
249
is_liga(let) || // 14.09.2000 E.P.
250
memchr("$ā/",let,7) ||
251
language==LANG_RUSSIAN && let==r_cu_z )
252
if( !memchr("��",let,2) )
254
c->stick_inc |= 0x1000;
260
if (let=='I' || let=='i' || let==liga_i ||
261
language == LANG_TURKISH && // 30.05.2002 E.P.
262
(let==i_sans_accent||let==II_dot_accent)
265
h=(indBOX *)tableBOX+let;
266
for (nansw=0,i=h->numel; !nansw || i; i=elm->list)
268
elm=(elmBOX *)(tableBOX+NLET*sizeof(indBOX))+i;
269
if( elm->bnd & 0x0100 )
271
if( !(c->pos_inc&erect_rot) && (elm->bnd & 0x0200) )
273
font[nansw]=elm->fnt;
274
prob[nansw]=(*scalarf)(elm->vect,s->matrBOX.vect,s->matrBOX.isq_rt);
277
if(language==LANG_RUSSIAN) twins=twinsr;
279
for (l=strlen(twins),i=0; i<l; i++)
281
{let=twins[i^1]; break;}
284
h=(indBOX *)tableBOX+let;
285
for (i=h->numel; !nansw || i; i=elm->list)
287
elm=(elmBOX *)(tableBOX+NLET*sizeof(indBOX))+i;
288
if( ( elm->bnd & 0x0100 ) == 1 )
290
if( !(c->pos_inc&erect_rot) && (elm->bnd & 0x0200) )
292
font[nansw]=elm->fnt;
293
prob[nansw]=(*scalarf)(elm->vect,s->matrBOX.vect,s->matrBOX.isq_rt);
297
for (maxi=maxni=i=0; i<nansw; i++)
299
if ( language == LANG_RUSSIAN && (font[i] & c_fp_it) ||
300
language != LANG_RUSSIAN && (font[i]==f_italic || font[i]>=f_italic_add && font[i]<=f_italic_lst)
310
if( !erection_language(language) )
312
if (maxi>PROBMIN && maxi-maxni>DPROB)
314
if (maxni>PROBMIN && maxni-maxi>DPROB)
317
else if( !(p2_active &&
318
sv_save_stick_inc>240 &&
319
sv_save_stick_inc!=NO_INCLINE
322
//if( !c->nvers|| !strchr(non_inclinable_letters,c->vers[0].let) )
328
c->pos_inc = (BYTE)sv_pos_inc ;
329
c->stick_inc = sv_stick_inc ;
330
c->save_stick_inc = sv_save_stick_inc ;
334
// ������� ����������� � ��������� ������������ '���������' �� ������ ����.
335
// ��� ����� ������������� ������-0x01 �/��� �����-0x02 �� �����
336
static CHAR tabincl[256]={
337
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0 - 23
338
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 24 - 47
339
// ! " # $ % & ' ( ) * + , - . /
340
0,3,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0, // 48 - 64
341
// 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @
342
0,2,0,2,2,2,0,3,3,3,2,3,3,3,0,2,0,2,0,3,3,0,0,0,0,0,// 65 - 90
343
// A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
344
0,0,0,0,0,0, // 91 - 96
346
0,2,0,1,0,0,0,2,3,3,2,3,3,3,0,2,1,2,0,3,3,0,0,0,0,0,// 97 - 122
347
// a b c d e f g h i j k l m n o p q r s t u v w x y z
348
0,0,0,0,0,0,2,2,2,0,2,3,0,3,3,2,1,3,3,0,3,2,0,3,3,0,3,3,//123 - 150
349
// { | } ~ � � � � � � � � � � � � � � � � � � � � � � �
350
3,3,3,2,3,2,0,2,1,0,0,2,2,0,0,3,0,3,3,2,1,3,3,0,3,0,// 151 - 176
351
// � � � � � � � � � � � � � � � � � � � � � � � � � �
352
0, 0, 0, 0, 2, 2,0,0, 0, 2,1,0,0, // 177 - 189
353
// fi fl ff ffi rt ri % % ffl i j ! ?
354
// � � � � � � � � � � � � �
355
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,// 190 - 223
356
// � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �
357
2,0,3,3,3,3,3,3,3,3,2,3,2,0,2,1, // 224 - 239
358
// � � � � � � � � � � � � � � � �
359
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // 240 - 255
360
// � � � � � � � � � � � � � � �
372
INT i,mini,maxi,h,nr,nl;
373
INT left[KEGMAX],right[KEGMAX];
375
interval *intv0,*intv,*intve;
378
let=let_sans_acc[c->vers[0].let];
379
//if( language==LANG_RUSSIAN || language==LANG_ENGLISH )
380
if( erection_cyr_language(language) )
382
if (c->env==NULL || (f=tabincl[let])==0 || c->h<KEGMIN)
384
mini=c->h/4; maxi=3*mini;
388
/* printf("let=%c,h=%u,mini=%u,maxi=%u\n",let,c->h,mini,maxi);*/
389
if (f&RINCL) {memset(right,0,h+h); nr=h;}
390
if (f&LINCL) {for (i=0; i<h; i++) left[i]=WMAX; nl=h;}
391
for (line=(lnhead *)((PCHAR)(c->env)+c->env->lines+sizeof(INT));
392
line->lth>0; line=(lnhead *)((PCHAR)line+line->lth))
393
if (line->row<=maxi && line->row+line->h>mini)
395
intv0=(interval *)((PCHAR)line+sizeof(lnhead));
396
intv=intv0+MAX(0,mini-line->row);
397
intve=intv0+MIN(maxi+1-line->row,line->h);
398
/* printf("y=%u,h=%u,b=%u,e=%u\n",line->row,line->h,
399
(intv-intv0)+line->row-mini,intve-intv0-1+line->row-mini);*/
400
for (i=intv-intv0+line->row-mini; intv<intve; intv++,i++)
402
if (f&RINCL && right[i]<intv->e-1) right[i]=intv->e-1;
403
if (f&LINCL && left[i]>intv->e-intv->l) left[i]=intv->e-intv->l;
407
if (f&RINCL && (nr=linerev(nr,right))>=KEGMIN/2)
408
{s+=inclin(nr,right); i++;}
409
if (f&LINCL && (nl=linerev(nl,left))>=KEGMIN/2)
410
{s+=inclin(nl,left); i++;}
413
if ((s=s/i-page_nIncline)>=((let=='/')?3:1)*BNDINCL)
414
{c->font_new|=c_fp_it; return 1*0;}
415
if (s<=((let=='/')?2:1)*BNDNINCL)
416
{c->font_new|=c_fp_str; return 1*0;}
420
static INT linerev(INT n,INT *line)
426
for (beg=n/2; beg; beg--)
427
if (abs(line[beg]-line[beg-1])>1) break;
428
for (end=n/2; end<n-1; end++)
429
if (abs(line[end]-line[end+1])>1) break;
430
for (i=beg; i<=end; i++) line[i-beg]=line[i];
431
/* for (i=0; i<=end-beg; i++) printf(" %u",line[i]); printf("\n");*/
435
static LONG inclin(INT n,INT *line)
440
for (sxy=sy=x=0; x<n; x++)
441
{sy+=line[x]; sxy+=x*line[x];}
442
inc=-12288*(2*sxy-(n-1)*sy)/(n*(n*n-1));
443
/* printf("sy=%ld,sxy=%ld,inc=%ld\n",sy,sxy,inc);*/
450
// ������ ���ନ��� � ��������� �ᯮ������� ��䮢 �� �㪢�
451
// ��� ����� ��������� � ������-0x01 �/��� ���孥�-0x02 ��� �㪢�
452
static CHAR tabserif[256]={
453
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0-23
454
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 24-47
455
// ! " # $ % & ' ( ) * + , - . /
456
0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0, // 48-64
457
// 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @
458
1,3,0,3,3,3,0,3,3,2,3,3,3,3,0,3,0,3,0,1,0,2,2,0,1,0, //65-90
459
// A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
462
0,1,0,1,0,1,0,1,1,1,1,1,1,1,0,3,3,1,0,0,0,2,2,0,2,0, // 97-122
463
// a b c d e f g h i j k l m n o p q r s t u v w x y z
464
0,0,0,0,0,1,3,3,3,1,3,0,0,3,3,3,1,3,3,0,1,3,0,1,2,3,0,3,//123-150
465
// { | } ~ � � � � � � � � � � � � � � � � � � � � � � �
466
3,0,0,3,3,3,0,0,3,0,0,3,3,1,0,0,0,3,3,3,1,3,3,0,1,0, //151-176
467
// � � � � � � � � � � � � � � � � � � � � � � � � � �
468
1, 1, 1, 1, 1, 1,0,0, 1, 1,0,0,0, // 177-189
469
// fi fl ff ffi rt ri % % ffl i j ! ?
470
// � � � � � � � � � � � � �
471
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,// 190 - 223
472
// � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �
473
3,0,3,2,3,0,3,3,0,0,3,3,3,0,0,3, // 224 - 239
474
// � � � � � � � � � � � � � � � �
475
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // 240 - 255
476
// � � � � � � � � � � � � � � �
479
static void serif(cell *c)
484
INT H,n1,n2,h,b1,b2,e1,e2;
487
let=let_sans_acc[c->vers[0].let];
488
for (n1=n2=0,line=(lnhead *)((PCHAR)(c->env)+c->env->lines+sizeof(INT));
489
line->lth>0; line=(lnhead *)((PCHAR)line+line->lth))
491
if (tabserif[let]&LSER && line->flg&l_fend && (h=line->h)>=5 && h>=H/4 &&
492
line->row+h+2>=H && !(c->font&c_fp_it && memchr("BLb",let,3)))
494
i1=(interval *)((PCHAR)line+sizeof(lnhead))+(h-3);
496
b1=MIN(MIN(i1->e-i1->l,(i1+1)->e-(i1+1)->l),(i1+2)->e-(i1+2)->l);
497
e1=MAX(MAX(i1->e,(i1+1)->e),(i1+2)->e);
499
if (e1>e2 && b1<b2) n1++;
500
if (abs(e1-b1-e2+b2)<=1 && abs(e1-e2)<=1 && abs(b1-b2)<=1) n2++;
502
if (tabserif[let]&HSER && line->flg&l_fbeg && (h=line->h)>=5 && h>=H/4 &&
503
line->row<=2 && !(c->font&c_fp_it && let=='q'))
505
i1=(interval *)((PCHAR)line+sizeof(lnhead));
507
b1=MIN(MIN(i1->e-i1->l,(i1+1)->e-(i1+1)->l),(i1+2)->e-(i1+2)->l);
508
e1=MAX(MAX(i1->e,(i1+1)->e),(i1+2)->e);
510
if (e1>e2 && b1<b2) n1++;
511
if (abs(e1-b1-e2+b2)<=1 && abs(e1-e2)<=1 && abs(b1-b2)<=1) n2++;
514
if (n1>n2) c->font|=c_fp_ser;
515
if (n1<n2) c->font|=c_fp_gelv;
533
static INT total_pitch=0; // =0 Nick 04.01.2002
534
static INT base_prevstr=0; // =0 Nick 04.01.2002
535
static INT kegl_prevstr=0; // =0 Nick 04.01.2002
539
extern INT line_number;
540
extern BOOL pass4_in;
543
get_b_lines(NULL,&bl);
544
if (!line_number || bl.b3<base_prevstr || bl.b3-base_prevstr>20*bl.ps ||
545
bl.b3-base_prevstr>5*bl.ps && abs(kegl_prevstr-bl.ps)>1)
546
total_pitch=0; // =0 Nick 04.01.2002 was = -1
555
INT nl,nc,ng,n,n1,n2,h,w,ww,wmin,wmax,i,j,sp,bad,d,p,mg;
557
WORD center[LSTRMAX],left[LSTRMAX],right[LSTRMAX];
559
for (nl=nc=ng=0,c=(cell_f())->next; c->next!=NULL; c=c->next)
560
if (c->flg&(c_f_let|c_f_bad))
563
if (!(c->cg_flag&(c_cg_cutr|c_cg_cutl)))
567
// (let=c->vers[0].let)>=ligas_beg && let<=ligas_end &&
568
is_liga(let) && // 14.09.2000 E.P.
571
!(language == LANG_TURKISH && // 30.05.2002 E.P.
572
(let==i_sans_accent||let==II_dot_accent)
574
let!=liga_j && let!=liga_exm && let!=liga_qm
579
for (n=0,c=(cell_f())->next; c->next!=NULL && n<LSTRMAX; c=c->next)
580
if (!(c->flg&(c_f_dust|c_f_space)) && (let=c->vers[0].let)!='[' &&
582
// (let<ligas_beg || let>ligas_end ||
583
(!is_liga(let) || // 14.09.2000 E.P.
586
language == LANG_TURKISH && // 30.05.2002 E.P.
587
(let==i_sans_accent||let==II_dot_accent) ||
588
let==liga_j || let==liga_exm || let==liga_qm) &&
589
(nl<NLETOK && c->flg&c_f_punct || c->flg&(c_f_let|c_f_bad)) &&
590
(nc<NCUTMAX || !(c->cg_flag&(c_cg_cutr|c_cg_cutl))))
593
right[n]=c->col+c->w;
594
center[n]=c->col+(c->w)/2;
595
if (((let=c->vers[0].let)=='l' || let=='1' || let=='I') &&
596
!(c->font&c_fp_it) && c->font&c_fp_gelv && 4*c->w>c->h)
598
if ((let=='i' && 5*c->w>2*c->h ||
600
language == LANG_TURKISH && // 30.05.2002 E.P.
601
(let==i_sans_accent||let==II_dot_accent)
603
!(c->font&c_fp_it) && c->font&c_fp_gelv)
605
if (let=='f' && !(c->font&c_fp_it) && c->font&c_fp_gelv && 2*c->w>c->h)
611
h=get_size()+((fax1x2)?2:0);
612
for (averwid=nl=0,min=10000,i=1; i<n; i++)
614
if (left[i]-right[i-1]<h)
615
{averwid+=center[i]-center[i-1]; nl++;}
616
if (min>center[i]-center[i-1])
617
min=center[i]-center[i-1];
619
if (nl>LSTRMIN || nl && 2*averwid<5*nl*h)
626
if( averwid <= 1 ) // Nick 01.04.2002 - �������� ������� �� 0
633
for (p=j=bad=nl=0,min=1000000,w=wmin; w<=wmax; w++)
636
for (sp=1,n2=n1=0,s=0,i=1; i<n; i++)
637
if (left[i]-right[i-1]<ww)
639
d=center[i]-center[i-1]-w;
640
if (d>-DELTMAX && 5*d<=2*w)
642
if (!fax1x2 || abs(d)>1)
647
d=(center[i-1]-center[j])%w;
649
if (!fax1x2 || abs(d)>1)
661
if (n2+ng<=NTHLMAX && n1>=LSTRMIN || !n2 && n1>=2)
664
if (s<=min || w==2*p && nl<n1 && s<5*min/2)
668
/* printf("p=%u,d=%u\n",p,s); scanf("%c",&i);*/
669
if (!nl || min>BND2*h)
673
if (abs(p-total_pitch)<=1)
678
if (abs(p-total_pitch)<=1)
680
if (abs(p/2-total_pitch)<=1)
682
if (p>2*h+((fax1x2)?1:0))
684
if (min<BNDOK*h && nl>1 || min<BND0*h && nl>=LSTRMIN && total_pitch)
686
if (nl<LSTRMIN && !fax1x2 || nl<LSTRMINF || nl<n/2 ||
687
!total_pitch && 3*(n-nl-1)>nl)
689
for (n1=0,s=0,i=1; i<n; i++)
691
if (left[i]-right[i-1]>=3*p/4)
693
d=center[i]-center[i-1]-p;
694
if (d>=-DELTMAX && 700l*d*d<min)
696
if (!fax1x2 || abs(d)>1)
701
if (n1>3 && n1>=n/2 && (12*n1>=7*n && nl-n1<=3 || 8*n1>=7*nl) &&
702
(1000l*s/(n1-1)<BND0*h || total_pitch && 1000l*s/(n1-1)<BND1*h))
706
///////////////////////////////////////////////////////////////////////////////////////////////////////
710
INT ni1,ni2,ns1,ns2,nu,n,trp;
712
BYTE fnt,fntu,fntprev;
724
INT nwi=1; // 0 is fictive as left neigbor
728
// ********* font calculation **************
731
get_b_lines(NULL,&bl);
732
total_pitch=pitchsize;
737
for (c1=NULL,c=(cell_f())->next; c!=NULL; c=c->next)
741
ni1=ni2=ns1=ns2=nu=n=0;
748
if( erection_language(language) )
753
if( memchr(strong_italic,c->vers[0].let,sizeof(strong_italic)) )
755
if( c->vers[0].prob>180 )
757
else if( c->vers[0].prob>70 )
762
if (c->font&c_fp_str)
765
if( memchr(bad_italic,c->vers[0].let,sizeof(bad_italic)) &&
766
!is_russian_baltic_conflict(c->vers[0].let)&&// 17.07.2001 E.P.
767
!is_russian_turkish_conflict(c->vers[0].let) // 21.05.2002 E.P.
773
if (c->font&c_fp_ser)
775
if (c->font&c_fp_gelv)
777
if (c->font&c_fp_undrln)
782
if (c->flg==c_f_space && c->vers[0].let!=0x1e || c->flg==c_f_fict)
784
if (!(c1->flg&c_f_space))
787
for (c2=c1; c2!=c && c2->vers[0].let=='/'; c2=c2->next)
799
CHAR snap[80], sg[30], tmps[30];
801
if( ni1 == 0 && ni2 == 0 )
805
strcpy(tmps, " ITA");
809
sprintf(sg, "%s it = %3d st = %3d", tmps, ni1, ni2);
811
if( snap_activity('i') )
814
sprintf(snap,"Word italic: %s",sg);
815
snap_show_text(snap);
824
if (nu>3 || nu>0 && nu>n-3)
826
if (!(fnt&(c_fp_it+c_fp_str)))
827
fnt|=fntprev&(c_fp_it+c_fp_str); //???
828
if (!(fnt&(c_fp_ser+c_fp_gelv)))
829
fnt|=fntprev&(c_fp_ser+c_fp_gelv);//???
836
for (c2=c1; c2!=c; c2=c2->next)
838
if (c2->flg!=c_f_space)
841
memchr(one_italic,c2->vers[0].let,sizeof(one_italic)) &&
842
!is_russian_baltic_conflict(c2->vers[0].let)&&// 17.07.2001 E.P.
843
!is_russian_turkish_conflict(c2->vers[0].let) // 21.05.2002 E.P.
847
if( memchr(nei_italic,c2->vers[0].let,sizeof(nei_italic)) &&
848
!is_russian_baltic_conflict(c2->vers[0].let)&&// 17.07.2001 E.P.
849
!is_russian_turkish_conflict(c2->vers[0].let) // 21.05.2002 E.P.
861
w_inc[nwi].fnt = fnt & (c_fp_it+c_fp_str);
862
w_inc[nwi].bool = bool;
868
if( nwi < WORDMAX-1 )
871
if( (fnt&c_fp_it) && !(fnt&c_fp_str) )
873
for (c2=c1; c2!=c; c2=c2->next)
875
if( c2->flg!=c_f_space && c2->font&c_fp_str )
879
if( !(fnt&c_fp_it) && (fnt&c_fp_str) )
881
for (c2=c1; c2!=c; c2=c2->next)
883
if( c2->flg!=c_f_space && c2->font&c_fp_it )
888
for (c2=c1; c2!=c; c2=c2->next)
890
if (c2->flg!=c_f_space)
891
c2->font=(c2->font/*&c_fp_undrln*/)|fnt;
895
c2!=c1->prev && !(c2->flg&c_f_let);
900
for ( ; c2!=c1->prev; c2=c2->prev)
902
if (c2->flg!=c_f_space)
905
if (c2->prev == cell_f() || c2->prev == NULL)
915
for (fnt=0,c=(cell_f())->next; c->next!=NULL; c=c->next)
916
if (c->flg!=c_f_space && c->font&(c_fp_it+c_fp_str))
918
fnt=c->font&(c_fp_it+c_fp_str);
925
for (c1=(cell_f())->next; c1!=c; c1=c1->next)
926
if (c1->flg!=c_f_space)
929
for (fnt=0,c=(cell_f())->next; c->next!=NULL; c=c->next)
930
if (c->flg!=c_f_space && c->font&(c_fp_ser+c_fp_gelv))
932
fnt=c->font&(c_fp_ser+c_fp_gelv);
936
for (c1=(cell_f())->next; c1!=c; c1=c1->next)
937
if (c1->flg!=c_f_space)
942
c1->font|=((c1->font&c_fp_it)?c_fp_gelv:c_fp_ser);
946
//use neigbor information for italic :
953
if ( nwi > 0 && nwi < WORDMAX )
966
if( !w_inc[i-1].bool )
971
if( !w_inc[i+1].bool )
977
if( fnt && (fnt^(c_fp_it+c_fp_str)) )
980
w_inc[i].fnt = (BYTE)fnt;
982
CHAR snap[80],sg[30];
992
sprintf(sg,"%s ",sg);
993
if( snap_activity('i') )
995
snap_newcell(w_inc[i].c1);
996
sprintf(snap,"Word italic after neigbor: %s",sg);
997
snap_show_text(snap);
1002
for (c2=w_inc[i].c1; c2!=w_inc[i].c; c2=c2->next)
1004
if (c2->flg!=c_f_space)
1006
c2->font &= (~(c_fp_it+c_fp_str));
1015
// ********* kegel calculation ************
1018
for (c1=NULL,c=(cell_f())->next; c!=NULL; c=c->next)
1028
if (c->flg==c_f_space && c->vers[0].let!=0x1e || c->flg==c_f_fict)
1030
if (!(c1->flg&c_f_space))
1032
get_b_lines(c1,&bl);
1033
keg=keg_word(c1,c,n,&bl)<<line_scale;
1036
for (c2=c1; c2!=c; c2=c2->next)
1037
if (c2->flg!=c_f_space)
1045
for (keg=0,c=(cell_f())->next; c->next!=NULL; c=c->next)
1046
if (c->flg!=c_f_space && c->keg)
1054
get_b_lines(NULL,&bl);
1055
keg=(bl.ps+((fax1x2)?2:0))<<line_scale;
1058
for (c1=(cell_f())->next; c1!=c; c1=c1->next)
1059
if (c1->flg!=c_f_space)
1064
// ********* boldness calculation ***********
1066
for (nw=0,c1=NULL,c=(cell_f())->next; c!=NULL; c=c->next)
1070
trp=(c->vers[0].let=='.' && c->prev->vers[0].let=='.' &&
1071
c->prev->prev!=NULL && c->prev->prev->vers[0].let=='.' &&
1072
c->next->vers[0].let!='.')?1:0;
1073
if (c->flg==c_f_space && c->vers[0].let!=0x1e || c->flg==c_f_fict || trp)
1075
if (!(c1->flg&c_f_space))
1079
bold_word(c1,c,&bld[nw]);
1092
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1094
static void underline()
1097
extern STRLN page_lines[];
1098
extern Int32 num_of_lines;
1100
INT nl=(INT)num_of_lines;
1102
STRLN *lines=page_lines;
1103
INT i,bx,by,ex,ey,x;
1107
get_b_lines(NULL,&bl);
1108
cf=(cell_f())->next; cl=(cell_l())->prev;
1109
for (i=0; i<nl; i++)
1111
if (lines[i].type&FRM_LN || !(lines[i].type&HOR_LN))
1113
bx=lines[i].beg.x>>line_scale;
1114
by=lines[i].beg.y>>line_scale;
1115
ex=lines[i].end.x>>line_scale;
1116
ey=lines[i].end.y>>line_scale;
1117
by-=(INT)((LONG)nIncline*bx/2048);
1118
ey-=(INT)((LONG)nIncline*ex/2048);
1119
if (MIN(by,ey)<bl.b3 || MAX(by,ey)>bl.b3+bl.ps/2 ||
1120
cf->r_col-bl.ps>bx || cl->r_col+cl->w+bl.ps<ex)
1122
for (c=(cell_f())->next; c->next!=NULL; c=c->next)
1124
if ((x=c->r_col+c->w/2)>=bx && x<=ex)
1125
c->font|=c_fp_undrln;
1127
lines[i].type|=UNDRLN;
1134
static CHAR tabpos[256]={
1135
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1136
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1137
// ! " # $ % & ' ( ) * + , - . /
1138
2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,0,0,
1139
// 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @
1140
2,2,2,2,2,2,2,2,2,0,2,2,2,2,2,2,0,2,2,2,2,2,2,2,2,2,
1141
// A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
1144
1,2,1,2,1,0,3,2,0,3,2,2,1,1,1,3,3,1,1,4,1,1,1,1,3,1,
1145
// a b c d e f g h i j k l m n o p q r s t u v w x y z
1146
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1148
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1149
0, 0, 0, 0, 4, 1,0,0, 0, 2,0,0,0};
1150
// fi fl ff ffi rt ri % % ffl i j ! ?
1152
// ������ ���ନ��� � ��������� �ᯮ������� �㪢� �⭮�⥫쭮
1153
// 4-� ������� �����.
1155
// ___________ 2 0,4 -- ??????
1156
// ___________ 1 2 3
1159
static CHAR tabpos[256]={
1160
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 0-23
1161
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, // 24-47
1162
// ! " # $ % & ' ( ) * + , - . /
1163
2,2,2,2,2,2,2,2,2,2,0,0,0,0,0,0,0, // 48-64
1164
// 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @
1165
2,2,2,2,2,2,2,2,2,0,2,2,2,2,2,2,0,2,2,2,2,2,2,2,2,2, //65-90
1166
// A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
1167
0,0,0,0,0,0, //91-96
1169
1,2,1,2,1,0,3,2,0,3,2,2,1,1,1,3,3,1,1,4,1,1,1,1,3,1, // 97-122
1170
// a b c d e f g h i j k l m n o p q r s t u v w x y z
1171
0,0,0,0,0,2,2,2,2,0,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,0,//123-150 ,0,
1172
// { | } ~ � � � � � � � � � � � � � � � � � � � � � � �
1173
2,2,0,2,2,2,2,2,2,1,2,1,1,0,1,1,1,1,0,1,1,1,1,1,1,0,// 151 - 176
1174
// � � � � � � � � � � � � � � � � � � � � � � � � � �
1175
0, 0, 0, 0, 4, 1,0,0, 0, 2,0,0,0, // 177-189
1176
// fi fl ff ffi rt ri % % ffl i j ! ?
1177
// � � � � � � � � � � � � �
1178
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,// 190 - 223
1179
// � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �
1180
3,1,1,3,3,1,0,1,1,0,1,1,1,1,1,1, // 224 - 239
1181
// � � � � � � � � � � � � � � � �
1182
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // 240 - 255
1183
// � � � � � � � � � � � � � � �
1185
static BYTE keg_word(cell *c1,cell *c2,INT n,B_LINES *bl)
1187
INT s[4],m[4],i,ss,bm1,bm2;
1192
if (bl->n2>=3 && bl->n3>=3)
1193
return (BYTE)bl->ps;
1194
if( bl->n1>=3 && bl->n3>=3 && bl->n2<1 && bl->n4<1 )
1195
return (BYTE)bl->ps;
1197
return (BYTE)bl->ps;
1198
for (ss=s[0]=s[1]=s[2]=s[3]=m[0]=m[1]=m[2]=m[3]=bm1=bm2=0,c=c1;
1202
for (i=-1,v=c->vers; v->let; v++)
1204
if (v->prob<BNDPROB)
1207
i=tabpos[let_sans_acc[v->let]];
1209
if (i!=tabpos[let_sans_acc[v->let]])
1215
s[i-1]+=c->h+((fax1x2)?2:0);
1216
if (bl->n1>0 && i==2 && (abs(c->row-bl->b1-c->bdiff)+
1217
abs(c->row+c->h-bl->b3-c->bdiff)>3))
1219
if (bl->n4>0 && i==3 && (abs(c->row-bl->b2-c->bdiff)+
1220
abs(c->row+c->h-bl->b4-c->bdiff)>3))
1224
/* printf("m1=%u,s1=%u,m2=%u,fl=%u,bm1=%u,s2=%u,m3=%u,s3=%u,m4=%u,s4=%u\n",
1225
m[0],s[0],m[1],fg,bm1,s[1],m[2],s[2],m[3],s[3]);*/
1226
if ((bl->n1>0 || !m[1]) && (bl->n4>0 || !m[2]) &&
1227
m[1]+m[2] && m[0]+m[3]<=(m[1]+m[2])/2 &&
1228
bm1<=m[1]/2 && bm2<=m[2]/2)
1229
ss=(bl->n2>0 && bl->n3>0 || !(pitchsize && c1->font&c_fp_ser))?
1230
bl->ps:(6*bl->ps+2)/5;
1233
if (m[0]==n || m[0]>=2)
1234
ss=(s[0]+m[0]/2)/m[0];
1237
if (bl->n1>0 && bl->n2>0 && bl->n3>0 && 3*bl->ps/2+2>=bl->b3-bl->b1)
1239
if (m[0]+m[1]+m[2]==n || m[0]+m[1]+m[2]>=3)
1240
ss=(s[0]+((pitchsize)?(4*(s[1]+s[2]+2)/5):(2*(s[1]+s[2])+1)/3)+
1241
(m[0]+m[1]+m[2])/2)/(m[0]+m[1]+m[2]);
1244
if (m[0]+m[1]+m[2] && m[3])
1245
ss=(s[0]+((pitchsize)?(4*(s[1]+s[2]+s[3]+2)/5):
1246
(2*(s[1]+s[2])+1)/3+(4*s[3]+2)/5)+
1247
(m[0]+m[1]+m[2]+m[3])/2)/(m[0]+m[1]+m[2]+m[3]);
1252
if ((bl->n2<0 || bl->n3<0) && bl->n1>0 && pitchsize)
1253
bl->ps=(6*bl->ps+2)/5;
1254
if (ss && abs(ss-(bl->ps+((fax1x2)?2:0)))<=1)
1255
ss=bl->ps+((fax1x2)?2:0);
1259
#define NOTAPPL -200
1266
static void bold_word(cell *c1,cell *c2,struct word_inf *inf)
1271
for (sd=nd=0,c=c1; c!=c2; c=c->next)
1273
if ( !(c->flg & c_f_let) || c->vers[0].prob<MINPROB)
1275
if ((td=dens_let(c))!=NOTAPPL)
1278
if (nd==1 && c1->vers[0].let=='/')
1281
sd=(sd+((sd>0)?nd/2:-nd/2))/nd;
1291
CHAR snap[80],sg[30];
1295
for(c=c1; c!=c2; c=c->next){
1296
if ( !(c->flg & c_f_let) || c->vers[0].prob<MINPROB)
1298
if( c->font & c_fp_ser )
1300
if( c->font & c_fp_gelv )
1303
if( gel == 0 && ser == 0 )
1306
strcpy(sg," SERIF");
1308
strcpy(sg," GELVE");
1310
sprintf(sg," SG S = %3d G = %3d",ser,gel);
1311
if( snap_activity('i') ){
1313
sprintf(snap,"Word density: dens = %3d ( n = %3d ) %s",sd,nd,sg);
1314
snap_show_text(snap);
1320
static CHAR aver_dens;
1326
//c_comp **curr,**last,*cmp;
1329
//extern PBYTE box_pool,string_curr;
1330
//extern PBYTE comp_file,comp_curr;
1331
//extern WORD comp_lth;
1332
cell *c,*c1=cell_f(),*c2=cell_l();
1334
total_pitch=0; // =0 Nick 04.01.2002 was =-1
1335
for (c=c1,n=s=0; c!=c2; c=c->next)// Piter add init s=0
1337
if ( !(c->flg & (c_f_let|c_f_bad)) )
1339
n+=(c->env->h)*(c->env->w);
1340
for( line=(lnhead *)((PCHAR)(c->env)+c->env->lines+sizeof(INT));
1341
line->lth>0; line=(lnhead *)((PCHAR)line+line->lth))
1343
for (ie=(ic=(interval *)((PBYTE)line+sizeof(lnhead)))+line->h;
1351
for (s=n=0,ln=(str *)box_pool; (PBYTE)ln!=string_curr;
1352
ln=(str *)((PBYTE)ln+ln->lth))
1354
last=(c_comp **)((PBYTE)ln+ln->dust);
1356
for (curr=&(ln->c_comp); curr<last; curr++) //AK 04.03.97 ? for address
1359
if (cmp->size==1 && !((file_comp *)cmp)->h && !((file_comp *)cmp)->w)
1361
l=((LONG)((file_comp *)cmp)->lth)<<4;
1362
if ((comp_curr-comp_file+l)>>4>comp_lth)
1363
error_exit(ERR_comp,2);
1364
read_comp(((file_comp *)cmp)->offset,comp_curr,l);
1365
cmp=(c_comp *)comp_curr;
1367
if (cmp->h>=KEGMAX || cmp->w>=WMAX) continue;
1368
n+=(cmp->h)*(cmp->w);
1369
for (line=(lnhead *)((PBYTE)cmp+cmp->lines+sizeof(INT));
1370
line->lth>0; line=(lnhead *)((PBYTE)line+line->lth))
1371
for (ie=(ic=(interval *)((PBYTE)line+sizeof(lnhead)))+line->h;
1378
{aver_dens=16; return;}
1379
aver_dens=(16*s+n/2)/n+9;
1386
/* printf("s=%ld,n=%ld,dens=%u",s,n,aver_dens); scanf("%c",&l);*/
1394
static CHAR tabss[256]={
1395
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1396
0,0,0,0,0,0,0,0,0,0,0,0,2,-7,1,0,0,0,0,0,0,0,0,-8,
1397
// ! " # $ % & ' ( ) * + , - . /
1398
3,0,1,0,-1,0,2,-4,3,2,0,0,-4,0,-4,-2,2,
1399
// 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @
1400
-3,4,-4,-1,0,0,-3,2,0,-3,-1,-4,0,-2,-1,-1,-2,2,1,-4,-3,-6,-2,-3,-5,0,
1401
// A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
1404
4,-1,0,0,3,0,2,1,0,-1,-1,0,3,4,3,-1,-1,1,3,0,4,-2,0,2,-2,2,
1405
// a b c d e f g h i j k l m n o p q r s t u v w x y z
1406
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1408
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1409
3, 3, 1, 3, 3, 4,0,0, 3, 0,0,0,-2};
1410
// fi fl ff ffi rt ri % % ffl i j ! ?
1412
static CHAR tabgs[256]={
1413
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1414
0,0,0,0,0,0,0,0,0,0,0,0,1,-7,-1,0,0,0,0,0,0,0,0,-11,
1415
// ! " # $ % & ' ( ) * + , - . /
1416
0,0,-1,-2,-2,-1,1,-6,3,1,0,0,-4,0,-4,-2,2,
1417
// 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @
1418
-2,3,-4,0,1,-2,-1,1,0,-4,-1,-5,2,2,-3,0,-2,0,-1,-6,-3,-4,-2,-3,-6,-2,
1419
// A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
1422
3,0,-1,0,2,-1,3,0,0,0,-1,0,1,3,1,1,0,0,2,0,1,-2,1,0,-3,2,
1423
// a b c d e f g h i j k l m n o p q r s t u v w x y z
1424
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1426
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1427
3, 3, 1, 3, -2, 0,0,0, 3, 0,0,0,-2};
1428
// fi fl ff ffi rt ri % % ffl i j ! ?
1430
static CHAR tabgi[256]={
1431
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1432
0,0,0,0,0,0,0,0,0,0,0,0,1,-7,-1,0,0,0,0,0,0,0,0,-9,
1433
// ! " # $ % & ' ( ) * + , - . /
1434
1,4,-2,-2,-2,0,1,-5,3,0,0,0,-4,0,-4,-2,2,
1435
// 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @
1436
-1,3,-6,0,0,-3,-1,0,0,-5,-1,-5,-1,-1,-2,-1,-2,1,0,-4,-5,-2,-4,-3,-5,-2,
1437
// A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
1440
3,-2,-2,-2,3,-5,0,-2,0,0,-2,0,1,2,2,-1,-3,-2,2,0,2,-3,2,-1,-4,0,
1441
// a b c d e f g h i j k l m n o p q r s t u v w x y z
1442
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1444
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1445
2, 3, 0, 2, 2, 3,0,0, 2, 0,0,0,-2};
1446
// fi fl ff ffi rt ri % % ffl i j ! ?
1448
static CHAR tabcr[256]={
1449
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1450
0,0,0,0,0,0,0,0,0,0,0,0,1,-7,-1,0,0,0,0,0,0,0,0,-8,
1451
// ! " # $ % & ' ( ) * + , - . /
1452
0,0,-1,-1,0,-1,2,-3,3,2,0,0,-4,0,-4,-2,2,
1453
// 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @
1454
1,3,-3,1,2,-2,-2,1,0,-3,-1,-3,2,1,-1,-1,-1,0,0,-1,-3,-3,-1,-1,-3,-2,
1455
// A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
1458
5,1,1,1,6,1,2,0,0,0,-2,0,5,2,2,2,1,0,6,0,0,-1,3,3,-2,2,
1459
// a b c d e f g h i j k l m n o p q r s t u v w x y z
1460
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1462
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1463
3, 3, 1, 3, 3, 4,0,0, 3, 0,0,0,-2};
1464
// fi fl ff ffi rt ri % % ffl i j ! ?
1466
static CHAR tabmd[256]={
1467
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1468
0,0,0,0,0,0,0,0,0,0,0,0,2,-7,-1,0,0,0,0,0,0,0,0,-8,
1469
// ! " # $ % & ' ( ) * + , - . /
1470
2,0,-1,-2,0,-1,1,-3,3,2,0,0,-4,0,-4,-2,2,
1471
// 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @
1472
2,6,-3,3,2,-1,1,3,0,-3,-1,-3,5,7,3,-2,-1,3,-1,-4,0,0,7,-1,-3,-2,
1473
// A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
1476
5,1,0,3,5,-2,3,1,0,0,0,0,8,3,3,2,1,-2,1,0,3,0,6,0,-2,1,
1477
// a b c d e f g h i j k l m n o p q r s t u v w x y z
1478
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1480
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1481
3, 3, 1, 3, 3, 4,0,0, 3, 0,0,0,-2};
1482
// fi fl ff ffi rt ri % % ffl i j ! ?
1485
// ������� ������������� ��������� ����� � ����������� ��
1486
// ������ ����� �������.
1488
// ���� ����� ����� ��� '������'.
1489
static CHAR tabgi[256]={
1490
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1491
0,0,0,0,0,0,0,0,0,0,0,0,1,-7,-1,0,0,0,0,0,0,0,0,-9,
1492
// ! " # $ % & ' ( ) * + , - . /
1493
1,4,-2,-2,-2,0,1,-5,3,0,0,0,-4,0,-4,-2,2,
1494
// 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @
1495
-1,3,-6,0,0,-3,-1,0,0,-5,-1,-5,-1,-1,-2,-1,-2,1,0,-4,-5,-2,-4,-3,-5,-2,
1496
// A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
1499
3,-2,-2,-2,3,-5,0,-2,0,0,-2,0,1,2,2,-1,-3,-2,2,0,2,-3,2,-1,-4,0,
1500
// a b c d e f g h i j k l m n o p q r s t u v w x y z
1501
0,0,0,0,0,-1,2,3,-4,-1,-2,-1,-2,-1,-1,-1,-2, 0,-2,-1,-1,-1,-3,-2,-3, 1,-2,-3,//123-150 ,0,
1502
// { | } ~ � � � � � � � � � � � � � � � � � � � � � � �
1503
-1,-1,-2, 3, 1, 0,-2, 0,2,3,-1, 6,-2,2,3,2,1,2,2,1,1,2,2,2,2,0,// 151 - 176
1504
// � � � � � � � � � � � � � � � � � � � � � � � � � �
1505
2, 3, 0, 2, 2, 3,0,0, 2, 0,0,0,-2,
1506
// fi fl ff ffi rt ri % % ffl i j ! ?
1507
// � � � � � � � � � � � � �
1508
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,// 190 - 223
1509
// � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �
1510
-1,-2,-2,-2,-2, 1,1,1,3,1, 5,4,4,0,4,4, // 224 - 239
1511
// � � � � � � � � � � � � � � � �
1512
0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0}; // 240 - 255
1513
// � � � � � � � � � � � � � � �
1517
// ����� ���� ���ᨢ� � ���� �� ������.
1518
// ��ਭ� �㪢� ����।�����. ���� ����.
1519
static CHAR tabss[256]={
1520
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1521
0,0,0,0,0,0,0,0,0,0,0,0,2,-7,1,0,0,0,0,0,0,0,0,-8,
1522
// ! " # $ % & ' ( ) * + , - . /
1523
3,0,1,0,-1,0,2,-4,3,2,0,0,-4,0,-4,-2,2,
1524
// 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @
1525
-3,4,-4,-1,0,0,-3,2,0,-3,-1,-4,0,-2,-1,-1,-2,2,1,-4,-3,-6,-2,-3,-5,0,
1526
// A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
1529
4,-1,0,0,3,0,2,1,0,-1,-1,0,3,4,3,-1,-1,1,3,0,4,-2,0,2,-2,2,
1530
// a b c d e f g h i j k l m n o p q r s t u v w x y z
1531
0,0,0,0,0,-3,2,4,-2,-3,3,-2,0, 0, 0,-1,-4,0,0,-2,0, 0,-3,-3,-4, 0,-2,-3,//123-150 ,0,
1532
// { | } ~ � � � � � � � � � � � � � � � � � � � � � � �
1533
-2, 0,-2,-1, 0, 1, 0,-1,1,3,2,6,1,0,4,2,2,4,4, 3,-2,3,3,1,4,0,// 151 - 176
1534
// � � � � � � � � � � � � � � � � � � � � � � � � � �
1535
3, 3, 1, 3, 3, 4,0,0, 3, 0,0,0,-2,
1536
// fi fl ff ffi rt ri % % ffl i j ! ?
1537
// � � � � � � � � � � � � �
1538
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,// 190 - 223
1539
// � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �
1540
1,1,0,-4,-1,3,0,1,2,0, 0,4, 2,2,2,4, // 224 - 239
1541
// � � � � � � � � � � � � � � � �
1542
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // 240 - 255
1543
// � � � � � � � � � � � � � � �
1546
// ��ਭ� �㪢� ����।�����. ���� �� ����.
1547
static CHAR tabgs[256]={
1548
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1549
0,0,0,0,0,0,0,0,0,0,0,0,1,-7,-1,0,0,0,0,0,0,0,0,-11,
1550
// ! " # $ % & ' ( ) * + , - . /
1551
0,0,-1,-2,-2,-1,1,-6,3,1,0,0,-4,0,-4,-2,2,
1552
// 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @
1553
-2,3,-4,0,1,-2,-1,1,0,-4,-1,-5,2,2,-3,0,-2,0,-1,-6,-3,-4,-2,-3,-6,-2,
1554
// A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
1557
3,0,-1,0,2,-1,3,0,0,0,-1,0,1,3,1,1,0,0,2,0,1,-2,1,0,-3,2,
1558
// a b c d e f g h i j k l m n o p q r s t u v w x y z
1559
0,0,0,0,0,-2,2,4,-4,-2,0,-1,-1,2,2,-1,-2,2,0,-2,1,-1,-3,-5,-3,-1,-2,-3,//123-150 ,0,
1560
// { | } ~ � � � � � � � � � � � � � � � � � � � � � � �
1561
-3, 0,-3,-2, 1,0,-1,0,1,4,2,8,-1,1,4,3,3,6,4, 4, 1,5,4,2,4,0,// 151 - 176
1562
// � � � � � � � � � � � � � � � � � � � � � � � � � �
1563
3, 3, 1, 3, -2, 0,0,0, 3, 0,0,0,-2,
1564
// fi fl ff ffi rt ri % % ffl i j ! ?
1565
// � � � � � � � � � � � � �
1566
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,// 190 - 223
1567
// � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �
1568
1, 1,-4,-3,-1,2,-0,1,3,-1,-0,5,3,2,3,4, // 224 - 239
1569
// � � � � � � � � � � � � � � � �
1570
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // 240 - 255
1571
// � � � � � � � � � � � � � � �
1575
// . ��ਭ� �㪢� ����� 祬 ࠧ��� �����.
1576
static CHAR tabcr[256]={
1577
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1578
0,0,0,0,0,0,0,0,0,0,0,0,1,-7,-1,0,0,0,0,0,0,0,0,-8,
1579
// ! " # $ % & ' ( ) * + , - . /
1580
0,0,-1,-1,0,-1,2,-3,3,2,0,0,-4,0,-4,-2,2,
1581
// 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @
1582
1,3,-3,1,2,-2,-2,1,0,-3,-1,-3,2,1,-1,-1,-1,0,0,-1,-3,-3,-1,-1,-3,-2,
1583
// A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
1586
5,1,1,1,6,1,2,0,0,0,-2,0,5,2,2,2,1,0,6,0,0,-1,3,3,-2,2,
1587
// a b c d e f g h i j k l m n o p q r s t u v w x y z
1588
0,0,0,0,0,1,2,3,-3,-2,2,-2,-1,1,1,-1,-2,2,1,-1,1,-1,-3,-1,-3,-2,-1,-3,//123-150 ,0,
1589
// { | } ~ � � � � � � � � � � � � � � � � � � � � � � �
1590
-2, 0,-2,0, 0,-1,-1,0,0,5,4,7,0,4,4,4,4,5,6, 5, 0,5,4,1,6,0,// 151 - 176
1591
// � � � � � � � � � � � � � � � � � � � � � � � � � �
1592
3, 3, 1, 3, 3, 4,0,0, 3, 0,0,0,-2,
1593
// fi fl ff ffi rt ri % % ffl i j ! ?
1594
// � � � � � � � � � � � � �
1595
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,// 190 - 223
1596
// � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �
1597
3,-1,-3,-2,1,5,2,3,4,2,2,6,4,4,4,6, // 224 - 239
1598
// � � � � � � � � � � � � � � � �
1599
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // 240 - 255
1600
// � � � � � � � � � � � � � � �
1603
// . ��ਭ� �㪢� ����� ��� ࠢ�� ࠧ���� �����.
1604
static CHAR tabmd[256]={
1605
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1606
0,0,0,0,0,0,0,0,0,0,0,0,2,-7,-1,0,0,0,0,0,0,0,0,-8,
1607
// ! " # $ % & ' ( ) * + , - . /
1608
2,0,-1,-2,0,-1,1,-3,3,2,0,0,-4,0,-4,-2,2,
1609
// 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @
1610
2,6,-3,3,2,-1,1,3,0,-3,-1,-3,5,7,3,-2,-1,3,-1,-4,0,0,7,-1,-3,-2,
1611
// A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
1614
5,1,0,3,5,-2,3,1,0,0,0,0,8,3,3,2,1,-2,1,0,3,0,6,0,-2,1,
1615
// a b c d e f g h i j k l m n o p q r s t u v w x y z
1616
0,0,0,0,0,2,4,6,-3,0,2,0,-2,7,7,-1,-2,5,3,3,3,-2,-3,-4,-3,-1,-1,0,//123-150 ,0,
1617
// { | } ~ � � � � � � � � � � � � � � � � � � � � � � �
1618
0,2,0,1,4, 4, 2,3,3,5,3,8,-2,1,4,2,2,5,5,3,2,6,3,1,3,0,// 151 - 176
1619
// � � � � � � � � � � � � � � � � � � � � � � � � � �
1620
3, 3, 1, 3, 3, 4,0,0, 3, 0,0,0,-2,
1621
// fi fl ff ffi rt ri % % ffl i j ! ?
1622
// � � � � � � � � � � � � �
1623
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,// 190 - 223
1624
// � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �
1625
1,0,-4,-2,-2,1,-1,0,2,-2,-1,4,2,2,2,0, // 224 - 239
1626
// � � � � � � � � � � � � � � � �
1627
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // 240 - 255
1628
// � � � � � � � � � � � � � � �
1630
static INT dens_let(cell *c)
1635
if (c->dens>100) // 11-10-94 05:59pm Pit for debug
1637
if (c->dens==NODENS)
1639
let=let_sans_acc[c->vers[0].let];
1641
if (strchr("*#!ijltI1()[]{}",let)!=NULL ||
1644
language == LANG_TURKISH && // 30.05.2002 E.P.
1645
(let==i_sans_accent||let==II_dot_accent) ||
1646
let==liga_j || let==liga_exm ||
1647
let=='r' && 5*c->w<3*c->h)
1653
if ( language != LANG_RUSSIAN && pitchsize )
1655
if (pitchsize>c->keg)
1668
d=aver_dens+tab[let];
1669
if (let=='f' && fnt&c_fp_it && c->cpos&ce_p_Ql)
1671
if (let=='f' && tab==tabgs)
1678
if (let=='r' && 17*c->w<=11*c->h)
1680
d+=(d<<line_scale)/5;
1681
if (c->keg<<line_scale>STDKEG)
1683
if (c->h<=3*c->keg/2+2)
1684
h=c->keg>>line_scale;
1687
d-=(d*((h<<line_scale)-STDKEG)+MKEGDENS/2)/MKEGDENS;
1689
if (c->keg<=16) d++;
1690
if (c->keg<=12) d++;
1694
// ���� �।����䬥���� � ���⭮�� ᨬ�����
1697
if(tab==tabgi) stat_tab = stat_tabgi;
1698
if(tab==tabss) stat_tab = stat_tabss;
1699
if(tab==tabgs) stat_tab = stat_tabgs;
1700
if(tab==tabcr) stat_tab = stat_tabcr;
1701
if(tab==tabmd) stat_tab = stat_tabmd;
1703
stat_tab[let].mid = (stat_tab[let].mid * stat_tab[let].n + c->dens) /
1704
(stat_tab[let].n + 1);
1705
stat_tab[let].real = ((int)stat_tab[let].real * stat_tab[let].n + (int)c->dens - (int)d) /
1706
(stat_tab[let].n + 1);
1707
if(stat_tab[let].min > c->dens
1708
|| !stat_tab[let].min) stat_tab[let].min = c->dens;
1709
if(stat_tab[let].max < c->dens) stat_tab[let].max = c->dens;
1715
return (c->dens-tab[let]);
1717
return MDENS*(c->dens-d);
1721
void font_narrow(void)
1724
BYTE slanguage=language;
1725
INT prop, nall, nval, narrow, pn;
1727
if( line_tabcell || !line_scale )
1729
for(nval=nall=narrow=0,c=cell_f()->nextl;c!=cell_l();c=c->nextl)
1731
if( c->nvers==0 || !(c->flg&c_f_let) )
1733
language = c->language;
1735
prop = prop_index(c->h, c->w);
1736
pn = prop_narrow[ (INT)c->vers[0].let ];
1739
if( (c->font & c_fp_narrow) )
1741
else if( pn && pn> prop )
1744
if( narrow*10 > nall*6 || narrow*10 > nval*6 && nval*2>=nall)
1746
for(nall=narrow=0,c=cell_f()->nextl;c!=cell_l();c=c->nextl)
1748
c->font |= c_fp_narrow;