Release 1.5.29.
[wine] / dlls / wineps.drv / type1.c
1 /*
2  *      PostScript driver Type1 font functions
3  *
4  *      Copyright 2002  Huw D M Davies for CodeWeavers
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include "config.h"
22 #include "wine/port.h"
23
24 #include <string.h>
25 #include <stdlib.h>
26 #include <stdarg.h>
27 #include <stdio.h>
28 #include <assert.h>
29
30 #include "windef.h"
31 #include "winbase.h"
32 #include "wingdi.h"
33 #include "winternl.h"
34
35 #include "psdrv.h"
36 #include "wine/debug.h"
37
38 WINE_DEFAULT_DEBUG_CHANNEL(psdrv);
39
40 struct tagTYPE1 {
41     DWORD glyph_sent_size;
42     BOOL *glyph_sent;
43     DWORD emsize;
44 };
45
46 #define GLYPH_SENT_INC 128
47
48 /* Type 1 font commands */
49 enum t1_cmds {
50     rlineto = 5,
51     rrcurveto = 8,
52     closepath = 9,
53     hsbw = 13,
54     endchar = 14,
55     rmoveto = 21
56 };
57
58
59 #define MS_MAKE_TAG( _x1, _x2, _x3, _x4 ) \
60           ( ( (DWORD)_x4 << 24 ) |     \
61             ( (DWORD)_x3 << 16 ) |     \
62             ( (DWORD)_x2 <<  8 ) |     \
63               (DWORD)_x1         )
64
65 #ifdef WORDS_BIGENDIAN
66 static inline WORD  get_be_word(const void *p)  { return *(WORD*)p; }
67 static inline DWORD get_be_dword(const void *p) { return *(DWORD*)p; }
68 #else
69 static inline WORD  get_be_word(const void *p)  { return RtlUshortByteSwap(*(WORD*)p); }
70 static inline DWORD get_be_dword(const void *p) { return RtlUlongByteSwap(*(DWORD*)p); }
71 #endif
72
73 TYPE1 *T1_download_header(PHYSDEV dev, char *ps_name, RECT *bbox, UINT emsize)
74 {
75     char *buf;
76     TYPE1 *t1;
77
78     static const char dict[] = /* name, emsquare, fontbbox */
79       "25 dict begin\n"
80       " /FontName /%s def\n"
81       " /Encoding 256 array 0 1 255{1 index exch /.notdef put} for def\n"
82       " /PaintType 0 def\n"
83       " /FontMatrix [1 %d div 0 0 1 %d div 0 0] def\n"
84       " /FontBBox [%d %d %d %d] def\n"
85       " /FontType 1 def\n"
86       " /Private 7 dict begin\n"
87       "  /RD {string currentfile exch readhexstring pop} def\n"
88       "  /ND {def} def\n"
89       "  /NP {put} def\n"
90       "  /MinFeature {16 16} def\n"
91       "  /BlueValues [] def\n"
92       "  /password 5839 def\n"
93       "  /lenIV -1 def\n"
94       " currentdict end def\n"
95       " currentdict dup /Private get begin\n"
96       "  /CharStrings 256 dict begin\n"
97       "   /.notdef 4 RD 8b8b0d0e ND\n"
98       "  currentdict end put\n"
99       " end\n"
100       "currentdict end dup /FontName get exch definefont pop\n";
101
102     t1 = HeapAlloc(GetProcessHeap(), 0, sizeof(*t1));
103     t1->emsize = emsize;
104
105     t1->glyph_sent_size = GLYPH_SENT_INC;
106     t1->glyph_sent = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
107                                t1->glyph_sent_size *
108                                sizeof(*(t1->glyph_sent)));
109
110     buf = HeapAlloc(GetProcessHeap(), 0, sizeof(dict) + strlen(ps_name) +
111                     100);
112
113     sprintf(buf, dict, ps_name, t1->emsize, t1->emsize,
114             bbox->left, bbox->bottom, bbox->right, bbox->top);
115
116     PSDRV_WriteSpool(dev, buf, strlen(buf));
117
118     HeapFree(GetProcessHeap(), 0, buf);
119     return t1;
120 }
121
122
123 typedef struct {
124   BYTE *str;
125   int len, max_len;
126 } STR;
127
128 static STR *str_init(int sz)
129 {
130   STR *str = HeapAlloc(GetProcessHeap(), 0, sizeof(*str));
131   str->max_len = sz;
132   str->str = HeapAlloc(GetProcessHeap(), 0, str->max_len);
133   str->len = 0;
134   return str;
135 }
136
137 static void str_free(STR *str)
138 {
139   HeapFree(GetProcessHeap(), 0, str->str);
140   HeapFree(GetProcessHeap(), 0, str);
141 }
142
143 static void str_add_byte(STR *str, BYTE b)
144 {
145     if(str->len == str->max_len) {
146         str->max_len *= 2;
147         str->str = HeapReAlloc(GetProcessHeap(), 0, str->str, str->max_len);
148     }
149     str->str[str->len++] = b;
150 }
151
152 static void str_add_num(STR *str, int num)
153 {
154     if(num <= 107 && num >= -107)
155         str_add_byte(str, num + 139);
156     else if(num >= 108 && num <= 1131) {
157         str_add_byte(str, ((num - 108) >> 8) + 247);
158         str_add_byte(str, (num - 108) & 0xff);
159     } else if(num <= -108 && num >= -1131) {
160         num = -num;
161         str_add_byte(str, ((num - 108) >> 8) + 251);
162         str_add_byte(str, (num - 108) & 0xff);
163     } else {
164         str_add_byte(str, 0xff);
165         str_add_byte(str, (num >> 24) & 0xff);
166         str_add_byte(str, (num >> 16) & 0xff);
167         str_add_byte(str, (num >> 8) & 0xff);
168         str_add_byte(str, (num & 0xff));
169     }
170 }
171
172 static void str_add_point(STR *str, POINT pt, POINT *curpos)
173 {
174     str_add_num(str, pt.x - curpos->x);
175     str_add_num(str, pt.y - curpos->y);
176     *curpos = pt;
177 }
178
179 static void str_add_cmd(STR *str, enum t1_cmds cmd)
180 {
181     str_add_byte(str, (BYTE)cmd);
182 }
183
184 static int str_get_bytes(STR *str, BYTE **b)
185 {
186   *b = str->str;
187   return str->len;
188 }
189
190 static BOOL get_hmetrics(HDC hdc, DWORD index, short *lsb, WORD *advance)
191 {
192     BYTE hhea[36];
193     WORD num_of_long;
194     BYTE buf[4];
195
196     *lsb = 0;
197     *advance = 0;
198
199     GetFontData(hdc, MS_MAKE_TAG('h','h','e','a'), 0, hhea, sizeof(hhea));
200     num_of_long = get_be_word(hhea + 34);
201
202     if(index < num_of_long)
203     {
204         if(GetFontData(hdc, MS_MAKE_TAG('h','m','t','x'), index * 4, buf, 4) != 4) return FALSE;
205         *advance = get_be_word(buf);
206         *lsb = (signed short)get_be_word(buf + 2);
207     }
208     else
209     {
210         if(GetFontData(hdc, MS_MAKE_TAG('h','m','t','x'), (num_of_long - 1) * 4, buf, 2) != 2) return FALSE;
211         *advance = get_be_word(buf);
212         if(GetFontData(hdc, MS_MAKE_TAG('h','m','t','x'), num_of_long * 4 + (index - num_of_long) * 2, buf, 2) != 2) return FALSE;
213         *lsb = (signed short)get_be_word(buf);
214     }
215
216     return TRUE;
217 }
218
219 static BOOL get_glyf_pos(HDC hdc, DWORD index, DWORD *start, DWORD *end)
220 {
221     DWORD len;
222     BYTE *head, *loca;
223     WORD loca_format;
224     BOOL ret = FALSE;
225
226     *start = *end = 0;
227
228     len = GetFontData(hdc, MS_MAKE_TAG('h','e','a','d'), 0, NULL, 0);
229     if (len == GDI_ERROR) return FALSE;
230     head = HeapAlloc(GetProcessHeap(), 0, len);
231     GetFontData(hdc, MS_MAKE_TAG('h','e','a','d'), 0, head, len);
232     loca_format = get_be_word(head + 50);
233
234     len = GetFontData(hdc, MS_MAKE_TAG('l','o','c','a'), 0, NULL, 0);
235     if (len == GDI_ERROR)
236     {
237         len = GetFontData(hdc, MS_MAKE_TAG('C','F','F',' '), 0, NULL, 0);
238         if (len != GDI_ERROR) FIXME( "CFF tables not supported yet\n" );
239         else ERR( "loca table not found\n" );
240         HeapFree(GetProcessHeap(), 0, head);
241         return FALSE;
242     }
243     loca = HeapAlloc(GetProcessHeap(), 0, len);
244     GetFontData(hdc, MS_MAKE_TAG('l','o','c','a'), 0, loca, len);
245
246     switch(loca_format) {
247     case 0:
248         *start = get_be_word(((WORD*)loca) + index);
249         *start <<= 1;
250         *end = get_be_word(((WORD*)loca) + index + 1);
251         *end <<= 1;
252         ret = TRUE;
253         break;
254     case 1:
255         *start = get_be_dword(((DWORD*)loca) + index);
256         *end = get_be_dword(((DWORD*)loca) + index + 1);
257         ret = TRUE;
258         break;
259     default:
260         ERR("Unknown loca_format %d\n", loca_format);
261     }
262
263     HeapFree(GetProcessHeap(), 0, loca);
264     HeapFree(GetProcessHeap(), 0, head);
265     return ret;
266 }
267
268
269 static BYTE *get_glyph_data(HDC hdc, DWORD index)
270 {
271     DWORD start, end, len;
272     BYTE *data;
273
274     if(!get_glyf_pos(hdc, index, &start, &end))
275         return NULL;
276
277     len = end - start;
278     if(!len) return NULL;
279
280     data = HeapAlloc(GetProcessHeap(), 0, len);
281     if(!data) return NULL;
282
283     if(GetFontData(hdc, MS_MAKE_TAG('g','l','y','f'), start, data, len) != len)
284     {
285         HeapFree(GetProcessHeap(), 0, data);
286         return NULL;
287     }
288     return data;
289 }
290
291 typedef struct
292 {
293     WORD num_conts;
294     WORD *end_pts; /* size_is(num_conts) */
295     BYTE *flags;   /* size_is(end_pts[num_conts - 1] + 1) */
296     POINT *pts;    /* size_is(end_pts[num_conts - 1] + 1) */
297     short lsb;
298     WORD advance;
299 } glyph_outline;
300
301 static inline WORD pts_in_outline(glyph_outline *outline)
302 {
303     WORD num_pts = 0;
304
305     if(outline->num_conts)
306         num_pts = outline->end_pts[outline->num_conts - 1] + 1;
307
308     return num_pts;
309 }
310
311 static BOOL append_glyph_outline(HDC hdc, DWORD index, glyph_outline *outline);
312
313 static BOOL append_simple_glyph(BYTE *data, glyph_outline *outline)
314 {
315     USHORT num_pts, start_pt = 0, ins_len;
316     WORD *end_pts;
317     int num_conts, start_cont, i;
318     BYTE *ptr;
319     int x, y;
320
321     start_cont = outline->num_conts;
322     start_pt = pts_in_outline(outline);
323
324     num_conts = get_be_word(data);
325
326     end_pts = (WORD*)(data + 10);
327     num_pts = get_be_word(end_pts + num_conts - 1) + 1;
328
329     ins_len = get_be_word(end_pts + num_conts);
330
331     ptr = (BYTE*)(end_pts + num_conts) + 2 + ins_len;
332
333     if(outline->num_conts)
334     {
335         outline->end_pts = HeapReAlloc(GetProcessHeap(), 0, outline->end_pts, (start_cont + num_conts) * sizeof(*outline->end_pts));
336         outline->flags   = HeapReAlloc(GetProcessHeap(), 0, outline->flags, start_pt + num_pts);
337         outline->pts     = HeapReAlloc(GetProcessHeap(), 0, outline->pts,  (start_pt + num_pts) * sizeof(*outline->pts));
338     }
339     else
340     {
341         outline->end_pts = HeapAlloc(GetProcessHeap(), 0, num_conts * sizeof(*outline->end_pts));
342         outline->flags   = HeapAlloc(GetProcessHeap(), 0, num_pts);
343         outline->pts     = HeapAlloc(GetProcessHeap(), 0, num_pts * sizeof(*outline->pts));
344     }
345
346     outline->num_conts += num_conts;
347
348     for(i = 0; i < num_conts; i++)
349         outline->end_pts[start_cont + i] = start_pt + get_be_word(end_pts + i);
350
351     for(i = 0; i < num_pts; i++)
352     {
353         outline->flags[start_pt + i] = *ptr;
354         if(*ptr & 8)
355         {
356             BYTE count = *++ptr;
357             while(count)
358             {
359                 i++;
360                 outline->flags[start_pt + i] = *(ptr - 1);
361                 count--;
362             }
363         }
364         ptr++;
365     }
366
367     x = 0;
368
369     for(i = 0; i < num_pts; i++)
370     {
371         INT delta;
372
373         delta = 0;
374         if(outline->flags[start_pt + i] & 2)
375         {
376             delta = *ptr++;
377             if((outline->flags[start_pt + i] & 0x10) == 0)
378                 delta = -delta;
379         }
380         else if((outline->flags[start_pt + i] & 0x10) == 0)
381         {
382             delta = (signed short)get_be_word(ptr);
383             ptr += 2;
384         }
385         x += delta;
386         outline->pts[start_pt + i].x = x;
387     }
388
389     y = 0;
390     for(i = 0; i < num_pts; i++)
391     {
392         INT delta;
393
394         delta = 0;
395         if(outline->flags[start_pt + i] & 4)
396         {
397             delta = *ptr++;
398             if((outline->flags[start_pt + i] & 0x20) == 0)
399                 delta = -delta;
400         }
401         else if((outline->flags[start_pt + i] & 0x20) == 0)
402         {
403             delta = (signed short)get_be_word(ptr);
404             ptr += 2;
405         }
406         y += delta;
407         outline->pts[start_pt + i].y = y;
408     }
409     return TRUE;
410 }
411
412 /* Some flags for composite glyphs.  See glyf table in OT spec */
413 #define ARG_1_AND_2_ARE_WORDS    (1L << 0)
414 #define ARGS_ARE_XY_VALUES       (1L << 1)
415 #define WE_HAVE_A_SCALE          (1L << 3)
416 #define MORE_COMPONENTS          (1L << 5)
417 #define WE_HAVE_AN_X_AND_Y_SCALE (1L << 6)
418 #define WE_HAVE_A_TWO_BY_TWO     (1L << 7)
419 #define USE_MY_METRICS           (1L << 9)
420
421 static BOOL append_complex_glyph(HDC hdc, const BYTE *data, glyph_outline *outline)
422 {
423     const BYTE *ptr = data;
424     WORD flags, index;
425     short arg1, arg2;
426     FLOAT scale_xx = 1, scale_xy = 0, scale_yx = 0, scale_yy = 1;
427     WORD start_pt, end_pt;
428
429     ptr += 10;
430     do
431     {
432         flags = get_be_word(ptr);
433         ptr += 2;
434         index = get_be_word(ptr);
435         ptr += 2;
436         if(flags & ARG_1_AND_2_ARE_WORDS)
437         {
438             arg1 = (short)get_be_word(ptr);
439             ptr += 2;
440             arg2 = (short)get_be_word(ptr);
441             ptr += 2;
442         }
443         else
444         {
445             arg1 = *(char*)ptr++;
446             arg2 = *(char*)ptr++;
447         }
448         if(flags & WE_HAVE_A_SCALE)
449         {
450             scale_xx = scale_yy = (FLOAT)(short)get_be_word(ptr) / 0x4000;
451             ptr += 2;
452         }
453         else if(flags & WE_HAVE_AN_X_AND_Y_SCALE)
454         {
455             scale_xx = (FLOAT)(short)get_be_word(ptr) / 0x4000;
456             ptr += 2;
457             scale_yy = (FLOAT)(short)get_be_word(ptr) / 0x4000;
458             ptr += 2;
459         }
460         else if(flags & WE_HAVE_A_TWO_BY_TWO)
461         {
462             scale_xx = (FLOAT)(short)get_be_word(ptr) / 0x4000;
463             ptr += 2;
464             scale_xy = (FLOAT)(short)get_be_word(ptr) / 0x4000;
465             ptr += 2;
466             scale_yx = (FLOAT)(short)get_be_word(ptr) / 0x4000;
467             ptr += 2;
468             scale_yy = (FLOAT)(short)get_be_word(ptr) / 0x4000;
469             ptr += 2;
470         }
471
472         start_pt = pts_in_outline(outline);
473         append_glyph_outline(hdc, index, outline);
474         end_pt = pts_in_outline(outline);
475
476         if (flags & (WE_HAVE_A_SCALE | WE_HAVE_AN_X_AND_Y_SCALE | WE_HAVE_A_TWO_BY_TWO))
477         {
478             WORD i;
479             TRACE("transform %f,%f,%f,%f of glyph %x\n", scale_xx, scale_xy, scale_yx, scale_yy, index);
480             for (i = start_pt; i < end_pt; i++)
481             {
482                 LONG x = outline->pts[i].x, y = outline->pts[i].y;
483                 outline->pts[i].x = x * scale_xx + y * scale_yx;
484                 outline->pts[i].y = x * scale_xy + y * scale_yy;
485             }
486         }
487
488         if((flags & ARGS_ARE_XY_VALUES) == 0)
489         {
490             WORD orig_pt = arg1, new_pt = arg2;
491             new_pt += start_pt;
492
493             if(orig_pt >= start_pt || new_pt >= end_pt) return FALSE;
494
495             arg1 = outline->pts[orig_pt].x - outline->pts[new_pt].x;
496             arg2 = outline->pts[orig_pt].y - outline->pts[new_pt].y;
497         }
498         while(start_pt < end_pt)
499         {
500             outline->pts[start_pt].x += arg1;
501             outline->pts[start_pt].y += arg2;
502             start_pt++;
503         }
504
505         if(flags & USE_MY_METRICS)
506             get_hmetrics(hdc, index, &outline->lsb, &outline->advance);
507
508     } while(flags & MORE_COMPONENTS);
509     return TRUE;
510 }
511
512 static BOOL append_glyph_outline(HDC hdc, DWORD index, glyph_outline *outline)
513 {
514     BYTE *glyph_data;
515     SHORT num_conts;
516
517     glyph_data = get_glyph_data(hdc, index);
518     if(!glyph_data) return TRUE;
519
520     num_conts = get_be_word(glyph_data);
521
522     if(num_conts == -1)
523         append_complex_glyph(hdc, glyph_data, outline);
524     else if(num_conts > 0)
525         append_simple_glyph(glyph_data, outline);
526
527     HeapFree(GetProcessHeap(), 0, glyph_data);
528     return TRUE;
529 }
530
531 static inline BOOL on_point(const glyph_outline *outline, WORD pt)
532 {
533     return outline->flags[pt] & 1;
534 }
535
536 BOOL T1_download_glyph(PHYSDEV dev, DOWNLOAD *pdl, DWORD index, char *glyph_name)
537 {
538     DWORD len;
539     WORD cur_pt, cont;
540     char *buf;
541     TYPE1 *t1;
542     STR *charstring;
543     BYTE *bytes;
544     POINT curpos;
545     glyph_outline outline;
546
547     static const char glyph_def_begin[] =
548       "/%s findfont dup\n"
549       "/Private get begin\n"
550       "/CharStrings get begin\n"
551       "/%s %d RD\n";
552     static const char glyph_def_end[] =
553       "ND\n"
554       "end end\n";
555
556     TRACE("%d %s\n", index, glyph_name);
557     assert(pdl->type == Type1);
558     t1 = pdl->typeinfo.Type1;
559
560     if(index < t1->glyph_sent_size) {
561         if(t1->glyph_sent[index])
562             return TRUE;
563     } else {
564         t1->glyph_sent_size = (index / GLYPH_SENT_INC + 1) * GLYPH_SENT_INC;
565         t1->glyph_sent = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
566                                       t1->glyph_sent,
567                                       t1->glyph_sent_size * sizeof(*(t1->glyph_sent)));
568     }
569
570     outline.num_conts = 0;
571     outline.flags = NULL;
572     outline.end_pts = NULL;
573     outline.pts = NULL;
574     get_hmetrics(dev->hdc, index, &outline.lsb, &outline.advance);
575
576     if(!append_glyph_outline(dev->hdc, index, &outline)) return FALSE;
577
578     charstring = str_init(100);
579     curpos.x = outline.lsb;
580     curpos.y = 0;
581
582     str_add_num(charstring, curpos.x);
583     str_add_num(charstring, outline.advance);
584     str_add_cmd(charstring, hsbw);
585
586     for(cur_pt = 0, cont = 0; cont < outline.num_conts; cont++)
587     {
588         POINT start_pos = outline.pts[cur_pt++];
589         WORD end_pt = outline.end_pts[cont];
590         POINT curve_pts[3] = {{0,0},{0,0},{0,0}};
591
592         str_add_point(charstring, start_pos, &curpos);
593         str_add_cmd(charstring, rmoveto);
594
595         for(; cur_pt <= end_pt; cur_pt++)
596         {
597             if(on_point(&outline, cur_pt))
598             {
599                 str_add_point(charstring, outline.pts[cur_pt], &curpos);
600                 str_add_cmd(charstring, rlineto);
601             }
602             else
603             {
604                 BOOL added_next = FALSE;
605
606                 /* temporarily store the start pt in curve_pts[0] */
607                 if(on_point(&outline, cur_pt - 1))
608                     curve_pts[0] = outline.pts[cur_pt - 1];
609                 else /* last pt was off curve too, so the previous curve's
610                         end pt was constructed */
611                     curve_pts[0] = curve_pts[2];
612
613                 if(cur_pt != end_pt)
614                 {
615                     if(on_point(&outline, cur_pt + 1))
616                     {
617                         curve_pts[2] = outline.pts[cur_pt + 1];
618                         added_next = TRUE;
619                     }
620                     else /* next pt is off curve too, so construct the end pt from the
621                             average of the two */
622                     {
623                         curve_pts[2].x = (outline.pts[cur_pt].x + outline.pts[cur_pt + 1].x + 1) / 2;
624                         curve_pts[2].y = (outline.pts[cur_pt].y + outline.pts[cur_pt + 1].y + 1) / 2;
625                     }
626                 }
627                 else /* last pt of the contour is off curve, so the end pt is the
628                         start pt of the contour */
629                     curve_pts[2] = start_pos;
630
631                 curve_pts[0].x = (curve_pts[0].x + 2 * outline.pts[cur_pt].x + 1) / 3;
632                 curve_pts[0].y = (curve_pts[0].y + 2 * outline.pts[cur_pt].y + 1) / 3;
633
634                 curve_pts[1].x = (curve_pts[2].x + 2 * outline.pts[cur_pt].x + 1) / 3;
635                 curve_pts[1].y = (curve_pts[2].y + 2 * outline.pts[cur_pt].y + 1) / 3;
636
637                 str_add_point(charstring, curve_pts[0], &curpos);
638                 str_add_point(charstring, curve_pts[1], &curpos);
639                 str_add_point(charstring, curve_pts[2], &curpos);
640                 str_add_cmd(charstring, rrcurveto);
641                 if(added_next) cur_pt++;
642             }
643         }
644         str_add_cmd(charstring, closepath);
645     }
646     str_add_cmd(charstring, endchar);
647
648     HeapFree(GetProcessHeap(), 0, outline.pts);
649     HeapFree(GetProcessHeap(), 0, outline.end_pts);
650     HeapFree(GetProcessHeap(), 0, outline.flags);
651
652     buf = HeapAlloc(GetProcessHeap(), 0, sizeof(glyph_def_begin) +
653                     strlen(pdl->ps_name) + strlen(glyph_name) + 100);
654
655     sprintf(buf, "%%%%glyph %04x\n", index);
656     PSDRV_WriteSpool(dev, buf, strlen(buf));
657
658     len = str_get_bytes(charstring, &bytes);
659     sprintf(buf, glyph_def_begin, pdl->ps_name, glyph_name, len);
660     PSDRV_WriteSpool(dev, buf, strlen(buf));
661     PSDRV_WriteBytes(dev, bytes, len);
662     sprintf(buf, glyph_def_end);
663     PSDRV_WriteSpool(dev, buf, strlen(buf));
664     str_free(charstring);
665
666     t1->glyph_sent[index] = TRUE;
667     HeapFree(GetProcessHeap(), 0, buf);
668     return TRUE;
669 }
670
671 void T1_free(TYPE1 *t1)
672 {
673     HeapFree(GetProcessHeap(), 0, t1->glyph_sent);
674     HeapFree(GetProcessHeap(), 0, t1);
675     return;
676 }