2
Copyright (c) 1993-2008, Cognitive Technologies
5
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½,
6
ļæ½ļæ½ļæ½ ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½:
8
* ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
9
ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
10
ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½.
11
* ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½/ļæ½ļæ½ļæ½ ļæ½
12
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
13
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½
14
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½.
15
* ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ Cognitive Technologies, ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½
16
ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½/ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
17
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½, ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
18
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½.
20
ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½/ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ "ļæ½ļæ½ļæ½
21
ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½" ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½-ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½,
22
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ ļæ½ļæ½
23
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½. ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
24
ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½/ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½
25
ļæ½ļæ½ŃØļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½
26
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
27
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ (ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½,
28
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½/ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½-ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½
29
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½/ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½,
30
ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½), ļæ½ļæ½ ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½, ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½
31
ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½ ļæ½ ļæ½ļæ½ļæ½ļæ½ļæ½ļæ½.
33
Redistribution and use in source and binary forms, with or without modification,
34
are permitted provided that the following conditions are met:
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.
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.
59
/*********************************************************************/
61
/* module CORNERS - studies corners of the component(s) */
63
/*********************************************************************/
73
#define CONST_PLUS 10 // this constant is added abris values in order
74
// to avoid negative values caused by shifting
75
#define AVOID_PRYSCH 3
77
/************** all function prototypes ***********************************/
78
INT u_around_bl_corner ( s_glue * );
79
INT n_around_ur_corner ( s_glue * );
80
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();
87
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();
91
/*************************************************************************/
97
BYTE l_tab_shift[128]; // the tables of shifts ( avoiding italic
98
BYTE r_tab_shift[128]; // and oblique )
101
static INT pen_for_staires[ST_PEN_NUM+1] = { 0, 14, 36, 60, 72, 120 };
102
#define LRD_PEN_NUM 7
103
static INT pen_for_left_right_dist[LRD_PEN_NUM+1] =
104
{ 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;
113
void discrim_un( cell *GC, s_glue *GL, INT cod_let )
117
memset ( l_tab_shift, 0, sizeof (l_tab_shift) );
118
memset ( r_tab_shift, 0, sizeof (r_tab_shift) );
120
pen_u = 0; pen_n = 0; un_code = (BYTE)cod_let;
122
comp_row_col( GL ); // compute coordinates of the composed box
123
// check italic incline of the component
126
if ( ((GC->font|GC->font_new) & c_fp_it) && (GL->ncell == 1) ) return;
128
make_straight_abris( GL, l_tab_shift, r_tab_shift );
133
{ compare_corners_mass(); goto ApplyPenalty;}
136
if ( cod_let & Let_n )
138
pen_n = n_around_ur_corner(GL); // study right upper corner against arounding
139
pen_n += left_right_dist();
141
if ( cod_let & Let_u )
142
pen_u = u_around_bl_corner(GL); // study left bottom corner against arounding
147
cell_bonus_let(GC, 'u', (INT)(-(pen_u)) );
152
cell_bonus_let(GC, 'n', (INT)(-(pen_n)) );
157
static void make_straight_abris (s_glue *GL, PBYTE left_shift, PBYTE right_shift)
165
// initialize both arraies
166
memset (str_left, 255, sizeof (str_left));
167
memset (str_right, 255, sizeof (str_right));
170
while ( (WC=GL->celist[j]) != NULL )
172
// set address of the first line
173
Line = (lnhead *)(((PBYTE) (WC -> env)) + WC -> env -> lines + sizeof (INT));
175
while ( Line -> lth ) // loop for all lines
177
y = maxrow - WC->row - (Line -> row) - 1; // uppermost y-coordinate
178
cur_int = (interval *)(Line + 1); // first interval
180
for ( i = y; (cur_int -> l > 0 ); i--) // loop for all intervals
182
beg = cur_int->e - cur_int->l + CONST_PLUS;
183
beg = WC->col - mincol + ( beg - left_shift[i] );
184
if ( beg < str_left[i] )
187
end = maxcol - WC->col - ( cur_int->e + right_shift[i] );
188
if ( end < str_right[i] )
193
Line = (lnhead *)( (PBYTE)Line + Line->lth );
199
/*********************
200
static INT upper_left_corner (PBYTE s_left, BYTE from, BYTE to, BYTE minst)
205
for ( st=0, cur=to-1, prev=to; ( cur>=from && st<minst ); prev--, cur-- )
207
if ( s_left[prev] - s_left[cur] > AVOID_PRYSCH )
208
{ st = 0; continue; }
209
dif = s_left[cur] - s_left[prev];
217
if ( dif == 0 ) continue;
224
static INT upper_right_corner (PBYTE s_right, BYTE from, BYTE to, BYTE minst)
229
for ( st=0, cur=to-1, prev=to; ( cur>=from && st<minst ); prev--, cur-- )
231
if ( s_right[prev] - s_right[cur] > AVOID_PRYSCH )
232
{ st = 0; continue; }
233
dif = s_right[cur] - s_right[prev];
240
if ( dif == 0 ) continue;
247
static INT bottom_left_corner (PBYTE s_left, BYTE from, BYTE to, BYTE minst)
252
for ( st=0, cur=from+1, prev=from; ( cur <= to && st<minst ); prev++, cur++ )
254
if ( s_left[prev] - s_left[cur] > AVOID_PRYSCH )
255
{ st = 0; continue; }
256
dif = s_left[cur] - s_left[prev];
264
if ( dif == 0 ) continue;
272
static INT bottom_right_corner (PBYTE s_right, BYTE from, BYTE to, BYTE minst)
277
for ( st=0, cur=from+1, prev=from; ( cur <= to && st<minst ); prev++, cur++ )
279
if ( s_right[prev] - s_right[cur] > AVOID_PRYSCH )
280
{ st = 0; continue; }
281
dif = s_right[cur] - s_right[prev];
289
if ( dif == 0 ) continue;
296
static void comp_parms( BYTE fullh )
299
if ( (fullh < 40) && (fullh > 24) )
300
{ num_st = 4; beg_zone = 0; end_zone = (fullh)/3; }
301
if ( (fullh <= 24) && (fullh >15) )
302
{ num_st = 3; beg_zone = 0; end_zone = (fullh)/3 + 1; }
304
{ num_st = 2; beg_zone = 0; end_zone = (fullh)/3; }
306
{ num_st = 5; beg_zone = 1; end_zone =(fullh)/3; }
309
void comp_row_col( s_glue *GL )
314
maxrow = maxcol = -32000;
315
minrow = mincol = 32767;
318
while ( (curc = GL->celist[j]) != NULL )
320
if (mincol > curc->col) mincol=curc->col;
321
if (minrow > curc->row) minrow=curc->row;
322
if (maxrow < (curc->row + curc->h)) maxrow=curc->row+curc->h;
323
if (maxcol < (curc->col+curc->w)) maxcol=curc->col+curc->w;
326
GL->height = maxrow - minrow;
327
comp_h = (BYTE)GL->height;
328
GL->width = maxcol - mincol;
331
INT n_around_ur_corner ( s_glue *GL )
337
comp_parms ( (BYTE)GL->height );
338
from = GL->height - end_zone + 1;
339
to = GL->height - 1 - beg_zone;
341
ret_pen = upper_right_corner( str_right, from, to, num_st );
342
np = num_st - ret_pen;
343
if ( np > ST_PEN_NUM ) np = ST_PEN_NUM;
344
ret_pen = pen_for_staires[np];
348
INT u_around_bl_corner ( s_glue *GL )
353
comp_parms ( (BYTE)GL->height );
357
ret_pen = bottom_left_corner( str_left, from, to, num_st );
358
np = num_st - ret_pen;
359
if ( np > ST_PEN_NUM ) np = ST_PEN_NUM;
360
ret_pen = pen_for_staires[np];
366
static BOOL is_italic()
372
for ( xmax=h14, lmax=0, i=h14; i < comp_h - 2; i++ )
374
if ( str_left[i+1] - str_left[i] > 3 ) // big gap to right is forbidden
376
if ( lmax < str_left[i] )
377
{ lmax = str_left[i]; xmax = i; }
380
if ( str_left[xmax] - str_left[h14] > 2 )
382
if ( str_left[xmax] - str_left[h14] == 0 )
384
for ( i=h14; i <= xmax; i++ )
386
if ( str_left[i] > str_left[i+1] )
392
static void compare_corners_mass()
396
d = mBOX[2] - mBOX[12];
399
if ( un_code & Let_u )
400
pen_u += ( (d+1)>>1 ) & 0xfe;
404
if ( un_code & Let_n )
405
pen_n += ( (abs(d)+1)>>1 ) & 0xfe;
409
static INT left_right_dist()
415
lmd = func_mode_val( str_left, (BYTE)h14, (BYTE)(comp_h - h14));
417
rmd = func_mode_val( str_right, (BYTE)h14, (BYTE)(comp_h - h14));
419
if ( j > LRD_PEN_NUM ) j = LRD_PEN_NUM;
420
return pen_for_left_right_dist[j];
423
static INT func_mode_val( PBYTE func, BYTE from, BYTE to)
429
memset ( counts, 0, sizeof( counts ) );
431
for ( maxv=0, i=from; i < to; i++ )
435
if ( maxv < j ) maxv = j;
437
for ( ans=0, j=0, i=0; i <= maxv; i++ )
440
{ j = counts[i]; ans = i; }