1 /* Copyright (c) 1997-1998 by Juliusz Chroboczek */
10 #define ALIAS_FILE_TO_FILECOOKIE
12 #include "libc-extension.hh"
14 #define CHUNKSIZE 65534
21 (gnt[i].name.index==0?NULL:macGlyphEncoding[gnt[i].name.index]):\
23 ((i)<258?macGlyphEncoding[i]:NULL)))
27 printPSFont (FILE * out, struct HeadTable *ht,
28 char **strings, int nglyphs, int postType,
29 struct PostTable *pt, struct GlyphName *gnt, int fd)
31 printPSHeader (out, ht, strings, pt);
32 printPSData (out, fd);
33 printPSTrailer (out, nglyphs, postType, gnt);
37 printPSHeader (FILE * out, struct HeadTable *ht,
38 char **strings, struct PostTable *pt)
40 fprintf (out, "%%!PS-TrueTypeFont\n");
42 fprintf (out, "%%%%VMUsage: %ld %ld\n", pt->minMemType42,
44 fprintf (out, "%d dict begin\n", 11);
45 fprintf (out, "/FontName /%s def\n", strings[6] ? strings[6] : "Unknown");
46 fprintf (out, "/Encoding StandardEncoding def\n");
47 fprintf (out, "/PaintType 0 def\n/FontMatrix [1 0 0 1 0 0] def\n");
48 fprintf (out, "/FontBBox [%ld %ld %ld %ld] def\n",
49 ht->xMin * 1000L / ht->unitsPerEm,
50 ht->yMin * 1000L / ht->unitsPerEm,
51 ht->xMax * 1000L / ht->unitsPerEm,
52 ht->yMax * 1000L / ht->unitsPerEm);
53 fprintf (out, "/FontType 42 def\n");
54 fprintf (out, "/FontInfo 8 dict dup begin\n");
55 fprintf (out, "/version (%d.%d) def\n",
56 ht->fontRevision.mantissa, ht->fontRevision.fraction);
59 fprintf (out, "/Notice (");
60 fputpss (strings[0], out);
61 fprintf (out, ") def\n");
65 fprintf (out, "/FullName (");
66 fputpss (strings[4], out);
67 fprintf (out, ") def\n");
71 fprintf (out, "/FamilyName (");
72 fputpss (strings[1], out);
73 fprintf (out, ") def\n");
75 fprintf (out, "/isFixedPitch %s def\n",
76 pt->isFixedPitch ? "true" : "false");
77 fprintf (out, "/UnderlinePosition %ld def\n",
78 pt->underlinePosition * 1000L / ht->unitsPerEm);
79 fprintf (out, "/UnderlineThickness %ld def\n",
80 pt->underlineThickness * 1000L / ht->unitsPerEm);
81 fprintf (out, "end readonly def\n");
85 printPSData (FILE * out, int fd)
87 static char xdigits[] = "0123456789ABCDEF";
89 unsigned char *buffer;
92 surely_lseek (fd, 0, SEEK_SET);
94 buffer = mymalloc (CHUNKSIZE);
96 fprintf (out, "/sfnts [");
99 i = read (fd, buffer, CHUNKSIZE);
102 fprintf (out, "\n<");
103 for (j = 0; j < i; j++)
105 if (j != 0 && j % 36 == 0)
107 /* fprintf(out,"%02X",(int)buffer[j]) is too slow */
108 putc (xdigits[(buffer[j] & 0xF0) >> 4], out);
109 putc (xdigits[buffer[j] & 0x0F], out);
111 fprintf (out, "00>"); /* Adobe bug? */
115 fprintf (out, "\n] def\n");
120 printPSTrailer (FILE * out, int nglyphs, int postType, struct GlyphName *gnt)
125 fprintf (out, "/CharStrings %d dict dup begin\n", nglyphs);
129 for (n = i = 0; i < nglyphs; i++)
131 if (n != 0 && n % 4 == 0)
136 fprintf (out, "/%s %d def ", name, i);
146 "No glyph name table; assuming MacGlyphEncoding\n");
148 for (i = 0; i < 258 && i < nglyphs; i++)
150 fprintf (out, "/%s %d def ", macGlyphEncoding[i], i);
151 if (i != 0 && i % 4 == 0)
156 fprintf (out, "end readonly def\n");
157 fprintf (out, "FontName currentdict end definefont pop\n");