2
2
Copyright (c) 1993-2008, Cognitive Technologies
5
����������� ��������� ��������������� � ������������� ��� � ���� ��������� ����,
6
��� � � �������� �����, � ����������� ��� ���, ��� ���������� ��������� �������:
8
* ��� ��������� ��������������� ��������� ���� ������ ���������� ���������
9
���� ����������� �� ��������� �����, ���� ������ ������� � �����������
11
* ��� ��������� ��������������� ��������� ���� � ������������ �/��� �
12
������ ����������, ������������ ��� ���������������, ������ �����������
13
��������� ���� ���������� �� ��������� �����, ���� ������ ������� �
14
����������� ����� �� ��������.
15
* �� �������� Cognitive Technologies, �� ����� �� ����������� �� �����
16
���� ������������ � �������� �������� ��������� �/��� �����������
17
���������, ���������� �� ���� ��, ��� ���������������� �����������
20
��� ��������� ������������� ����������� ��������� ���� �/��� ������� ������ "���
21
��� ����" ��� ������-���� ���� ��������, ���������� ���� ��� ���������������,
22
������� �������� ������������ �������� � ����������� ��� ���������� ����, �� ��
23
������������� ���. �� �������� ��������� ���� � �� ���� ������ ����, �������
24
����� �������� �/��� �������� �������������� ���������, �� � ���� ������ ��
25
��Ѩ� ���������������, ������� ����� �����, ���������, ����������� ���
26
������������� ������, ��������� � �������������� ��� ���������� ����������
27
������������� ������������� ��������� (������� ������ ������, ��� ������,
28
������� ���������, ��� ������ �/��� ������ �������, ���������� ��-�� ��������
29
������� ��� �/��� ������ ��������� �������� ��������� � ������� �����������,
30
�� �� ������������� ����� ��������), �� �� ������������� ���, ���� ���� �����
31
�������� ��� ������ ���� ���� �������� � ����������� ����� ������� � ������.
5
Разрешается повторное распространение и использование как в виде исходного кода,
6
так и в двоичной форме, с изменениями или без, при соблюдении следующих условий:
8
* При повторном распространении исходного кода должны оставаться указанное
9
выше уведомление об авторском праве, этот список условий и последующий
11
* При повторном распространении двоичного кода в документации и/или в
12
других материалах, поставляемых при распространении, должны сохраняться
13
указанная выше информация об авторском праве, этот список условий и
14
последующий отказ от гарантий.
15
* Ни название Cognitive Technologies, ни имена ее сотрудников не могут
16
быть использованы в качестве средства поддержки и/или продвижения
17
продуктов, основанных на этом ПО, без предварительного письменного
20
ЭТА ПРОГРАММА ПРЕДОСТАВЛЕНА ВЛАДЕЛЬЦАМИ АВТОРСКИХ ПРАВ И/ИЛИ ДРУГИМИ ЛИЦАМИ "КАК
21
ОНА ЕСТЬ" БЕЗ КАКОГО-ЛИБО ВИДА ГАРАНТИЙ, ВЫРАЖЕННЫХ ЯВНО ИЛИ ПОДРАЗУМЕВАЕМЫХ,
22
ВКЛЮЧАЯ ГАРАНТИИ КОММЕРЧЕСКОЙ ЦЕННОСТИ И ПРИГОДНОСТИ ДЛЯ КОНКРЕТНОЙ ЦЕЛИ, НО НЕ
23
ОГРАНИЧИВАЯСЬ ИМИ. НИ ВЛАДЕЛЕЦ АВТОРСКИХ ПРАВ И НИ ОДНО ДРУГОЕ ЛИЦО, КОТОРОЕ
24
МОЖЕТ ИЗМЕНЯТЬ И/ИЛИ ПОВТОРНО РАСПРОСТРАНЯТЬ ПРОГРАММУ, НИ В КОЕМ СЛУЧАЕ НЕ
25
НЕСЁТ ОТВЕТСТВЕННОСТИ, ВКЛЮЧАЯ ЛЮБЫЕ ОБЩИЕ, СЛУЧАЙНЫЕ, СПЕЦИАЛЬНЫЕ ИЛИ
26
ПОСЛЕДОВАВШИЕ УБЫТКИ, СВЯЗАННЫЕ С ИСПОЛЬЗОВАНИЕМ ИЛИ ПОНЕСЕННЫЕ ВСЛЕДСТВИЕ
27
НЕВОЗМОЖНОСТИ ИСПОЛЬЗОВАНИЯ ПРОГРАММЫ (ВКЛЮЧАЯ ПОТЕРИ ДАННЫХ, ИЛИ ДАННЫЕ,
28
СТАВШИЕ НЕГОДНЫМИ, ИЛИ УБЫТКИ И/ИЛИ ПОТЕРИ ДОХОДОВ, ПОНЕСЕННЫЕ ИЗ-ЗА ДЕЙСТВИЙ
29
ТРЕТЬИХ ЛИЦ И/ИЛИ ОТКАЗА ПРОГРАММЫ РАБОТАТЬ СОВМЕСТНО С ДРУГИМИ ПРОГРАММАМИ,
30
НО НЕ ОГРАНИЧИВАЯСЬ ЭТИМИ СЛУЧАЯМИ), НО НЕ ОГРАНИЧИВАЯСЬ ИМИ, ДАЖЕ ЕСЛИ ТАКОЙ
31
ВЛАДЕЛЕЦ ИЛИ ДРУГОЕ ЛИЦО БЫЛИ ИЗВЕЩЕНЫ О ВОЗМОЖНОСТИ ТАКИХ УБЫТКОВ И ПОТЕРЬ.
33
33
Redistribution and use in source and binary forms, with or without modification,
34
34
are permitted provided that the following conditions are met:
75
73
#define INCL_FAC 2048
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;
81
79
Bool32 p2_Line2Raster(c_comp *comp, RecRaster *rec);
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
// р с т у ф х ц ч ш щ ъ ы ь э ю
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'а
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);
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)
531
int16_t h,H8=H/8,H3=H/3;
537
for (line=(lnhead *)((PCHAR)(env)+env->lines+sizeof(INT));
535
for (line=(lnhead *)((pchar)(env)+env->lines+sizeof(int16_t));
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)
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;
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)
633
int16_t h,H8=H/8,H3=H/3;
639
for (line=(lnhead *)((PCHAR)(env)+env->lines+sizeof(INT));
637
for (line=(lnhead *)((pchar)(env)+env->lines+sizeof(int16_t));
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)
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;
648
646
i=H8+1; //from line top
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;
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;
765
763
static void ideal2rc(Point16 *p)
768
p->y=y+(INT)((LONG)nIncline*p->x/2048);
769
p->x=p->x-(INT)((LONG)nIncline*y/2048);
766
p->y=y+(int16_t)((int32_t)nIncline*p->x/2048);
767
p->x=p->x-(int16_t)((int32_t)nIncline*y/2048);
772
static void bound_cell(cell *c, Word32 color)
770
static void bound_cell(cell *c, uint32_t color)
775
773
Point16 pa={c->col,c->row},pb={c->col+c->w-1,c->row+c->h-1};