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

« back to all changes in this revision

Viewing changes to cuneiform_src/Kern/rstr/src/corners.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:
64
64
#include <stdlib.h>
65
65
#include <stdio.h>
66
66
#include <string.h>
67
 
#include "nt_types.h"
68
67
#include "struct.h"
69
68
#include "cutstr.h"
70
69
#include "func.h"
75
74
#define AVOID_PRYSCH 3
76
75
 
77
76
/************** all function prototypes ***********************************/
78
 
INT u_around_bl_corner ( s_glue * );
79
 
INT n_around_ur_corner ( s_glue * );
 
77
int16_t u_around_bl_corner ( s_glue * );
 
78
int16_t n_around_ur_corner ( s_glue * );
80
79
void comp_row_col( s_glue * );
81
 
static void comp_parms( BYTE );
82
 
// static INT bottom_right_corner (PBYTE, BYTE, BYTE, BYTE);
83
 
static INT bottom_left_corner (PBYTE, BYTE, BYTE, BYTE);
84
 
static INT upper_right_corner (PBYTE, BYTE, BYTE, BYTE);
85
 
//static INT upper_left_corner (PBYTE, BYTE, BYTE, BYTE);
86
 
static BOOL is_italic();
 
80
static void comp_parms( uchar );
 
81
// static int16_t bottom_right_corner (puchar, uchar, uchar, uchar);
 
82
static int16_t bottom_left_corner (puchar, uchar, uchar, uchar);
 
83
static int16_t upper_right_corner (puchar, uchar, uchar, uchar);
 
84
//static int16_t upper_left_corner (puchar, uchar, uchar, uchar);
 
85
static Bool is_italic();
87
86
static void compare_corners_mass();
88
 
static void make_straight_abris (s_glue *, PBYTE, PBYTE);
89
 
static INT func_mode_val( PBYTE func, BYTE from, BYTE to);
90
 
static INT left_right_dist();
 
87
static void make_straight_abris (s_glue *, puchar, puchar);
 
88
static int16_t func_mode_val( puchar func, uchar from, uchar to);
 
89
static int16_t left_right_dist();
91
90
/*************************************************************************/
92
91
 
93
92
extern servBOX SBOX;
94
 
BYTE str_left[128];
95
 
BYTE str_right[128];
 
93
uchar str_left[128];
 
94
uchar str_right[128];
96
95
 
97
 
BYTE l_tab_shift[128];       // the tables of shifts ( avoiding italic
98
 
BYTE r_tab_shift[128];       //  and oblique )
 
96
uchar l_tab_shift[128];       // the tables of shifts ( avoiding italic
 
97
uchar r_tab_shift[128];       //  and oblique )
99
98
 
100
99
#define ST_PEN_NUM 5
101
 
static INT pen_for_staires[ST_PEN_NUM+1] = { 0, 14, 36, 60, 72, 120 };
 
100
static int16_t pen_for_staires[ST_PEN_NUM+1] = { 0, 14, 36, 60, 72, 120 };
102
101
#define LRD_PEN_NUM 7
103
 
static INT pen_for_left_right_dist[LRD_PEN_NUM+1] =
 
102
static int16_t pen_for_left_right_dist[LRD_PEN_NUM+1] =
104
103
                                     { 0, 0, 12, 46, 80, 120, 160, 220 };
105
 
static BYTE comp_h, un_code;
106
 
static BYTE num_st, beg_zone, end_zone;
107
 
static INT pen_u, pen_n;
108
 
static INT maxrow, maxcol, minrow, mincol;
 
104
static uchar comp_h, un_code;
 
105
static uchar num_st, beg_zone, end_zone;
 
106
static int16_t pen_u, pen_n;
 
107
static int16_t maxrow, maxcol, minrow, mincol;
109
108
 
110
109
 
111
110
#define Let_n   2
112
111
#define Let_u   4
113
 
void discrim_un( cell *GC, s_glue *GL, INT cod_let )
 
112
void discrim_un( cell *GC, s_glue *GL, int16_t cod_let )
114
113
{
115
 
INT wi;
 
114
int16_t wi;
116
115
 
117
116
 memset ( l_tab_shift, 0, sizeof (l_tab_shift) );
118
117
 memset ( r_tab_shift, 0, sizeof (r_tab_shift) );
119
118
 
120
 
 pen_u = 0; pen_n = 0; un_code = (BYTE)cod_let;
 
119
 pen_u = 0; pen_n = 0; un_code = (uchar)cod_let;
121
120
 
122
121
 comp_row_col( GL );          // compute coordinates of the composed box
123
122
 // check italic incline of the component
144
143
ApplyPenalty:
145
144
 if ( pen_u )
146
145
  {
147
 
   cell_bonus_let(GC, 'u', (INT)(-(pen_u)) );
 
146
   cell_bonus_let(GC, 'u', (int16_t)(-(pen_u)) );
148
147
   sort_vers( GC );
149
148
  }
150
149
 if ( pen_n )
151
150
  {
152
 
   cell_bonus_let(GC, 'n', (INT)(-(pen_n)) );
 
151
   cell_bonus_let(GC, 'n', (int16_t)(-(pen_n)) );
153
152
   sort_vers( GC );
154
153
  }
155
154
}
156
155
 
157
 
static void make_straight_abris (s_glue *GL, PBYTE left_shift, PBYTE right_shift)
 
156
static void make_straight_abris (s_glue *GL, puchar left_shift, puchar right_shift)
158
157
{
159
 
    INT             i, j, y;
160
 
    BYTE            beg, end;
 
158
    int16_t             i, j, y;
 
159
    uchar            beg, end;
161
160
    interval        *cur_int;
162
161
    lnhead          *Line;
163
162
    cell            *WC;
170
169
  while ( (WC=GL->celist[j]) != NULL )
171
170
  {
172
171
    // set address of the first line
173
 
    Line = (lnhead *)(((PBYTE) (WC -> env)) + WC -> env -> lines + sizeof (INT));
 
172
    Line = (lnhead *)(((puchar) (WC -> env)) + WC -> env -> lines + sizeof (int16_t));
174
173
 
175
174
    while ( Line -> lth )        // loop for all lines
176
175
    {
190
189
 
191
190
            cur_int++;
192
191
        }
193
 
        Line = (lnhead *)( (PBYTE)Line + Line->lth );
 
192
        Line = (lnhead *)( (puchar)Line + Line->lth );
194
193
    }
195
194
   j++;
196
195
  }
197
196
}
198
197
 
199
198
/*********************
200
 
static INT upper_left_corner (PBYTE s_left, BYTE from, BYTE to, BYTE minst)
 
199
static int16_t upper_left_corner (puchar s_left, uchar from, uchar to, uchar minst)
201
200
{
202
 
    INT  dif;
203
 
    INT  st, prev, cur;
 
201
    int16_t  dif;
 
202
    int16_t  st, prev, cur;
204
203
 
205
204
 for ( st=0, cur=to-1, prev=to; ( cur>=from && st<minst ); prev--, cur-- )
206
205
  {
221
220
}
222
221
*******************/
223
222
 
224
 
static INT upper_right_corner (PBYTE s_right, BYTE from, BYTE to, BYTE minst)
 
223
static int16_t upper_right_corner (puchar s_right, uchar from, uchar to, uchar minst)
225
224
{
226
 
    INT dif;
227
 
    INT st, prev, cur;
 
225
    int16_t dif;
 
226
    int16_t st, prev, cur;
228
227
 
229
228
 for ( st=0, cur=to-1, prev=to; ( cur>=from && st<minst ); prev--, cur-- )
230
229
  {
244
243
}
245
244
 
246
245
 
247
 
static INT bottom_left_corner (PBYTE s_left, BYTE from, BYTE to, BYTE minst)
 
246
static int16_t bottom_left_corner (puchar s_left, uchar from, uchar to, uchar minst)
248
247
{
249
 
    INT  dif;
250
 
    INT  st, prev, cur;
 
248
    int16_t  dif;
 
249
    int16_t  st, prev, cur;
251
250
 
252
251
 for ( st=0, cur=from+1, prev=from; ( cur <= to && st<minst ); prev++, cur++ )
253
252
  {
269
268
 
270
269
 
271
270
/*****************
272
 
static INT bottom_right_corner (PBYTE s_right, BYTE from, BYTE to, BYTE minst)
 
271
static int16_t bottom_right_corner (puchar s_right, uchar from, uchar to, uchar minst)
273
272
{
274
 
    INT  dif;
275
 
    INT  st, prev, cur;
 
273
    int16_t  dif;
 
274
    int16_t  st, prev, cur;
276
275
 
277
276
 for ( st=0, cur=from+1, prev=from; ( cur <= to && st<minst ); prev++, cur++ )
278
277
  {
293
292
}
294
293
******************/
295
294
 
296
 
static void comp_parms( BYTE fullh )
 
295
static void comp_parms( uchar fullh )
297
296
{
298
297
 
299
298
  if ( (fullh < 40) && (fullh > 24) )
309
308
void comp_row_col( s_glue *GL )
310
309
{
311
310
cell * curc;
312
 
INT j;
 
311
int16_t j;
313
312
 
314
313
  maxrow = maxcol = -32000;
315
314
  minrow = mincol = 32767;
324
323
   j++;
325
324
  }
326
325
 GL->height = maxrow - minrow;
327
 
 comp_h = (BYTE)GL->height;
 
326
 comp_h = (uchar)GL->height;
328
327
 GL->width = maxcol - mincol;
329
328
}
330
329
 
331
 
INT n_around_ur_corner ( s_glue *GL )
 
330
int16_t n_around_ur_corner ( s_glue *GL )
332
331
{
333
 
 BYTE from, to, np;
334
 
 INT ret_pen;
 
332
 uchar from, to, np;
 
333
 int16_t ret_pen;
335
334
 
336
335
  ret_pen = 0;
337
 
  comp_parms ( (BYTE)GL->height );
 
336
  comp_parms ( (uchar)GL->height );
338
337
  from = GL->height - end_zone + 1;
339
338
  to = GL->height - 1 - beg_zone;
340
339
 
345
344
  return ret_pen;
346
345
}
347
346
 
348
 
INT u_around_bl_corner ( s_glue *GL )
 
347
int16_t u_around_bl_corner ( s_glue *GL )
349
348
{
350
 
 BYTE from, to, np;
351
 
 INT ret_pen;
 
349
 uchar from, to, np;
 
350
 int16_t ret_pen;
352
351
 
353
 
  comp_parms ( (BYTE)GL->height );
 
352
  comp_parms ( (uchar)GL->height );
354
353
  from = beg_zone;
355
354
  to = end_zone;
356
355
 
363
362
 
364
363
}
365
364
 
366
 
static BOOL is_italic()
 
365
static Bool is_italic()
367
366
{
368
 
BYTE h14, i;
369
 
INT lmax, xmax;
 
367
uchar h14, i;
 
368
int16_t lmax, xmax;
370
369
 
371
370
 h14 =(comp_h>>2);
372
371
 for ( xmax=h14, lmax=0, i=h14; i < comp_h - 2; i++ )
391
390
 
392
391
static void compare_corners_mass()
393
392
{
394
 
INT  d;
 
393
int16_t  d;
395
394
 
396
395
 d = mBOX[2] - mBOX[12];
397
396
 if ( d > 0 )
406
405
  }
407
406
}
408
407
 
409
 
static INT left_right_dist()
 
408
static int16_t left_right_dist()
410
409
{
411
 
INT lmd, rmd, h14;
412
 
BYTE j;
 
410
int16_t lmd, rmd, h14;
 
411
uchar j;
413
412
 
414
413
   h14 = (comp_h >> 2);
415
 
   lmd = func_mode_val( str_left, (BYTE)h14, (BYTE)(comp_h - h14));
 
414
   lmd = func_mode_val( str_left, (uchar)h14, (uchar)(comp_h - h14));
416
415
   lmd -= CONST_PLUS;
417
 
   rmd = func_mode_val( str_right, (BYTE)h14, (BYTE)(comp_h - h14));
 
416
   rmd = func_mode_val( str_right, (uchar)h14, (uchar)(comp_h - h14));
418
417
   j = abs(lmd - rmd);
419
418
   if ( j > LRD_PEN_NUM ) j = LRD_PEN_NUM;
420
419
   return pen_for_left_right_dist[j];
421
420
}
422
421
 
423
 
static INT func_mode_val( PBYTE func, BYTE from, BYTE to)
 
422
static int16_t func_mode_val( puchar func, uchar from, uchar to)
424
423
{
425
 
INT ans;
426
 
INT i, j, maxv;
427
 
BYTE counts[128];
 
424
int16_t ans;
 
425
int16_t i, j, maxv;
 
426
uchar counts[128];
428
427
 
429
428
  memset ( counts, 0, sizeof( counts ) );
430
429