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

« back to all changes in this revision

Viewing changes to cuneiform_src/Kern/rstr/src/il1tgh.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:
55
55
*/
56
56
 
57
57
 
58
 
static void comptorast (PBYTE raster, cell *C)
 
58
static void comptorast (puchar raster, cell *C)
59
59
{
60
60
    memcpy (raster, save_raster (C), ((C -> w + 7)/8) * C -> h);
61
61
}
62
62
 
63
63
static void make_hor_vert (cell *cl)
64
64
{
65
 
    INT             i, y;
 
65
    int16_t             i, y;
66
66
    interval        *c;
67
67
    struct statist  *h, *v;
68
68
 
69
69
    memset (hor,  0, sizeof (*hor)  * ((dx + 7) & 0xF8));
70
70
    memset (vert, 0, sizeof (*vert) * dy);
71
71
 
72
 
    c = (interval *)(((PBYTE) (cl -> env)) + cl -> env -> lines + sizeof (INT));
 
72
    c = (interval *)(((puchar) (cl -> env)) + cl -> env -> lines + sizeof (int16_t));
73
73
 
74
74
    while (((lnhead *) c) -> lth)
75
75
    {
92
92
            for (h = hor + c -> e - 1, i = c -> l; i > 0; i--, ((h--) -> sum)++)
93
93
            if (h -> sum)
94
94
            {
95
 
                if      (h -> bot >= y) h -> bot = (BYTE)y;
96
 
                else if (h -> top <= y) h -> top = (BYTE)y;
 
95
                if      (h -> bot >= y) h -> bot = (uchar)y;
 
96
                else if (h -> top <= y) h -> top = (uchar)y;
97
97
            }
98
98
            else
99
99
            {
100
 
                h -> top = h -> bot = (BYTE)y;
 
100
                h -> top = h -> bot = (uchar)y;
101
101
            }
102
102
            c ++;
103
103
            y --;
108
108
 
109
109
static void make_hist ()
110
110
{
111
 
    INT i;
 
111
    int16_t i;
112
112
 
113
113
    memset (hist [0], 0, MAX_HOR_IL1 * N_HIST);
114
114
    for (i = 0; i < dy; i++)
134
134
 
135
135
static void make_func ()
136
136
{
137
 
    INT i, m;
 
137
    int16_t i, m;
138
138
 
139
139
    memset (funcs [0], 0, MAX_NEW_FUNC * MAX_HOR_IL1);
140
140
    for (i = 0; i < dy; i++)    funcs [1][i] = dx - hist [3][i];
145
145
    for (i = 0; i < dy; i++)    funcs [5][i] = hist [1][i];
146
146
//    for (i = 0; i < dx; i++)    funcs [6][i] = hist [5][i];
147
147
//    for (i = 0; i < dx; i++)    funcs [7][i] = hist [6][i];
148
 
    m = gmax (hist [1], 0, (INT)(dy - 1));
 
148
    m = gmax (hist [1], 0, (int16_t)(dy - 1));
149
149
    for (i = 0; i < dy; i++)    funcs [8][i] = m - hist [1][i];
150
150
    nfunc = 8;
151
151
}
152
152
 
153
 
static INT line_width (PBYTE func, INT beg, INT end)
 
153
static int16_t line_width (puchar func, int16_t beg, int16_t end)
154
154
{
155
 
    INT i;
156
 
    INT max         = 0;
157
 
    INT gmax        = 0;
158
 
    INT lines_value = 0;
159
 
    INT count [MAX_HOR_IL1];
 
155
    int16_t i;
 
156
    int16_t max         = 0;
 
157
    int16_t gmax        = 0;
 
158
    int16_t lines_value = 0;
 
159
    int16_t count [MAX_HOR_IL1];
160
160
 
161
161
    memset (count, 0, sizeof (count));
162
162
    for (i = beg; i < end; i++)
174
174
    return lines_value;
175
175
}
176
176
 
177
 
static WORD integral (PBYTE func, INT from, INT to, INT threshold)
 
177
static uint16_t integral (puchar func, int16_t from, int16_t to, int16_t threshold)
178
178
{
179
 
    WORD  s;
180
 
    DWORD i;
 
179
    uint16_t  s;
 
180
    uint32_t i;
181
181
 
182
182
    s = 0;
183
 
    for (i = from; i <= (DWORD)to; i++)
 
183
    for (i = from; i <= (uint32_t)to; i++)
184
184
    s += MAX (0, func [i] - threshold);
185
185
    return s;
186
186
}
187
187
 
188
 
static INT gmax (PBYTE func, INT from, INT to)
 
188
static int16_t gmax (puchar func, int16_t from, int16_t to)
189
189
{
190
 
    WORD s;
191
 
    INT  i;
 
190
    uint16_t s;
 
191
    int16_t  i;
192
192
 
193
193
    s = 0;
194
194
    for (i = from; i <= to; i++)
196
196
    return s;
197
197
}
198
198
 
199
 
static INT gmin (PBYTE func, INT from, INT to)
 
199
static int16_t gmin (puchar func, int16_t from, int16_t to)
200
200
{
201
 
    WORD s;
202
 
    INT  i;
 
201
    uint16_t s;
 
202
    int16_t  i;
203
203
 
204
204
    s = MAX_HOR_IL1;
205
205
    for (i = from; i <= to; i++)
208
208
}
209
209
 
210
210
/*
211
 
static INT pure_hill (PBYTE func, INT from, INT to)
 
211
static int16_t pure_hill (puchar func, int16_t from, int16_t to)
212
212
{
213
213
 while (from != to)
214
214
  {
223
223
 return TRUE;
224
224
}
225
225
 
226
 
static INT flthll_1 ()
 
226
static int16_t flthll_1 ()
227
227
//
228
228
//      This procedure checks absence of hill on bottom one third
229
229
//      of letter and presence of it on top one third.
230
230
//
231
231
{
232
 
    INT beg, end;
233
 
    INT i1, i2;
234
 
    INT lw1;
235
 
    INT b1, b2;
 
232
    int16_t beg, end;
 
233
    int16_t i1, i2;
 
234
    int16_t lw1;
 
235
    int16_t b1, b2;
236
236
 
237
237
    beg = 0;
238
238
    end = dy - 1;
245
245
                                                                    return 1;
246
246
}
247
247
 
248
 
static INT flat_1()
 
248
static int16_t flat_1()
249
249
//
250
250
//      This procedure checks absence of hills on top and bottom
251
251
//      one thirds of letter.
252
252
//
253
253
{
254
 
    INT beg, end;
255
 
    INT i1, i2;
256
 
    INT lw1;
257
 
    INT b1, b2;
 
254
    int16_t beg, end;
 
255
    int16_t i1, i2;
 
256
    int16_t lw1;
 
257
    int16_t b1, b2;
258
258
 
259
259
    beg = 0;
260
260
    end = dy - 1;
268
268
                                                                    return 0;
269
269
}
270
270
 
271
 
static INT botserif (INT width, INT area)
 
271
static int16_t botserif (int16_t width, int16_t area)
272
272
{
273
 
    INT beg, end;
274
 
    INT i1, lw1;
 
273
    int16_t beg, end;
 
274
    int16_t i1, lw1;
275
275
 
276
276
    lw1 = line_width (hist [1], 0, dy * 5/10);
277
277
    beg = 0;
286
286
                                                return 0;
287
287
}
288
288
 
289
 
static INT topserif (INT width,INT area)
 
289
static int16_t topserif (int16_t width,int16_t area)
290
290
{
291
 
    INT beg, end;
292
 
    INT i1, lw1;
 
291
    int16_t beg, end;
 
292
    int16_t i1, lw1;
293
293
 
294
294
    lw1 = line_width (hist [1], dy * 5/10, dy - 1);
295
295
    beg = dy * (100 - width) / 100;
299
299
                                                    return 0;
300
300
}
301
301
 
302
 
static INT toprser ()
 
302
static int16_t toprser ()
303
303
{
304
 
    INT i, i1;
 
304
    int16_t i, i1;
305
305
 
306
306
    extremum (hist [4], 4, 0, dy - 1,
307
307
                line_width (hist [4], 0, dy - 1), YES, YES);
313
313
                                                return 0;
314
314
}
315
315
 
316
 
static INT toplser()
 
316
static int16_t toplser()
317
317
{
318
 
    INT i, i1;
 
318
    int16_t i, i1;
319
319
 
320
320
    extremum (hist [3], 3, 0, dy - 1,
321
321
                line_width (hist [3], 0, dy - 1), YES, YES);
328
328
}
329
329
*/
330
330
 
331
 
static INT vertsym (INT bound)
 
331
static int16_t vertsym (int16_t bound)
332
332
{
333
 
    if (gmax (funcs [3], (INT)(dy * 6 / 100), (INT)(dy * 94 / 100)) <= bound) return 1;
 
333
    if (gmax (funcs [3], (int16_t)(dy * 6 / 100), (int16_t)(dy * 94 / 100)) <= bound) return 1;
334
334
                                                                return 0;
335
335
}
336
336
 
337
 
static INT centrsym (INT bound)
 
337
static int16_t centrsym (int16_t bound)
338
338
{
339
 
    if (gmax (funcs [4], (INT)(dy * 6 / 100), (INT)(dy * 94 / 100)) <= bound) return 1;
 
339
    if (gmax (funcs [4], (int16_t)(dy * 6 / 100), (int16_t)(dy * 94 / 100)) <= bound) return 1;
340
340
                                                                return 0;
341
341
}
342
342
 
343
343
/*
344
 
static INT toplad (INT jump, INT percent)
 
344
static int16_t toplad (int16_t jump, int16_t percent)
345
345
//
346
346
//      This procedure checks left brim on top of letter.
347
347
//
348
348
{
349
 
    INT i, m, s;
350
 
    INT beg, end;
 
349
    int16_t i, m, s;
 
350
    int16_t beg, end;
351
351
 
352
352
    beg = dy * 67 / 100;
353
353
    end = dy - 1;
362
362
                                                return 0;
363
363
}
364
364
 
365
 
static INT botlad(INT jump,INT percent)
 
365
static int16_t botlad(int16_t jump,int16_t percent)
366
366
//
367
367
//      This procedure checks left brim on bottom of letter.
368
368
//
369
369
{
370
 
    INT i, m, s;
371
 
    INT beg, end;
 
370
    int16_t i, m, s;
 
371
    int16_t beg, end;
372
372
 
373
373
    beg = 0;
374
374
    end = dy * 33 / 100;
382
382
}
383
383
*/
384
384
 
385
 
static BOOL increase (PBYTE f, INT from, INT to)
 
385
static Bool increase (puchar f, int16_t from, int16_t to)
386
386
{
387
 
    INT i;
 
387
    int16_t i;
388
388
 
389
389
    for (i = from; i < to; i++)
390
390
        if (f [i] > f [i + 1])                  return FALSE;
393
393
}
394
394
 
395
395
/*
396
 
static BOOL decrease (PBYTE f, INT from, INT to)
 
396
static Bool decrease (puchar f, int16_t from, int16_t to)
397
397
//
398
398
//      This procedure checks function to be decreasing.
399
399
//
400
400
{
401
 
    INT i;
 
401
    int16_t i;
402
402
 
403
403
    for (i = from; i < to; i++)
404
404
        if (f [i] < f [i + 1])                  return FALSE;