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

« back to all changes in this revision

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

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

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
Copyright (c) 1993-2008, Cognitive Technologies
3
3
All rights reserved.
4
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
 
�������� ��� ������ ���� ���� �������� � ����������� ����� ������� � ������.
 
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
32
 
33
33
Redistribution and use in source and binary forms, with or without modification,
34
34
are permitted provided that the following conditions are met:
57
57
#include <string.h>
58
58
#include <stdlib.h>
59
59
 
60
 
#include "nt_types.h"
61
60
#include "struct.h"
62
61
#include "cstr.h"
63
 
//#include "cpage.h"
64
62
#include "func.h"
65
63
#include "linutil.h"
66
64
#include "fon.h"
75
73
#define INCL_FAC 2048
76
74
 
77
75
extern Handle hSnapSerifTrace;
78
 
extern INT    erection_inc;
79
 
extern BYTE   p2_active;
 
76
extern int16_t    erection_inc;
 
77
extern uchar   p2_active;
80
78
 
81
79
Bool32 p2_Line2Raster(c_comp *comp, RecRaster *rec);
82
80
 
83
 
static WORD tabserif[256]={
 
81
static uint16_t tabserif[256]={
84
82
        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
85
83
        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
86
84
//                        ! " # $ % & ' ( ) * + , - . /
93
91
        0,0,0,0x0001,0,0x00C0,0,0x0033,0x00C0,0,0x0033,0x00C0,0x003F,0x0033,0,0x2030,0x0103,0x00C0,0,0,0x2200,0x3300,0x3300,0,0x3300,0,    // 97-122
94
92
//      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
95
93
        0,0,0,0,0,0x0033,0x2020,0x2020,0x2030,0x2100,0x2020,0x0C0C,0,0x3123,0x0023,0x3030,0x0103,0x2133,0x3333,0,0x2133,0x2030,0,0x000C,0x3300,0x0C0C,0x0333,0x3300,//123-150
96
 
//      { | } ~       �      �      �      �      �      �      � �      �      �      �      �      �      � �      �      � �      �      �      �      �      �
 
94
//      { | } ~       Ђ      Ѓ      ‚      ѓ      „      …      † ‡      €      ‰      Љ      ‹      Њ      Ќ Ћ      Џ      ђ ‘      ’      “      ”      •      –
97
95
        0x3303,0x3F21,0x3F00,0x1020,0x3323,0x3020,0,0x3030,0x0103,0,0,0x2020,0x2030,0x2100,0,0x0C0C,0,0x3123,0x0023,0x3030,0x0103,0x2133,0x3333,0,0x2133,0,    //151-176
98
 
//           �      �      �      �      �      � �      �      � � �      �      �      � �      � �      �      �      �      �      �      � �      � �
 
96
//           —      �      ™      љ      ›      њ ќ      ћ      џ   Ў      ў      Ј      ¤ Ґ      ¦ §      Ё      ©      Є      «      ¬      ­ ®      Ї °
99
97
        0x0033,0x0033,0x0033,0x003F,0x0030,0x0033,0,0,0x003F,0x00C0,0,0,0,                      // 177-189
100
98
//          fi     fl     ff    ffi     rt     ri % %    ffl      i j ! ?
101
 
//      �  �  �  �   �  � � �  �  � � � �
 
99
//      ±  І  і  ґ   µ  ¶ · ё  №  є » ј Ѕ
102
100
        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
103
 
//      � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �
 
101
//      ѕ ї А Б В Г Д Е Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Ъ Ы Ь Э Ю Я
104
102
        0x2030,0,0x000C,0x3300,0x0C0C,0x3333,0x3300,0x3303,0x3F21,0x3F00,0x1020,0x3323,0x3020,0,0x3030,0x0103,                        // 224 - 239
105
 
//           � �      �      �      �      �      �      �      �      �      �      �      � �      �      �
 
103
//           а б      в      г      д      е      ж      з      и      й      к      л      м н      о      п
106
104
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};                       // 240 - 255
107
 
//      � � � � � � � � � � � � � � �
 
105
//      р с т у ф х ц ч ш щ ъ ы ь э ю
108
106
 
109
 
static WORD tabvserif[256]={
 
107
static uint16_t tabvserif[256]={
110
108
        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
111
109
        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
112
110
//                        ! " # $ % & ' ( ) * + , - . /
119
117
        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,    // 97-122
120
118
//      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
121
119
        0,0,0,0,0,0,0x0002,0,0x0002,0,0x0012,0,0,0,0,0,0,0,0,0,0,0,0,0x0202,0,0,0,0,//123-150
122
 
//      { | } ~  �      � �      � �      � � � � � � � � � � � � �      � � � � �
 
120
//      { | } ~  Ђ      Ѓ ‚      ѓ „      … † ‡ € ‰ Љ ‹ Њ Ќ Ћ Џ ђ ‘      ’ “ ” • –
123
121
        0,0,0,0,0,0,0,0,0,0,0,0,0x0002,0,0,0,0,0,0,0,0,0,0,0,0,0,    //151-176
124
 
//      � � � � � � � � � � � �      � � � � � � � � � � � � � �
 
122
//      — � ™ љ › њ ќ ћ џ   Ў ў      Ј ¤ Ґ ¦ § Ё © Є « ¬ ­ ® Ї °
125
123
        0,  0, 0,  0, 0, 0,0,0,  0,0,0,0,0,                      // 177-189
126
124
//      fi fl ff ffi rt ri % % ffl i j ! ?
127
 
//      �  �  �  �   �  � � �  �  � � � �
 
125
//      ±  І  і  ґ   µ  ¶ · ё  №  є » ј Ѕ
128
126
        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
129
 
//      � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �
 
127
//      ѕ ї А Б В Г Д Е Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Ъ Ы Ь Э Ю Я
130
128
        0,0,0x0202,0,0,0,0,0,0,0,0,0,0,0,0,0,                        // 224 - 239
131
 
//      � �      � � � � � � � � � � � � � �
 
129
//      а б      в г д е ж з и й к л м н о п
132
130
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};                       // 240 - 255
133
 
//      � � � � � � � � � � � � � � �
134
 
static Word32 key=2;                  //��� snap'�
 
131
//      р с т у ф х ц ч ш щ ъ ы ь э ю
 
132
static uint32_t key=2;                  //для snap'а
135
133
 
136
134
static cell *serif_word(cell *c);
137
 
static LONG new_serif(cell *c);
138
 
static LONG fon_test(cell *c);
139
 
static void find_serif(cell *c, WORD map, LONG *meas, LONG *np, LONG *nm);
140
 
static LONG downserif(c_comp *env, BYTE shape, INT H, STICK *st);
141
 
static LONG upserif(c_comp *env, BYTE shape, INT H, STICK *st);
142
 
static interval *interval_fit(INT i, lnhead *line, INT H, STICK *st);
 
135
static int32_t new_serif(cell *c);
 
136
static int32_t fon_test(cell *c);
 
137
static void find_serif(cell *c, uint16_t map, int32_t *meas, int32_t *np, int32_t *nm);
 
138
static int32_t downserif(c_comp *env, uchar shape, int16_t H, STICK *st);
 
139
static int32_t upserif(c_comp *env, uchar shape, int16_t H, STICK *st);
 
140
static interval *interval_fit(int16_t i, lnhead *line, int16_t H, STICK *st);
143
141
static void ideal2rc(Point16 *p);
144
 
static void bound_cell(cell *c, Word32 color);
 
142
static void bound_cell(cell *c, uint32_t color);
145
143
 
146
144
void serif_let()
147
145
{
152
150
 
153
151
static cell *serif_word(cell *c)
154
152
{
155
 
  LONG np=0,nm=0,meas=0;
156
 
  LONG serif=0;
157
 
  BOOL reliable;
158
 
//  LONG tol;
 
153
  int32_t np=0,nm=0,meas=0;
 
154
  int32_t serif=0;
 
155
  Bool reliable;
 
156
//  int32_t tol;
159
157
  cell *beg=c,*end;
160
 
  B_LINES my_bases; //������ �����
 
158
  B_LINES my_bases; //Ў §®ўлҐ «Ё­ЁЁ
161
159
 
162
160
  if (!c->next)
163
161
    return NULL;
174
172
 
175
173
    if (c->flg & (c_f_let | c_f_bad))
176
174
    {
177
 
      BYTE let;
 
175
      uchar let;
178
176
      c->font &= ~(c_fp_gelv | c_fp_ser);
179
177
      if (!(c->font & c_fp_it) || is_upper(let=c->vers[0].let) ||
180
 
                        strchr("���",let) &&
 
178
                        strchr("Јав",let) &&
181
179
                        !is_russian_baltic_conflict(let)&&// 17.07.2001 E.P.
182
180
                        !is_russian_turkish_conflict(let) // 21.05.2002 E.P.
183
181
                 )
184
182
      {
185
 
        LONG m=new_serif(c);
 
183
        int32_t m=new_serif(c);
186
184
        if (m>0)  np++;
187
185
        else
188
186
        if (m<0)  nm++;
218
216
 
219
217
      if (c->flg & (c_f_let | c_f_bad))
220
218
      {
221
 
        BYTE let;
 
219
        uchar let;
222
220
        if (!(c->font & c_fp_it) || is_upper(let=c->vers[0].let) ||
223
 
                                strchr("���",let) &&
 
221
                                strchr("Јав",let) &&
224
222
                                        !is_russian_baltic_conflict(let)&&// 17.07.2001 E.P.
225
223
                                        !is_russian_turkish_conflict(let) // 21.05.2002 E.P.
226
224
                   )
227
225
        {
228
 
          LONG m=fon_test(c);
 
226
          int32_t m=fon_test(c);
229
227
          if (m==0)            //no match found, use old flags
230
228
          {
231
229
            if (c->font & c_fp_ser)  m++;
248
246
 
249
247
  if (serif != 0)
250
248
  {
251
 
    BYTE font;
 
249
    uchar font;
252
250
    if (reliable)  font = (serif>0) ? c_fp_ser : c_fp_gelv;
253
251
    else           font = c_fp_ser | c_fp_gelv;
254
252
 
275
273
  return c;
276
274
}
277
275
 
278
 
static LONG new_serif(cell *c)
 
276
static int32_t new_serif(cell *c)
279
277
{
280
 
  BYTE let=let_sans_acc[c->vers[0].let];
281
 
  WORD map=tabserif[let];
282
 
  LONG meas=0,np=0,nm=0;
 
278
  uchar let=let_sans_acc[c->vers[0].let];
 
279
  uint16_t map=tabserif[let];
 
280
  int32_t meas=0,np=0,nm=0;
283
281
 
284
282
  if (map==0)
285
283
    return 0;
288
286
 
289
287
  if (map=tabvserif[let])
290
288
  {
291
 
    BYTE *rast=save_raster(c);
292
 
    INT t_height=c->w,t_width_b = (c->h+7)/8;
 
289
    uchar *rast=save_raster(c);
 
290
    int16_t t_height=c->w,t_width_b = (c->h+7)/8;
293
291
    MN   *mn;
294
292
 
295
293
    c_rastror(rast,t_raster(),c->w,c->h);
316
314
/*
317
315
  else
318
316
  {
319
 
    LONG nmin=(np,nm),nmax=MAX(np,nm);
 
317
    int32_t nmin=(np,nm),nmax=MAX(np,nm);
320
318
    if (nmin>1 || nmax-nmin<2)
321
319
      return 0;
322
320
 
326
324
*/
327
325
}
328
326
 
329
 
static LONG fon_test(cell *c)
 
327
static int32_t fon_test(cell *c)
330
328
{
331
329
  FonTestInfo testInfo[MAXCHECKALT];
332
330
  RecRaster recRast;
333
 
  BYTE let=let_sans_acc[c->vers[0].let];
334
 
  WORD map=tabserif[let];
335
 
  LONG i,nitem=0,serific,nbit=8*sizeof(map);
 
331
  uchar let=let_sans_acc[c->vers[0].let];
 
332
  uint16_t map=tabserif[let];
 
333
  int32_t i,nitem=0,serific,nbit=8*sizeof(map);
336
334
 
337
335
  if (map==0)
338
336
    return 0;
341
339
    return 0;
342
340
 
343
341
  // Nick 20.9.99
344
 
  // ��� �������� �������� ?
 
342
  // уже искались атрибуты ?
345
343
  if( c->clu_attr )
346
 
      testInfo[0].flag = (BYTE)c->clu_attr;
 
344
      testInfo[0].flag = (uchar)c->clu_attr;
347
345
  else
348
346
  {
349
347
    p2_Line2Raster(c->env,&recRast);
367
365
  return (serific>=0) ? nitem : -nitem;
368
366
}
369
367
 
370
 
static void find_serif(cell *c, WORD map, LONG *meas, LONG *np, LONG *nm)
 
368
static void find_serif(cell *c, uint16_t map, int32_t *meas, int32_t *np, int32_t *nm)
371
369
{
372
370
  STICK *st,*sti;
373
 
  INT i,nstick;
374
 
  BYTE shape;
375
 
  INT w0=c->w,dw=0,w3,w23;  //w0 - width of untilted letter
 
371
  int16_t i,nstick;
 
372
  uchar shape;
 
373
  int16_t w0=c->w,dw=0,w3,w23;  //w0 - width of untilted letter
376
374
 
377
375
  if (c->n_baton==255)
378
376
    nstick=sticks_in_letter(c,0,&st);
386
384
 
387
385
  if (c->font & c_fp_it)
388
386
  {
389
 
    INT stick_inc=c->stick_inc;
 
387
    int16_t stick_inc=c->stick_inc;
390
388
    if (stick_inc==NO_INCLINE)
391
389
      if (erection_inc != 0)
392
390
        stick_inc=erection_inc;
407
405
    sti=st+nstick-1;
408
406
    if (sti->y<=2 && w23 < sti->x && sti->x < c->w)
409
407
    {
410
 
      LONG m=downserif(c->env,shape,c->h,sti);
 
408
      int32_t m=downserif(c->env,shape,c->h,sti);
411
409
      if (m>0)  (*np)++;
412
410
      else
413
411
      if (m<0)  (*nm)++;
422
420
    for (i=0,sti=st; i<nstick; i++,sti++)
423
421
      if (sti->y<=2 && w3 <= sti->x && sti->x < w23)
424
422
      {
425
 
        LONG m=downserif(c->env,shape,c->h,sti);
 
423
        int32_t m=downserif(c->env,shape,c->h,sti);
426
424
        if (m>0)  (*np)++;
427
425
        else
428
426
        if (m<0)  (*nm)++;
438
436
    sti=st;
439
437
    if (sti->y<=2 && sti->x < w3)
440
438
    {
441
 
      LONG m=downserif(c->env,shape,c->h,sti);
 
439
      int32_t m=downserif(c->env,shape,c->h,sti);
442
440
      if (m>0)  (*np)++;
443
441
      else
444
442
      if (m<0)  (*nm)++;
450
448
  shape=map&3;
451
449
  if (shape && nstick==1)  //stick like
452
450
  {
453
 
    LONG m=downserif(c->env,shape,c->h,st);
 
451
    int32_t m=downserif(c->env,shape,c->h,st);
454
452
    if (m>0)  (*np)++;
455
453
    else
456
454
    if (m<0)  (*nm)++;
464
462
    sti=st+nstick-1;
465
463
    if (sti->y+sti->l+2>=c->h)
466
464
    {
467
 
      INT x=sti->x+sti->l*sti->incl/INCL_FAC-dw;
 
465
      int16_t x=sti->x+sti->l*sti->incl/INCL_FAC-dw;
468
466
      if (w23 < x && x < c->w)
469
467
      {
470
 
        LONG m=upserif(c->env,shape,c->h,sti);
 
468
        int32_t m=upserif(c->env,shape,c->h,sti);
471
469
        if (m>0)  (*np)++;
472
470
        else
473
471
        if (m<0)  (*nm)++;
483
481
    for (i=0,sti=st; i<nstick; i++,sti++)
484
482
      if (sti->y+sti->l+2>=c->h)
485
483
      {
486
 
        INT x=sti->x+sti->l*sti->incl/INCL_FAC-dw;
 
484
        int16_t x=sti->x+sti->l*sti->incl/INCL_FAC-dw;
487
485
        if (w3 <= x && x < w23)
488
486
        {
489
 
          LONG m=upserif(c->env,shape,c->h,sti);
 
487
          int32_t m=upserif(c->env,shape,c->h,sti);
490
488
          if (m>0)  (*np)++;
491
489
          else
492
490
          if (m<0)  (*nm)++;
503
501
    for (i=0,sti=st; i<MIN(2,nstick); i++,sti++)   //in russian 'i' left stick maybe not first
504
502
      if (sti->y+sti->l+2>=c->h)
505
503
      {
506
 
        INT x=sti->x+sti->l*sti->incl/INCL_FAC-dw;
 
504
        int16_t x=sti->x+sti->l*sti->incl/INCL_FAC-dw;
507
505
        if (x < w3)
508
506
        {
509
 
          LONG m=upserif(c->env,shape,c->h,sti);
 
507
          int32_t m=upserif(c->env,shape,c->h,sti);
510
508
          if (m>0)  (*np)++;
511
509
          else
512
510
          if (m<0)  (*nm)++;
520
518
  shape=map&3;
521
519
  if (shape && nstick==1)  //stick like
522
520
  {
523
 
    LONG m=upserif(c->env,shape,c->h,st);
 
521
    int32_t m=upserif(c->env,shape,c->h,st);
524
522
    if (m>0)  (*np)++;
525
523
    else
526
524
    if (m<0)  (*nm)++;
528
526
  }
529
527
}
530
528
 
531
 
static LONG downserif(c_comp *env, BYTE shape, INT H, STICK *st)
 
529
static int32_t downserif(c_comp *env, uchar shape, int16_t H, STICK *st)
532
530
{
533
 
  INT h,H8=H/8,H3=H/3;
 
531
  int16_t h,H8=H/8,H3=H/3;
534
532
  lnhead *line;
535
 
  LONG rv=0;
 
533
  int32_t rv=0;
536
534
 
537
 
  for (line=(lnhead *)((PCHAR)(env)+env->lines+sizeof(INT));
 
535
  for (line=(lnhead *)((pchar)(env)+env->lines+sizeof(int16_t));
538
536
                         line->lth>0;
539
 
       line=(lnhead *)((PCHAR)line+line->lth))
 
537
       line=(lnhead *)((pchar)line+line->lth))
540
538
    if (line->flg&l_fend && (h=line->h) > H3 && line->row+h+2 >= H)
541
539
    {
542
 
      INT x1,x2,i,i0=h-H3-1,in,begl=0,begr=0;
543
 
      LONG lsum=0,rsum=0,imaxl=0,vmaxl=0,imaxr=0,vmaxr=0;
 
540
      int16_t x1,x2,i,i0=h-H3-1,in,begl=0,begr=0;
 
541
      int32_t lsum=0,rsum=0,imaxl=0,vmaxl=0,imaxr=0,vmaxr=0;
544
542
      interval *intv;
545
543
 
546
544
      i0=MAX(i0,0);
563
561
//          break;              //a tump on the line end
564
562
//        else
565
563
        {
566
 
          INT dx=(i*st->incl+INCL_FAC/2)/INCL_FAC,s;
 
564
          int16_t dx=(i*st->incl+INCL_FAC/2)/INCL_FAC,s;
567
565
          if (shape&2)
568
566
          {
569
567
            s=x1-(intv->e-intv->l+dx);
630
628
  return 0;
631
629
}
632
630
 
633
 
static LONG upserif(c_comp *env, BYTE shape, INT H, STICK *st)
 
631
static int32_t upserif(c_comp *env, uchar shape, int16_t H, STICK *st)
634
632
{
635
 
  INT h,H8=H/8,H3=H/3;
 
633
  int16_t h,H8=H/8,H3=H/3;
636
634
  lnhead *line;
637
 
  LONG rv=0;
 
635
  int32_t rv=0;
638
636
 
639
 
  for (line=(lnhead *)((PCHAR)(env)+env->lines+sizeof(INT));
 
637
  for (line=(lnhead *)((pchar)(env)+env->lines+sizeof(int16_t));
640
638
                         line->lth>0;
641
 
       line=(lnhead *)((PCHAR)line+line->lth))
 
639
       line=(lnhead *)((pchar)line+line->lth))
642
640
    if (line->flg&l_fbeg && (h=line->h) > H3 && line->row <= 2)
643
641
    {
644
 
      INT x1,x2,i,i0=MIN(H3,h),begl=0,begr=0;
645
 
      LONG lsum=0,rsum=0,imaxl=0,vmaxl=0,imaxr=0,vmaxr=0;
 
642
      int16_t x1,x2,i,i0=MIN(H3,h),begl=0,begr=0;
 
643
      int32_t lsum=0,rsum=0,imaxl=0,vmaxl=0,imaxr=0,vmaxr=0;
646
644
      interval *intv;
647
645
 
648
646
      i=H8+1;                //from line top
666
664
//          break;               //a tump on the line begin
667
665
//        else
668
666
        {
669
 
          INT dx=(i*st->incl+INCL_FAC/2)/INCL_FAC,s;
 
667
          int16_t dx=(i*st->incl+INCL_FAC/2)/INCL_FAC,s;
670
668
          if (shape&2)
671
669
          {
672
670
            s=x1-(intv->e-intv->l-dx);
752
750
  return 0;
753
751
}
754
752
 
755
 
static interval *interval_fit(INT i, lnhead *line, INT H, STICK *st)
 
753
static interval *interval_fit(int16_t i, lnhead *line, int16_t H, STICK *st)
756
754
//return pointer to i-th interval of the line if it corresponds to stick st;
757
755
{
758
 
  INT h0=H-(line->row+i);    //from raster bottom
759
 
  INT x0=st->x+(h0-st->y)*st->incl/INCL_FAC;
760
 
  interval *intv=(interval *)((PCHAR)line+sizeof(lnhead))+i;
 
756
  int16_t h0=H-(line->row+i);    //from raster bottom
 
757
  int16_t x0=st->x+(h0-st->y)*st->incl/INCL_FAC;
 
758
  interval *intv=(interval *)((pchar)line+sizeof(lnhead))+i;
761
759
  if (x0 > intv->e || x0 < intv->e-intv->l)  intv=NULL;
762
760
  return intv;
763
761
}
764
762
 
765
763
static void ideal2rc(Point16 *p)
766
764
{
767
 
  INT y=p->y;
768
 
  p->y=y+(INT)((LONG)nIncline*p->x/2048);
769
 
  p->x=p->x-(INT)((LONG)nIncline*y/2048);
 
765
  int16_t y=p->y;
 
766
  p->y=y+(int16_t)((int32_t)nIncline*p->x/2048);
 
767
  p->x=p->x-(int16_t)((int32_t)nIncline*y/2048);
770
768
}
771
769
 
772
 
static void bound_cell(cell *c, Word32 color)
 
770
static void bound_cell(cell *c, uint32_t color)
773
771
{
774
772
  Rect16 box;
775
773
  Point16 pa={c->col,c->row},pb={c->col+c->w-1,c->row+c->h-1};