1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
*** fontfcn.c 2000/01/02 18:55:56 1.1
--- fontfcn.c 2000/01/02 19:00:17
***************
*** 33,38 ****
--- 33,39 ----
#include <string.h>
#include "t1imager.h"
#include "util.h"
+ #include "t1stdio.h"
#include "fontfcn.h"
#include "fontmisc.h"
***************
*** 117,132 ****
resetFont(env);
/* This will load the font into the FontP */
rcode = scan_font(FontP);
! if (rcode == SCAN_OUT_OF_MEMORY) {
/* free the memory and start again */
xfree(vm_base);
if (!(initFont(vm_size * 2))) {
/* we are really out of memory */
return(SCAN_OUT_OF_MEMORY);
}
resetFont(env);
rcode = scan_font(FontP);
- /* only double the memory once, then report error */
}
return(rcode);
}
--- 118,151 ----
resetFont(env);
/* This will load the font into the FontP */
rcode = scan_font(FontP);
! if (rcode != SCAN_OUT_OF_MEMORY)
! return rcode;
!
! if (T1FileSize > VM_SIZE) {
! /* use the file size as estimation */
!
/* free the memory and start again */
xfree(vm_base);
+ if (!(initFont(T1FileSize))) {
+ /* we are really out of memory */
+ return(SCAN_OUT_OF_MEMORY);
+ }
+ resetFont(env);
+ rcode = scan_font(FontP);
+ if (rcode != SCAN_OUT_OF_MEMORY)
+ return rcode;
+ }
+
+ /* if still not enough, increase up to maximum */
+ while (rcode == SCAN_OUT_OF_MEMORY
+ && vm_size <= VM_SIZE_MAX/2 ) {
+ xfree(vm_base);
if (!(initFont(vm_size * 2))) {
/* we are really out of memory */
return(SCAN_OUT_OF_MEMORY);
}
resetFont(env);
rcode = scan_font(FontP);
}
return(rcode);
}
*** paths.c 2000/01/02 18:55:56 1.1
--- paths.c 2000/01/02 18:56:27
***************
*** 584,590 ****
CONCAT(before, r);
r = before;
}
! else
r->context = after->context;
if (after != NULL)
CONCAT(r, after);
--- 584,590 ----
CONCAT(before, r);
r = before;
}
! else if (after != NULL)
r->context = after->context;
if (after != NULL)
CONCAT(r, after);
*** scanfont.c 2000/01/02 18:55:56 1.1
--- scanfont.c 2000/01/02 18:56:26
***************
*** 1383,1388 ****
--- 1383,1390 ----
/* point to name and search for leading blanks */
nameP= FontP->FontFileName.data.nameP;
namelen = FontP->FontFileName.len;
+ if (namelen > (128-1) ) /* prevent getting out of filename[] */
+ namelen = (128-1);
while (nameP[0] == ' ') {
nameP++;
namelen--;
*** t1io.c 2000/01/02 18:55:56 1.1
--- t1io.c 2000/01/02 18:56:32
***************
*** 54,59 ****
--- 54,62 ----
/* Our single FILE structure and buffer for this package */
STATIC F_FILE TheFile;
STATIC unsigned char TheBuffer[F_BUFSIZ];
+
+ /* the size of the file we read */
+ int T1FileSize;
/* Our routines */
F_FILE *T1Open(), *T1Eexec();
***************
*** 87,92 ****
--- 90,96 ----
of->flags = 0;
of->error = 0;
haveextrach = 0;
+ T1FileSize = 0;
return &TheFile;
} /* end Open */
***************
*** 165,171 ****
--- 169,181 ----
int T1Close(f) /* Close the file */
F_FILE *f; /* Stream descriptor */
{
+ int rc;
+
if (f->b_base == NULL) return 0; /* already closed */
+
+ while ( (rc = read(f->fd, f->b_base, F_BUFSIZ)) >0)
+ T1FileSize += rc; /* count the rest of the file */
+
f->b_base = NULL; /* no valid stream */
return close(f->fd);
} /* end Close */
***************
*** 289,294 ****
--- 299,305 ----
}
}
f->b_ptr = f->b_base;
+ T1FileSize += rc; /* remember how many bytes we have */
if (Decrypt) rc = T1Decrypt(f->b_base, rc);
return rc;
} /* end Fill */
*** type1.c 2000/01/02 18:55:56 1.1
--- type1.c 2000/01/02 18:56:27
***************
*** 365,378 ****
/* ADJUST STEM WIDTHS */
/**********************/
! widthdiff = 0.0;
/* Find standard stem with smallest width difference from this stem */
if (stems[stemno].vertical) { /* vertical stem */
if (blues->StdVW != 0) /* there is an entry for StdVW */
widthdiff = blues->StdVW - stemwidth;
for (i = 0; i < blues->numStemSnapV; ++i) { /* now look at StemSnapV */
! if (blues->StemSnapV[i] - stemwidth < widthdiff)
/* this standard width is the best match so far for this stem */
widthdiff = blues->StemSnapV[i] - stemwidth;
}
--- 365,380 ----
/* ADJUST STEM WIDTHS */
/**********************/
! /* a big value to not compete with StemSnap */
! /* if there is no StemSnap it will be caught later */
! widthdiff = onepixel*2;
/* Find standard stem with smallest width difference from this stem */
if (stems[stemno].vertical) { /* vertical stem */
if (blues->StdVW != 0) /* there is an entry for StdVW */
widthdiff = blues->StdVW - stemwidth;
for (i = 0; i < blues->numStemSnapV; ++i) { /* now look at StemSnapV */
! if ( FABS(blues->StemSnapV[i] - stemwidth) < FABS(widthdiff) )
/* this standard width is the best match so far for this stem */
widthdiff = blues->StemSnapV[i] - stemwidth;
}
***************
*** 380,386 ****
if (blues->StdHW != 0) /* there is an entry for StdHW */
widthdiff = blues->StdHW - stemwidth;
for (i = 0; i < blues->numStemSnapH; ++i) { /* now look at StemSnapH */
! if (blues->StemSnapH[i] - stemwidth < widthdiff)
/* this standard width is the best match so far for this stem */
widthdiff = blues->StemSnapH[i] - stemwidth;
}
--- 382,388 ----
if (blues->StdHW != 0) /* there is an entry for StdHW */
widthdiff = blues->StdHW - stemwidth;
for (i = 0; i < blues->numStemSnapH; ++i) { /* now look at StemSnapH */
! if ( FABS(blues->StemSnapH[i] - stemwidth) < FABS(widthdiff) )
/* this standard width is the best match so far for this stem */
widthdiff = blues->StemSnapH[i] - stemwidth;
}
|