~ubuntu-branches/debian/experimental/cuneiform/experimental

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-07-10 17:58:10 UTC
  • Revision ID: james.westby@ubuntu.com-20090710175810-rqc89d2i3tki9m89
Tags: upstream-0.7.0+dfsg
Import upstream version 0.7.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
Copyright (c) 1993-2008, Cognitive Technologies
 
3
All rights reserved.
 
4
 
 
5
����������� ��������� ��������������� � ������������� ��� � ���� ��������� ����,
 
6
��� � � �������� �����, � ����������� ��� ���, ��� ���������� ��������� �������:
 
7
 
 
8
      * ��� ��������� ��������������� ��������� ���� ������ ���������� ���������
 
9
        ���� ����������� �� ��������� �����, ���� ������ ������� � �����������
 
10
        ����� �� ��������.
 
11
      * ��� ��������� ��������������� ��������� ���� � ������������ �/��� �
 
12
        ������ ����������, ������������ ��� ���������������, ������ �����������
 
13
        ��������� ���� ���������� �� ��������� �����, ���� ������ ������� �
 
14
        ����������� ����� �� ��������.
 
15
      * �� �������� Cognitive Technologies, �� ����� �� ����������� �� �����
 
16
        ���� ������������ � �������� �������� ��������� �/��� �����������
 
17
        ���������, ���������� �� ���� ��, ��� ���������������� �����������
 
18
        ����������.
 
19
 
 
20
��� ��������� ������������� ����������� ��������� ���� �/��� ������� ������ "���
 
21
��� ����" ��� ������-���� ���� ��������, ���������� ���� ��� ���������������,
 
22
������� �������� ������������ �������� � ����������� ��� ���������� ����, �� ��
 
23
������������� ���. �� �������� ��������� ���� � �� ���� ������ ����, �������
 
24
����� �������� �/��� �������� �������������� ���������, �� � ���� ������ ��
 
25
��Ѩ� ���������������, ������� ����� �����, ���������, ����������� ���
 
26
������������� ������, ��������� � �������������� ��� ���������� ����������
 
27
������������� ������������� ��������� (������� ������ ������, ��� ������,
 
28
������� ���������, ��� ������ �/��� ������ �������, ���������� ��-�� ��������
 
29
������� ��� �/��� ������ ��������� �������� ��������� � ������� �����������,
 
30
�� �� ������������� ����� ��������), �� �� ������������� ���, ���� ���� �����
 
31
�������� ��� ������ ���� ���� �������� � ����������� ����� ������� � ������.
 
32
 
 
33
Redistribution and use in source and binary forms, with or without modification,
 
34
are permitted provided that the following conditions are met:
 
35
 
 
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.
 
44
 
 
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.
 
55
*/
 
56
 
 
57
#define ANDREW_BI
 
58
 
 
59
#include <stdlib.h>
 
60
#include <string.h>
 
61
#include <stdio.h>
 
62
#include "nt_types.h"
 
63
#include "struct.h"
 
64
#include "func.h"
 
65
#include "ligas.h"
 
66
#include "msgerr.h"
 
67
#include "lang.h"
 
68
#include "linutil.h"
 
69
#include "prop_nar.h"
 
70
 
 
71
#include "compat_defs.h"
 
72
 
 
73
extern BOOL line_readyBL;
 
74
extern BYTE p2_active;
 
75
extern INT  nIncline;
 
76
extern INT  page_nIncline;
 
77
extern BYTE line_scale;
 
78
extern WORD actual_resolution;
 
79
extern BYTE fax1x2;
 
80
 
 
81
#define WORDMAX  100
 
82
struct word_inf {cell *c; INT dens,n;} bld[WORDMAX];
 
83
INT nw;
 
84
 
 
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 *);
 
93
static INT pitch();
 
94
 
 
95
// RCM.C
 
96
extern BYTE line_tabcell;
 
97
extern BOOL pass4_in;
 
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[]="��";  // "��"
 
101
 
 
102
#define STAT_PIT
 
103
#ifdef  STAT_PIT
 
104
struct B { INT mid; // �ࠪ���⨪�
 
105
           INT real;
 
106
           INT max,min;
 
107
           WORD n; // �᫮ ᨬ�����
 
108
           };
 
109
typedef struct B STAT;
 
110
 
 
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];
 
116
STAT *  stat_tab;
 
117
 
 
118
void print_stat(FILE * f,STAT * stat)
 
119
{
 
120
register i,j,k;
 
121
 
 
122
 for(i=1;i<16;i++){
 
123
   for(j=0;j<16;j++){
 
124
   // ������ ⮫쪮 �� ����� ��ப�
 
125
       BYTE * byte = (BYTE *)(stat+i*16+j);
 
126
       for(k=0;k<sizeof(STAT);k++)
 
127
            if(byte[k])
 
128
                {
 
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);
 
135
                break;
 
136
                }
 
137
  }
 
138
 }
 
139
 memset(stat,0,sizeof(STAT)*256);// ���ᨢ ����� ���� �ᯮ�짮��� �������
 
140
}
 
141
#endif
 
142
 
 
143
void font_let()
 
144
 {
 
145
 cell *c;
 
146
 
 
147
 for (c=(cell_f())->next; c->next!=NULL; c=c->next)
 
148
  if (c->flg&c_f_let && tsimple(c))
 
149
   {
 
150
   italic(c);
 
151
   serif(c);
 
152
   }
 
153
 
 
154
 snap_newpass('i');
 
155
 
 
156
 if( snap_activity('i') ){
 
157
    snap_newcell((cell_f())->next);
 
158
    snap_show_text("FOR ITALIC DEBUG");
 
159
    snap_monitor();
 
160
 }
 
161
 
 
162
 }
 
163
 
 
164
static BYTE twinsl[]={"cCpPsSvVwVxXzZ0O1l"};
 
165
static BYTE twinsr[]={"�������������������������������������������"};
 
166
//                                    "����������������������������������������������������������
 
167
 
 
168
#define NVAR         256 // Valdemar & Oleg
 
169
#define NLET         256
 
170
#define f_italic     4
 
171
#define f_italic_add 6
 
172
#define f_italic_lst 20
 
173
#define PROBMIN      30000
 
174
#define DPROB        500
 
175
 
 
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)
 
180
 {
 
181
 s_glue GL;
 
182
 servBOX *s;
 
183
 indBOX *h;
 
184
 elmBOX *elm;
 
185
 BYTE let;
 
186
 PBYTE          twins;
 
187
 CHAR font[2*NVAR];
 
188
 WORD i,prob[2*NVAR];
 
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;
 
193
 
 
194
if( c->pos_inc==erect_no )
 
195
    disable_it=TRUE;
 
196
 
 
197
 sv_pos_inc        = c->pos_inc        ;
 
198
 sv_stick_inc      = c->stick_inc      ;
 
199
 sv_save_stick_inc = c->save_stick_inc ;
 
200
 
 
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)&&
 
209
      !bad_cur_ge )
 
210
    {
 
211
     c->font      |= c_fp_it;
 
212
     c->stick_inc |= 0x4000;
 
213
     goto  ret;
 
214
    }
 
215
 if( c->save_stick_inc == NO_INCLINE )
 
216
   calcErection(c);
 
217
 
 
218
 if( c->save_stick_inc != NO_INCLINE &&
 
219
     !memchr("$&#257/",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 */)
 
222
    {
 
223
    if( !disable_it )
 
224
        {
 
225
        c->font      |= c_fp_it;
 
226
        c->stick_inc |= 0x2000;
 
227
        goto ret;
 
228
        }
 
229
    else
 
230
        {
 
231
        c->font_new  |= c_fp_it;
 
232
        goto ret;
 
233
        }
 
234
    }
 
235
 }
 
236
 
 
237
 GL.celist[0]=c;
 
238
 GL.celist[1]=NULL;
 
239
 GL.complist[0]=c->env;
 
240
 GL.complist[1]=NULL;
 
241
 GL.ncell=0;
 
242
 if ((s=make_broken_raster(&GL,1))!=NULL)
 
243
  {
 
244
  let=let_sans_acc[c->vers[0].let];
 
245
  c->dens=s->dens;
 
246
 
 
247
  if (letincl(c) ||
 
248
//        let>=ligas_beg && let<=ligas_end ||
 
249
          is_liga(let) ||  // 14.09.2000 E.P.
 
250
      memchr("$&#257/",let,7) ||
 
251
      language==LANG_RUSSIAN && let==r_cu_z )
 
252
  if( !memchr("��",let,2) )
 
253
   {
 
254
      c->stick_inc |= 0x1000;
 
255
      goto ret;
 
256
   }
 
257
  else
 
258
      c->font^=c_fp_it;
 
259
 
 
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)
 
263
         )
 
264
   let='l';
 
265
  h=(indBOX *)tableBOX+let;
 
266
  for (nansw=0,i=h->numel; !nansw || i; i=elm->list)
 
267
   {
 
268
   elm=(elmBOX *)(tableBOX+NLET*sizeof(indBOX))+i;
 
269
   if( elm->bnd & 0x0100 )
 
270
     continue;
 
271
   if( !(c->pos_inc&erect_rot) && (elm->bnd & 0x0200) )
 
272
     continue;
 
273
   font[nansw]=elm->fnt;
 
274
   prob[nansw]=(*scalarf)(elm->vect,s->matrBOX.vect,s->matrBOX.isq_rt);
 
275
   nansw++;
 
276
   }
 
277
   if(language==LANG_RUSSIAN) twins=twinsr;
 
278
        else    twins=twinsl;
 
279
  for (l=strlen(twins),i=0; i<l; i++)
 
280
   if (let==twins[i])
 
281
    {let=twins[i^1]; break;}
 
282
  if (i<l)
 
283
   {
 
284
   h=(indBOX *)tableBOX+let;
 
285
   for (i=h->numel; !nansw || i; i=elm->list)
 
286
    {
 
287
    elm=(elmBOX *)(tableBOX+NLET*sizeof(indBOX))+i;
 
288
    if( ( elm->bnd & 0x0100 ) == 1 )
 
289
      continue;
 
290
    if( !(c->pos_inc&erect_rot) && (elm->bnd & 0x0200) )
 
291
      continue;
 
292
    font[nansw]=elm->fnt;
 
293
    prob[nansw]=(*scalarf)(elm->vect,s->matrBOX.vect,s->matrBOX.isq_rt);
 
294
    nansw++;
 
295
    }
 
296
   }
 
297
  for (maxi=maxni=i=0; i<nansw; i++)
 
298
    {
 
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)
 
301
      )
 
302
        {
 
303
        if (maxi<prob[i])
 
304
            maxi=prob[i];
 
305
        }
 
306
    else
 
307
        if (maxni<prob[i])
 
308
            maxni=prob[i];
 
309
    }
 
310
  if( !erection_language(language) )
 
311
      {
 
312
      if (maxi>PROBMIN && maxi-maxni>DPROB)
 
313
       c->font|=c_fp_it;
 
314
      if (maxni>PROBMIN && maxni-maxi>DPROB)
 
315
       c->font|=c_fp_str;
 
316
      }
 
317
  else if( !(p2_active              &&
 
318
             sv_save_stick_inc>240  &&
 
319
             sv_save_stick_inc!=NO_INCLINE
 
320
             ) )
 
321
       {
 
322
       //if( !c->nvers|| !strchr(non_inclinable_letters,c->vers[0].let) )
 
323
       c->font|=c_fp_str;
 
324
       }
 
325
  }
 
326
 
 
327
ret:
 
328
c->pos_inc        = (BYTE)sv_pos_inc        ;
 
329
c->stick_inc      = sv_stick_inc      ;
 
330
c->save_stick_inc = sv_save_stick_inc ;
 
331
return;
 
332
}
 
333
 
 
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
 
345
//      [ \ ] ^ _ `
 
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
//      � � � � � � � � � � � � � � �
 
361
#define KEGMAX    63
 
362
#define KEGMIN    12
 
363
#define WMAX     128
 
364
#define RINCL      1
 
365
#define LINCL      2
 
366
#define BNDINCL  200
 
367
#define BNDNINCL 150
 
368
 
 
369
INT letincl(cell *c)
 
370
 {
 
371
 BYTE f,let;
 
372
 INT i,mini,maxi,h,nr,nl;
 
373
 INT left[KEGMAX],right[KEGMAX];
 
374
 lnhead *line;
 
375
 interval *intv0,*intv,*intve;
 
376
 LONG s;
 
377
 
 
378
 let=let_sans_acc[c->vers[0].let];
 
379
 //if( language==LANG_RUSSIAN || language==LANG_ENGLISH )
 
380
 if( erection_cyr_language(language) )
 
381
    return 0;
 
382
 if (c->env==NULL || (f=tabincl[let])==0 || c->h<KEGMIN)
 
383
  return 0;
 
384
 mini=c->h/4; maxi=3*mini;
 
385
 if (let=='t')
 
386
  maxi=c->h-1;
 
387
 h=maxi-mini+1;
 
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)
 
394
   {
 
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++)
 
401
    {
 
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;
 
404
    }
 
405
   }
 
406
 s=i=0;
 
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++;}
 
411
/* scanf("%c",&i);*/
 
412
 if (!i) return 0;
 
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;}
 
417
 return 0;
 
418
 }
 
419
 
 
420
static INT linerev(INT n,INT *line)
 
421
 {
 
422
 INT i,beg,end;
 
423
 
 
424
 if (n<KEGMIN/2)
 
425
  return n;
 
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");*/
 
432
 return end-beg+1;
 
433
 }
 
434
 
 
435
static LONG inclin(INT n,INT *line)
 
436
 {
 
437
 INT x;
 
438
 LONG sy,sxy,inc;
 
439
 
 
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);*/
 
444
 return inc;
 
445
 }
 
446
 
 
447
#define LSER      1
 
448
#define HSER      2
 
449
 
 
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
 
460
        0,0,0,0,0,0,                                            //91-96
 
461
//      [ \ ] ^ _ `
 
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
//      � � � � � � � � � � � � � � �
 
477
 
 
478
 
 
479
static void serif(cell *c)
 
480
 {
 
481
 BYTE let;
 
482
 lnhead *line;
 
483
 interval *i1,*i2;
 
484
 INT H,n1,n2,h,b1,b2,e1,e2;
 
485
 
 
486
 H=c->h;
 
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))
 
490
  {
 
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)))
 
493
   {
 
494
   i1=(interval *)((PCHAR)line+sizeof(lnhead))+(h-3);
 
495
   i2=i1-(H/4-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);
 
498
   b2=(e2=i2->e)-i2->l;
 
499
   if (e1>e2 && b1<b2) n1++;
 
500
   if (abs(e1-b1-e2+b2)<=1 && abs(e1-e2)<=1 && abs(b1-b2)<=1) n2++;
 
501
   }
 
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'))
 
504
   {
 
505
   i1=(interval *)((PCHAR)line+sizeof(lnhead));
 
506
   i2=i1+(H/4-1);
 
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);
 
509
   b2=(e2=i2->e)-i2->l;
 
510
   if (e1>e2 && b1<b2) n1++;
 
511
   if (abs(e1-b1-e2+b2)<=1 && abs(e1-e2)<=1 && abs(b1-b2)<=1) n2++;
 
512
   }
 
513
  }
 
514
 if (n1>n2) c->font|=c_fp_ser;
 
515
 if (n1<n2) c->font|=c_fp_gelv;
 
516
 }
 
517
 
 
518
INT pitchsize=0;
 
519
INT averwid;
 
520
 
 
521
#define LSTRMAX 300
 
522
#define LSTRMIN 5
 
523
#define LSTRMINF 3
 
524
#define BNDOK    70
 
525
#define BND0    100
 
526
#define BND1    120
 
527
#define BND2    210
 
528
#define NLETOK  22
 
529
#define NCUTMAX  5
 
530
#define NTHLMAX  3
 
531
#define DELTMAX  4
 
532
 
 
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
 
536
 
 
537
void checkpitch()
 
538
 {
 
539
 extern INT line_number;
 
540
 extern BOOL pass4_in;
 
541
 B_LINES bl;
 
542
 
 
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
 
547
 
 
548
 pitchsize=pitch();
 
549
 }
 
550
 
 
551
static INT pitch()
 
552
 {
 
553
 cell *c;
 
554
 BYTE let;
 
555
 INT nl,nc,ng,n,n1,n2,h,w,ww,wmin,wmax,i,j,sp,bad,d,p,mg;
 
556
 LONG s,min;
 
557
 WORD center[LSTRMAX],left[LSTRMAX],right[LSTRMAX];
 
558
 
 
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))
 
561
   {
 
562
   nl++;
 
563
   if (!(c->cg_flag&(c_cg_cutr|c_cg_cutl)))
 
564
    nc++;
 
565
   let=c->vers[0].let;
 
566
   if (
 
567
//         (let=c->vers[0].let)>=ligas_beg && let<=ligas_end &&
 
568
          is_liga(let) &&  // 14.09.2000 E.P.
 
569
 
 
570
       let!=liga_i &&
 
571
                !(language == LANG_TURKISH &&  // 30.05.2002 E.P.
 
572
                        (let==i_sans_accent||let==II_dot_accent)
 
573
                 ) &&
 
574
           let!=liga_j && let!=liga_exm && let!=liga_qm
 
575
           )
 
576
    ng++;
 
577
   }
 
578
 mg=(3*nc<2*nl)?1:0;
 
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)!='[' &&
 
581
 
 
582
//      (let<ligas_beg || let>ligas_end ||
 
583
          (!is_liga(let) ||  // 14.09.2000 E.P.
 
584
 
 
585
       let==liga_i ||
 
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))))
 
591
   {
 
592
   left[n]=c->col;
 
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)
 
597
    center[n]+=c->w/3;
 
598
   if ((let=='i' && 5*c->w>2*c->h ||
 
599
                (let==liga_i ||
 
600
                 language == LANG_TURKISH &&  // 30.05.2002 E.P.
 
601
                        (let==i_sans_accent||let==II_dot_accent)
 
602
                )&& 4*c->w>c->h) &&
 
603
       !(c->font&c_fp_it) && c->font&c_fp_gelv)
 
604
    center[n]+=c->w/5;
 
605
   if (let=='f' && !(c->font&c_fp_it) && c->font&c_fp_gelv && 2*c->w>c->h)
 
606
    center[n]-=c->w/5;
 
607
   n++;
 
608
   }
 
609
 if (n==1)
 
610
  return 0;
 
611
 h=get_size()+((fax1x2)?2:0);
 
612
 for (averwid=nl=0,min=10000,i=1; i<n; i++)
 
613
  {
 
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];
 
618
  }
 
619
 if (nl>LSTRMIN || nl && 2*averwid<5*nl*h)
 
620
  averwid/=nl;
 
621
 else
 
622
  averwid=h;
 
623
 if (averwid<h/2)
 
624
  return 0;
 
625
 
 
626
 if( averwid <= 1 )  // Nick 01.04.2002 - �������� ������� �� 0
 
627
         return 0;
 
628
 
 
629
 wmin=2*averwid/3;
 
630
 wmax=3*averwid/2;
 
631
 if (wmax<min+1)
 
632
  wmax=min+1;
 
633
 for (p=j=bad=nl=0,min=1000000,w=wmin; w<=wmax; w++)
 
634
  {
 
635
  ww=3*w/4;
 
636
  for (sp=1,n2=n1=0,s=0,i=1; i<n; i++)
 
637
   if (left[i]-right[i-1]<ww)
 
638
    {
 
639
    d=center[i]-center[i-1]-w;
 
640
    if (d>-DELTMAX && 5*d<=2*w)
 
641
     {
 
642
     if (!fax1x2 || abs(d)>1)
 
643
      s+=d*d;
 
644
     n1++;
 
645
     if (!sp && bad)
 
646
      {
 
647
      d=(center[i-1]-center[j])%w;
 
648
      d=MIN(d,w-d);
 
649
      if (!fax1x2 || abs(d)>1)
 
650
       s+=d*d;
 
651
      n1++;
 
652
      }
 
653
     j=i;
 
654
     sp=bad=0;
 
655
     }
 
656
    else
 
657
     {bad=1; n2++;}
 
658
    }
 
659
   else
 
660
    sp=1;
 
661
  if (n2+ng<=NTHLMAX && n1>=LSTRMIN || !n2 && n1>=2)
 
662
   {
 
663
   s=1000l*s/(n1-1);
 
664
   if (s<=min || w==2*p && nl<n1 && s<5*min/2)
 
665
    {min=s; p=w; nl=n1;}
 
666
   }
 
667
  }
 
668
/* printf("p=%u,d=%u\n",p,s); scanf("%c",&i);*/
 
669
 if (!nl || min>BND2*h)
 
670
  return 0;
 
671
 if (mg)
 
672
  {
 
673
  if (abs(p-total_pitch)<=1)
 
674
   return total_pitch;
 
675
  else
 
676
   return 0;
 
677
  }
 
678
 if (abs(p-total_pitch)<=1)
 
679
  return p;
 
680
 if (abs(p/2-total_pitch)<=1)
 
681
  return total_pitch;
 
682
 if (p>2*h+((fax1x2)?1:0))
 
683
  return 0;
 
684
 if (min<BNDOK*h && nl>1 || min<BND0*h && nl>=LSTRMIN && total_pitch)
 
685
  return p;
 
686
 if (nl<LSTRMIN && !fax1x2 || nl<LSTRMINF || nl<n/2 ||
 
687
     !total_pitch && 3*(n-nl-1)>nl)
 
688
  return 0;
 
689
 for (n1=0,s=0,i=1; i<n; i++)
 
690
  {
 
691
  if (left[i]-right[i-1]>=3*p/4)
 
692
   continue;
 
693
  d=center[i]-center[i-1]-p;
 
694
  if (d>=-DELTMAX && 700l*d*d<min)
 
695
   {
 
696
   if (!fax1x2 || abs(d)>1)
 
697
    s+=d*d;
 
698
   n1++;
 
699
   }
 
700
  }
 
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))
 
703
  return p;
 
704
 return 0;
 
705
 }
 
706
///////////////////////////////////////////////////////////////////////////////////////////////////////
 
707
// AK 19.02.98
 
708
void font_str()
 
709
{
 
710
        INT ni1,ni2,ns1,ns2,nu,n,trp;
 
711
        cell *c,*c1,*c2;
 
712
        BYTE fnt,fntu,fntprev;
 
713
        BYTE keg,kegprev;
 
714
        B_LINES bl;
 
715
 
 
716
 
 
717
        struct word_inc
 
718
        {
 
719
                cell *c1,*c;
 
720
                INT bool,n;
 
721
                BYTE fnt;
 
722
        } w_inc[WORDMAX];
 
723
 
 
724
        INT nwi=1; // 0 is fictive as left neigbor
 
725
 
 
726
        snap_newpass('i');
 
727
 
 
728
        // ********* font calculation **************
 
729
 
 
730
        underline();
 
731
        get_b_lines(NULL,&bl);
 
732
        total_pitch=pitchsize;
 
733
        base_prevstr=bl.b3;
 
734
        kegl_prevstr=bl.ps;
 
735
        fntprev=0;
 
736
 
 
737
        for (c1=NULL,c=(cell_f())->next; c!=NULL; c=c->next)
 
738
        {
 
739
                if (c1==NULL)
 
740
                {
 
741
                        ni1=ni2=ns1=ns2=nu=n=0;
 
742
                        c1=c;
 
743
                }
 
744
 
 
745
                if (c->flg&c_f_let)
 
746
                {
 
747
 
 
748
            if( erection_language(language) )
 
749
                        {
 
750
                                if (c->font&c_fp_it)
 
751
                                {
 
752
                                        ni1++;
 
753
                                        if( memchr(strong_italic,c->vers[0].let,sizeof(strong_italic)) )
 
754
                        {
 
755
                        if( c->vers[0].prob>180 )
 
756
                                                    ni1 += 2;
 
757
                        else if( c->vers[0].prob>70 )
 
758
                            ni1 += 1;
 
759
                        }
 
760
                                }
 
761
 
 
762
                                if (c->font&c_fp_str)
 
763
                                {
 
764
                                        ni2++;
 
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.
 
768
                                          )
 
769
                                                ni2 -= 1;
 
770
                                }
 
771
                        }
 
772
 
 
773
                        if (c->font&c_fp_ser)
 
774
                                ns1++;
 
775
                        if (c->font&c_fp_gelv)
 
776
                                ns2++;
 
777
                        if (c->font&c_fp_undrln)
 
778
                                nu++;
 
779
                        n++;
 
780
                }
 
781
 
 
782
                if (c->flg==c_f_space && c->vers[0].let!=0x1e || c->flg==c_f_fict)
 
783
                {
 
784
                        if (!(c1->flg&c_f_space))
 
785
                        {
 
786
                                fnt=fntu=0;
 
787
                                for (c2=c1; c2!=c && c2->vers[0].let=='/'; c2=c2->next)
 
788
                                {
 
789
                                }
 
790
 
 
791
                                if (c2!=c)
 
792
                                {
 
793
                                        if (ni1>ni2)
 
794
                                        fnt|=c_fp_it;
 
795
                                        if (ni1<ni2)
 
796
                                        fnt|=c_fp_str;
 
797
 
 
798
                                        {
 
799
                                                CHAR snap[80], sg[30], tmps[30];
 
800
 
 
801
                                                if( ni1 == 0 && ni2 == 0 )
 
802
                                                        strcpy(tmps," NO ");
 
803
                                                else
 
804
                                                        if( ni1 > ni2 )
 
805
                                                                strcpy(tmps, " ITA");
 
806
                                                        else
 
807
                                                                strcpy(tmps," STR");
 
808
 
 
809
                                                sprintf(sg, "%s  it = %3d st = %3d", tmps, ni1, ni2);
 
810
 
 
811
                                                if( snap_activity('i') )
 
812
                                                {
 
813
                                                        snap_newcell(c2);
 
814
                                                        sprintf(snap,"Word italic: %s",sg);
 
815
                                                        snap_show_text(snap);
 
816
                                                        snap_monitor();
 
817
                                                }
 
818
                                        }
 
819
                                }
 
820
                                if (ns1>ns2)
 
821
                                        fnt|=c_fp_ser;
 
822
                                if (ns1<ns2)
 
823
                                        fnt|=c_fp_gelv;
 
824
                                if (nu>3 || nu>0 && nu>n-3)
 
825
                                        fntu|=c_fp_undrln;
 
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);//???
 
830
 
 
831
 
 
832
                                //save prew word :
 
833
                                {
 
834
                                        INT  bool=0;
 
835
 
 
836
                                        for (c2=c1; c2!=c; c2=c2->next)
 
837
                                        {
 
838
                                                if (c2->flg!=c_f_space)
 
839
                                                {
 
840
                                                        if ( n == 1 &&
 
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.
 
844
                                                           )
 
845
                                                                bool = 1;
 
846
 
 
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.
 
850
                                                          )
 
851
                                                                bool++;
 
852
                                                }
 
853
                                        }
 
854
                                        if( bool == n )
 
855
                                                bool = 1;
 
856
                                        else
 
857
                                                bool = 0;
 
858
 
 
859
                                        if ( nwi < WORDMAX )
 
860
                                        {
 
861
                                                w_inc[nwi].fnt = fnt & (c_fp_it+c_fp_str);
 
862
                                                w_inc[nwi].bool = bool;
 
863
                                                w_inc[nwi].c1 = c1;
 
864
                                                w_inc[nwi].c = c;
 
865
                                                w_inc[nwi].n = n;
 
866
                                        }
 
867
 
 
868
                                        if( nwi < WORDMAX-1 )
 
869
                                                nwi++;
 
870
                                }
 
871
    if( (fnt&c_fp_it) && !(fnt&c_fp_str) )
 
872
        {
 
873
        for (c2=c1; c2!=c; c2=c2->next)
 
874
            {
 
875
            if( c2->flg!=c_f_space && c2->font&c_fp_str )
 
876
                c2->font-=c_fp_str;
 
877
            }
 
878
        }
 
879
    if( !(fnt&c_fp_it) && (fnt&c_fp_str) )
 
880
        {
 
881
        for (c2=c1; c2!=c; c2=c2->next)
 
882
            {
 
883
            if( c2->flg!=c_f_space && c2->font&c_fp_it )
 
884
                c2->font-=c_fp_it;
 
885
            }
 
886
        }
 
887
 
 
888
                                for (c2=c1; c2!=c; c2=c2->next)
 
889
                                {
 
890
                                        if (c2->flg!=c_f_space)
 
891
                                                c2->font=(c2->font/*&c_fp_undrln*/)|fnt;
 
892
                                }
 
893
 
 
894
                                for ( c2=c->prev;
 
895
                                      c2!=c1->prev && !(c2->flg&c_f_let);
 
896
                                          c2=c2->prev)
 
897
                                {
 
898
                                }
 
899
 
 
900
                                for ( ; c2!=c1->prev; c2=c2->prev)
 
901
                                {
 
902
                                        if (c2->flg!=c_f_space)
 
903
                                                c2->font|=fntu;
 
904
                                        //AK add c/g
 
905
                                        if (c2->prev == cell_f() || c2->prev == NULL)
 
906
                                                break;
 
907
                                }
 
908
                                fntprev=fnt;
 
909
                        }
 
910
                        c1=NULL;
 
911
                }
 
912
        }
 
913
 
 
914
 
 
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))
 
917
                {
 
918
                        fnt=c->font&(c_fp_it+c_fp_str);
 
919
                        break;
 
920
                }
 
921
 
 
922
        if (!fnt)
 
923
                fnt=c_fp_str;
 
924
 
 
925
        for (c1=(cell_f())->next; c1!=c; c1=c1->next)
 
926
                if (c1->flg!=c_f_space)
 
927
                        c1->font|=fnt;
 
928
 
 
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))
 
931
                {
 
932
                        fnt=c->font&(c_fp_ser+c_fp_gelv);
 
933
                        break;
 
934
                }
 
935
 
 
936
        for (c1=(cell_f())->next; c1!=c; c1=c1->next)
 
937
                if (c1->flg!=c_f_space)
 
938
                {
 
939
                        if (fnt)
 
940
                                c1->font|=fnt;
 
941
                        else
 
942
                                c1->font|=((c1->font&c_fp_it)?c_fp_gelv:c_fp_ser);
 
943
                }
 
944
 
 
945
 
 
946
        //use neigbor information for italic :
 
947
    if(0)
 
948
        {
 
949
                INT  i,fl,fr,fnt;
 
950
 
 
951
                w_inc[0].fnt = 0;
 
952
                w_inc[0].bool = 0;
 
953
                if ( nwi > 0 && nwi < WORDMAX )
 
954
                {
 
955
                        w_inc[nwi].fnt = 0;
 
956
                        w_inc[nwi].bool = 0;
 
957
                }
 
958
                else
 
959
                        nwi = WORDMAX / 2;
 
960
 
 
961
                for(i=1;i<nwi;i++)
 
962
                {
 
963
                        if( !w_inc[i].bool )
 
964
                                continue;
 
965
 
 
966
                        if( !w_inc[i-1].bool )
 
967
                                fl = w_inc[i-1].fnt;
 
968
                        else
 
969
                                fl = 0;
 
970
 
 
971
                        if( !w_inc[i+1].bool )
 
972
                                fr = w_inc[i+1].fnt;
 
973
                        else
 
974
                                fr = 0;
 
975
 
 
976
                        fnt = fl | fr;
 
977
                        if( fnt && (fnt^(c_fp_it+c_fp_str)) )
 
978
                        {
 
979
                                w_inc[i].bool = 0;
 
980
                                w_inc[i].fnt = (BYTE)fnt;
 
981
                                {
 
982
                                        CHAR snap[80],sg[30];
 
983
 
 
984
                                        if( fnt & c_fp_it )
 
985
                                                strcpy(sg," ITA");
 
986
                                        else
 
987
                                                if (fnt &  c_fp_str )
 
988
                                                        strcpy(sg," STR");
 
989
                                                else
 
990
                                                        strcpy(sg," NO ");
 
991
 
 
992
                                        sprintf(sg,"%s  ",sg);
 
993
                                        if( snap_activity('i') )
 
994
                                        {
 
995
                                                snap_newcell(w_inc[i].c1);
 
996
                                                sprintf(snap,"Word italic after neigbor: %s",sg);
 
997
                                                snap_show_text(snap);
 
998
                                                snap_monitor();
 
999
                                        }
 
1000
                                }
 
1001
 
 
1002
                                for (c2=w_inc[i].c1; c2!=w_inc[i].c; c2=c2->next)
 
1003
                                {
 
1004
                                        if (c2->flg!=c_f_space)
 
1005
                                        {
 
1006
                                                c2->font &= (~(c_fp_it+c_fp_str));
 
1007
                                                c2->font |= fnt;
 
1008
                                        }
 
1009
                                }
 
1010
                        }
 
1011
                }
 
1012
        }
 
1013
 
 
1014
 
 
1015
        // ********* kegel calculation ************
 
1016
 
 
1017
        kegprev=0;
 
1018
        for (c1=NULL,c=(cell_f())->next; c!=NULL; c=c->next)
 
1019
        {
 
1020
                if (c->flg&c_f_let)
 
1021
                        n++;
 
1022
                if (c1==NULL)
 
1023
                {
 
1024
                        n=0;
 
1025
                        c1=c;
 
1026
                }
 
1027
 
 
1028
                if (c->flg==c_f_space && c->vers[0].let!=0x1e || c->flg==c_f_fict)
 
1029
                {
 
1030
                        if (!(c1->flg&c_f_space))
 
1031
                        {
 
1032
                                get_b_lines(c1,&bl);
 
1033
                                keg=keg_word(c1,c,n,&bl)<<line_scale;
 
1034
                                if (!keg)
 
1035
                                        keg=kegprev;
 
1036
                                for (c2=c1; c2!=c; c2=c2->next)
 
1037
                                        if (c2->flg!=c_f_space)
 
1038
                                                c2->keg=keg;
 
1039
                                kegprev=keg;
 
1040
                        }
 
1041
                        c1=NULL;
 
1042
                }
 
1043
        }
 
1044
 
 
1045
        for (keg=0,c=(cell_f())->next; c->next!=NULL; c=c->next)
 
1046
                if (c->flg!=c_f_space && c->keg)
 
1047
                {
 
1048
                        keg=c->keg;
 
1049
                        break;
 
1050
                }
 
1051
 
 
1052
        if (!keg)
 
1053
        {
 
1054
                get_b_lines(NULL,&bl);
 
1055
                keg=(bl.ps+((fax1x2)?2:0))<<line_scale;
 
1056
        }
 
1057
 
 
1058
        for (c1=(cell_f())->next; c1!=c; c1=c1->next)
 
1059
                if (c1->flg!=c_f_space)
 
1060
                        c1->keg=keg;
 
1061
 
 
1062
 
 
1063
 
 
1064
        // ********* boldness calculation ***********
 
1065
 
 
1066
        for (nw=0,c1=NULL,c=(cell_f())->next; c!=NULL; c=c->next)
 
1067
        {
 
1068
                if (c1==NULL)
 
1069
                c1=c;
 
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)
 
1074
                {
 
1075
                        if (!(c1->flg&c_f_space))
 
1076
                        {
 
1077
                                if (trp)
 
1078
                                        c=c->next;
 
1079
                                bold_word(c1,c,&bld[nw]);
 
1080
 
 
1081
 
 
1082
 
 
1083
                                nw++;
 
1084
                                if (trp)
 
1085
                                        c=c->prev;
 
1086
                        }
 
1087
                        c1=NULL;
 
1088
                }
 
1089
        }
 
1090
 
 
1091
}
 
1092
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
1093
//
 
1094
static void underline()
 
1095
 {
 
1096
//      return;
 
1097
extern STRLN page_lines[];
 
1098
extern Int32 num_of_lines;
 
1099
 
 
1100
 INT nl=(INT)num_of_lines;
 
1101
 
 
1102
 STRLN *lines=page_lines;
 
1103
 INT i,bx,by,ex,ey,x;
 
1104
 B_LINES bl;
 
1105
 cell *c,*cf,*cl;
 
1106
 
 
1107
 get_b_lines(NULL,&bl);
 
1108
 cf=(cell_f())->next; cl=(cell_l())->prev;
 
1109
 for (i=0; i<nl; i++)
 
1110
  {
 
1111
  if (lines[i].type&FRM_LN || !(lines[i].type&HOR_LN))
 
1112
    continue;
 
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)
 
1121
    continue;
 
1122
  for (c=(cell_f())->next; c->next!=NULL; c=c->next)
 
1123
    {
 
1124
    if ((x=c->r_col+c->w/2)>=bx && x<=ex)
 
1125
        c->font|=c_fp_undrln;
 
1126
    }
 
1127
  lines[i].type|=UNDRLN;
 
1128
  }
 
1129
 
 
1130
 }
 
1131
 
 
1132
#define BNDPROB 100
 
1133
/*
 
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
 
1142
        0,0,0,0,0,0,
 
1143
//      [ \ ] ^ _ `
 
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,
 
1147
//      { | } ~
 
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 ! ?
 
1151
  */
 
1152
// ������ ���ନ��� � ��������� �ᯮ������� �㪢� �⭮�⥫쭮
 
1153
//  4-� ������� �����.
 
1154
// ___________
 
1155
// ___________   2                     0,4 -- ??????
 
1156
// ___________ 1 2 3
 
1157
// ___________     3
 
1158
//
 
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
 
1168
//      [ \ ] ^ _ `
 
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
//      � � � � � � � � � � � � � � �
 
1184
// from pass3.c
 
1185
static BYTE keg_word(cell *c1,cell *c2,INT n,B_LINES *bl)
 
1186
 {
 
1187
 INT s[4],m[4],i,ss,bm1,bm2;
 
1188
 cell *c;
 
1189
 version *v;
 
1190
 
 
1191
 if (!n) return 0;
 
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;
 
1196
 if( line_readyBL )
 
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;
 
1199
                                                         c!=c2; c=c->next)
 
1200
  if (c->flg&c_f_let)
 
1201
   {
 
1202
   for (i=-1,v=c->vers; v->let; v++)
 
1203
    {
 
1204
    if (v->prob<BNDPROB)
 
1205
     break;
 
1206
    if (i<0)
 
1207
     i=tabpos[let_sans_acc[v->let]];
 
1208
    else
 
1209
     if (i!=tabpos[let_sans_acc[v->let]])
 
1210
      {i=-1; break;}
 
1211
    }
 
1212
   if (i>0)
 
1213
    {
 
1214
    m[i-1]++;
 
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))
 
1218
     bm1++;
 
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))
 
1221
     bm2++;
 
1222
    }
 
1223
   }
 
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;
 
1231
 else
 
1232
  {
 
1233
  if (m[0]==n || m[0]>=2)
 
1234
   ss=(s[0]+m[0]/2)/m[0];
 
1235
  else
 
1236
   {
 
1237
   if (bl->n1>0 && bl->n2>0 && bl->n3>0 && 3*bl->ps/2+2>=bl->b3-bl->b1)
 
1238
    {
 
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]);
 
1242
    else
 
1243
     {
 
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]);
 
1248
     }
 
1249
    }
 
1250
   }
 
1251
  }
 
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);
 
1256
 return (BYTE)ss;
 
1257
 }
 
1258
 
 
1259
#define NOTAPPL -200
 
1260
#define DIFMAX    10
 
1261
#define DIFFLET   10
 
1262
#define MINPROB  180
 
1263
#define NMIN      10
 
1264
#define DENSMAX   40
 
1265
 
 
1266
static void bold_word(cell *c1,cell *c2,struct word_inf *inf)
 
1267
 {
 
1268
 cell *c;
 
1269
 INT sd,nd,td;
 
1270
 
 
1271
 for (sd=nd=0,c=c1; c!=c2; c=c->next)
 
1272
  {
 
1273
  if ( !(c->flg & c_f_let) || c->vers[0].prob<MINPROB)
 
1274
   continue;
 
1275
  if ((td=dens_let(c))!=NOTAPPL)
 
1276
   {sd+=td; nd++;}
 
1277
  }
 
1278
 if (nd==1 && c1->vers[0].let=='/')
 
1279
  nd=sd=0;
 
1280
 if (nd)
 
1281
  sd=(sd+((sd>0)?nd/2:-nd/2))/nd;
 
1282
 if (sd>DENSMAX)
 
1283
  sd=DENSMAX;
 
1284
 if (sd<-DENSMAX)
 
1285
  sd=-DENSMAX;
 
1286
 inf->c=c1;
 
1287
 inf->dens=sd;
 
1288
 inf->n=nd;
 
1289
if(0)
 
1290
{
 
1291
   CHAR snap[80],sg[30];
 
1292
   INT  ser,gel;
 
1293
 
 
1294
   ser = gel = 0;
 
1295
   for(c=c1; c!=c2; c=c->next){
 
1296
      if ( !(c->flg & c_f_let) || c->vers[0].prob<MINPROB)
 
1297
        continue;
 
1298
      if( c->font & c_fp_ser )
 
1299
        ser++;
 
1300
      if( c->font & c_fp_gelv )
 
1301
        gel++;
 
1302
   }
 
1303
   if( gel == 0 && ser == 0 )
 
1304
     strcpy(sg," NO");
 
1305
   else if( gel == 0 )
 
1306
     strcpy(sg," SERIF");
 
1307
   else if( ser == 0 )
 
1308
     strcpy(sg," GELVE");
 
1309
   else
 
1310
     sprintf(sg," SG S = %3d G = %3d",ser,gel);
 
1311
   if( snap_activity('i') ){
 
1312
      snap_newcell(c1);
 
1313
      sprintf(snap,"Word density: dens = %3d   ( n = %3d )  %s",sd,nd,sg);
 
1314
      snap_show_text(snap);
 
1315
      snap_monitor();
 
1316
   }
 
1317
}
 
1318
 }
 
1319
 
 
1320
static CHAR aver_dens;
 
1321
 
 
1322
void avdens()
 
1323
 {
 
1324
 //str *ln;
 
1325
 LONG /*l,*/s,n;
 
1326
 //c_comp **curr,**last,*cmp;
 
1327
 lnhead *line;
 
1328
 interval *ic,*ie;
 
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();
 
1333
 
 
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
 
1336
        {
 
1337
        if ( !(c->flg & (c_f_let|c_f_bad)) )
 
1338
                continue;
 
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))
 
1342
                {
 
1343
                for (ie=(ic=(interval *)((PBYTE)line+sizeof(lnhead)))+line->h;
 
1344
                          ic<ie; ic++)
 
1345
                        {
 
1346
                        s+=ic->l;
 
1347
                        }
 
1348
                }
 
1349
        }
 
1350
 /*
 
1351
 for (s=n=0,ln=(str *)box_pool; (PBYTE)ln!=string_curr;
 
1352
                                          ln=(str *)((PBYTE)ln+ln->lth))
 
1353
  {
 
1354
  last=(c_comp **)((PBYTE)ln+ln->dust);
 
1355
 
 
1356
  for (curr=&(ln->c_comp); curr<last; curr++) //AK 04.03.97 ? for address
 
1357
   {
 
1358
   cmp=*curr;
 
1359
   if (cmp->size==1 && !((file_comp *)cmp)->h && !((file_comp *)cmp)->w)
 
1360
    {
 
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;
 
1366
    }
 
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;
 
1372
                                                          ic<ie; ic++)
 
1373
     s+=ic->l;
 
1374
   }
 
1375
  }
 
1376
  */
 
1377
 if (!n)
 
1378
  {aver_dens=16; return;}
 
1379
 aver_dens=(16*s+n/2)/n+9;
 
1380
 if (aver_dens>=20)
 
1381
  aver_dens--;
 
1382
 if (aver_dens>=23)
 
1383
  aver_dens--;
 
1384
 if (aver_dens<=14)
 
1385
  aver_dens++;
 
1386
/* printf("s=%ld,n=%ld,dens=%u",s,n,aver_dens); scanf("%c",&l);*/
 
1387
 }
 
1388
 
 
1389
#define NODENS   255
 
1390
#define STDKEG    22
 
1391
#define MKEGDENS  65
 
1392
#define MDENS      4
 
1393
/*
 
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
 
1402
    2,0,2,0,0,0,
 
1403
//  [ \ ] ^ _ `
 
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,
 
1407
//  { | } ~
 
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 !  ?
 
1411
 
 
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
 
1420
    0,-4,0,0,0,0,
 
1421
//  [  \ ] ^ _ `
 
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,
 
1425
//  { | } ~
 
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 !  ?
 
1429
 
 
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
 
1438
    0,0,0,0,0,0,
 
1439
//  [ \ ] ^ _ `
 
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,
 
1443
//  { | } ~
 
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 !  ?
 
1447
 
 
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
 
1456
    2,-4,2,0,0,0,
 
1457
//  [  \ ] ^ _ `
 
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,
 
1461
//  { | } ~
 
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 !  ?
 
1465
 
 
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
 
1474
    2,-4,2,0,0,0,
 
1475
//  [  \ ] ^ _ `
 
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,
 
1479
//  { | } ~
 
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 !  ?
 
1483
  */
 
1484
 
 
1485
// ������� ������������� ��������� ����� � ����������� ��
 
1486
// ������ ����� �������.
 
1487
 
 
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
 
1497
    0,0,0,0,0,0,
 
1498
//  [ \ ] ^ _ `
 
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
//      � � � � � � � � � � � � � � �
 
1514
 
 
1515
 
 
1516
 
 
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
 
1527
    2,0,2,0,0,0,
 
1528
//  [ \ ] ^ _ `
 
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
//      � � � � � � � � � � � � � � �
 
1544
 
 
1545
 
 
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
 
1555
    0,-4,0,0,0,0,
 
1556
//  [  \ ] ^ _ `
 
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
//      � � � � � �   � � � � � � � �   �
 
1572
 
 
1573
 
 
1574
 
 
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
 
1584
    2,-4,2,0,0,0,
 
1585
//  [  \ ] ^ _ `
 
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
//      � � � � � � � � � � � � � � �
 
1601
 
 
1602
 
 
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
 
1612
    2,-4,2,0,0,0,
 
1613
//  [  \ ] ^ _ `
 
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
//      � � � � � � � � � � � � � � �
 
1629
 
 
1630
static INT dens_let(cell *c)
 
1631
 {
 
1632
 INT d,h;
 
1633
 PCHAR tab;
 
1634
 BYTE let,fnt;
 
1635
 if (c->dens>100)  // 11-10-94 05:59pm Pit for debug
 
1636
  return NOTAPPL;  //
 
1637
 if (c->dens==NODENS)
 
1638
  return NOTAPPL;
 
1639
 let=let_sans_acc[c->vers[0].let];
 
1640
 fnt=c->font;
 
1641
 if (strchr("*#!ijltI1()[]{}",let)!=NULL ||
 
1642
     let==liga_bull ||
 
1643
         let==liga_i ||
 
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)
 
1648
  return NOTAPPL;
 
1649
 if (fnt&c_fp_it)
 
1650
  tab=tabgi;
 
1651
 else
 
1652
  {
 
1653
  if ( language != LANG_RUSSIAN && pitchsize )
 
1654
   {
 
1655
   if (pitchsize>c->keg)
 
1656
    tab=tabcr;
 
1657
   else
 
1658
    tab=tabmd;
 
1659
   }
 
1660
  else
 
1661
   {
 
1662
   if (fnt&c_fp_ser)
 
1663
    tab=tabss;
 
1664
   else
 
1665
    tab=tabgs;
 
1666
   }
 
1667
  }
 
1668
 d=aver_dens+tab[let];
 
1669
 if (let=='f' && fnt&c_fp_it && c->cpos&ce_p_Ql)
 
1670
  d-=3;
 
1671
 if (let=='f' && tab==tabgs)
 
1672
  {
 
1673
  if (c->w>c->h/2)
 
1674
   d-=2;
 
1675
  if (c->w<c->h/3)
 
1676
   d++;
 
1677
  }
 
1678
 if (let=='r' && 17*c->w<=11*c->h)
 
1679
  d++;
 
1680
 d+=(d<<line_scale)/5;
 
1681
 if (c->keg<<line_scale>STDKEG)
 
1682
  {
 
1683
  if (c->h<=3*c->keg/2+2)
 
1684
   h=c->keg>>line_scale;
 
1685
  else
 
1686
   h=(2*c->h+1)/3;
 
1687
  d-=(d*((h<<line_scale)-STDKEG)+MKEGDENS/2)/MKEGDENS;
 
1688
  }
 
1689
 if (c->keg<=16) d++;
 
1690
 if (c->keg<=12) d++;
 
1691
 if (fax1x2) d++;
 
1692
 
 
1693
#ifdef STAT_PIT
 
1694
//  ���� �।����䬥��᪮�� � ���⭮�� ᨬ�����
 
1695
//
 
1696
 
 
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;
 
1702
 
 
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;
 
1710
 stat_tab[let].n++;
 
1711
 
 
1712
#endif
 
1713
 
 
1714
#ifdef ANDREW_BI
 
1715
 return  (c->dens-tab[let]);
 
1716
#else
 
1717
 return MDENS*(c->dens-d);
 
1718
#endif
 
1719
 }
 
1720
 
 
1721
void font_narrow(void)
 
1722
{
 
1723
cell *  c;
 
1724
BYTE    slanguage=language;
 
1725
INT     prop, nall, nval, narrow, pn;
 
1726
 
 
1727
if( line_tabcell || !line_scale )
 
1728
    return;
 
1729
for(nval=nall=narrow=0,c=cell_f()->nextl;c!=cell_l();c=c->nextl)
 
1730
    {
 
1731
    if( c->nvers==0 || !(c->flg&c_f_let) )
 
1732
        continue;
 
1733
    language = c->language;
 
1734
    nall++;
 
1735
    prop = prop_index(c->h, c->w);
 
1736
    pn = prop_narrow[ (INT)c->vers[0].let ];
 
1737
    if( pn )
 
1738
        nval++;
 
1739
    if( (c->font & c_fp_narrow) )
 
1740
        narrow++;
 
1741
    else if(  pn &&  pn> prop )
 
1742
        narrow++;
 
1743
    }
 
1744
if( narrow*10 > nall*6 || narrow*10 > nval*6 && nval*2>=nall)
 
1745
    {
 
1746
    for(nall=narrow=0,c=cell_f()->nextl;c!=cell_l();c=c->nextl)
 
1747
        {
 
1748
        c->font |= c_fp_narrow;
 
1749
        }
 
1750
    }
 
1751
language=slanguage;
 
1752
return;
 
1753
}