summaryrefslogtreecommitdiff
path: root/Build/source/texk/ttf2pt1/app/X11/t1-xf86.39.patch
blob: 44d32ce57f1fa5cc7446bf2064cca7642f359ca1 (plain)
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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
*** scanfont.c	1999/12/27 00:34:02	1.1
--- scanfont.c	1999/12/27 00:35:34
***************
*** 2234,2239 ****
--- 2234,2241 ----
      /* 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--;
*** paths.c	1999/12/27 00:37:01	1.1
--- paths.c	1999/12/27 00:37:43
***************
*** 583,589 ****
                 CONCAT(before, r);
                 r = before;
         }
!        else
                 r->context = after->context;
         if (after != NULL)
                 CONCAT(r, after);
--- 583,589 ----
                 CONCAT(before, r);
                 r = before;
         }
!        else if (after != NULL)
                 r->context = after->context;
         if (after != NULL)
                 CONCAT(r, after);
*** type1.c	1999/12/27 00:38:16	1.1
--- type1.c	1999/12/27 01:08:02
***************
*** 399,412 ****
    /* 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;
      }
--- 399,414 ----
    /* 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;
      }
***************
*** 414,420 ****
      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;
      }
--- 416,422 ----
      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;
      }
*** t1io.c	2000/01/01 00:41:44	1.1
--- t1io.c	2000/01/01 01:23:38
***************
*** 78,83 ****
--- 78,86 ----
  /* 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();
***************
*** 118,123 ****
--- 121,127 ----
    of->flags = 0;
    of->error = 0;
    haveextrach = 0;
+   T1FileSize = 0;
    return &TheFile;
  } /* end Open */
   
***************
*** 196,202 ****
--- 200,212 ----
  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 */
***************
*** 381,386 ****
--- 391,397 ----
      }
    }
    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 */
*** t1stdio.h	2000/01/01 00:43:38	1.1
--- t1stdio.h	2000/01/01 01:24:19
***************
*** 73,78 ****
--- 73,79 ----
  
  extern FILE *T1Open(), *T1eexec();
  extern int T1Close(), T1Ungetc(), T1Read();
+ extern int T1FileSize;
   
  #undef fclose
  #undef fopen
*** fontfcn.c	2000/01/01 00:07:54	1.1
--- fontfcn.c	2000/01/01 01:36:02
***************
*** 57,62 ****
--- 57,63 ----
  #endif
  #include "t1imager.h"
  #include "util.h"
+ #include "t1stdio.h"
  #ifdef BUILDCID
  #include "range.h"
  #include "fontmisc.h"
***************
*** 300,333 ****
    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 */
  #ifdef BUILDCID
      /* xfree(vm_base); */
  #else
      xfree(vm_base);
  #endif
      if (!(initFont(vm_size * 2))) {
        /* we are really out of memory */
        return(SCAN_OUT_OF_MEMORY);
        }
      resetFont(env);
      rcode = scan_font(FontP);
- #ifdef BUILDCID
-     /* only double the memory twice, then report error */
-     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);
-     }
- #else
-     /* only double the memory once, then report error */
- #endif
    }
    return(rcode);
  }
--- 301,342 ----
    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 */
  #ifdef BUILDCID
      /* xfree(vm_base); */
  #else
      xfree(vm_base);
  #endif
+     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 ) {
+ #ifdef BUILDCID
+     /* xfree(vm_base); */
+ #else
+     xfree(vm_base);
+ #endif
      if (!(initFont(vm_size * 2))) {
        /* we are really out of memory */
        return(SCAN_OUT_OF_MEMORY);
        }
      resetFont(env);
      rcode = scan_font(FontP);
    }
    return(rcode);
  }
*** util.h	2000/01/01 00:40:11	1.1
--- util.h	2000/01/01 01:29:18
***************
*** 83,88 ****
--- 83,92 ----
  #else
  #define VM_SIZE               (50*1024)
  #endif
+ 
+ /* this is the maximal permitted memory size */
+ #define VM_SIZE_MAX           (1024*1024)
+ 
  /***================================================================***/
   
  #ifndef MIN