1 /* Copyright (c) 1997-1998 by Juliusz Chroboczek */
10 #include "libc-extension.hh"
12 #define CHUNKSIZE 65534
19 (gnt[i].name.index==0?NULL:macGlyphEncoding[gnt[i].name.index]):\
21 ((i)<258?macGlyphEncoding[i]:NULL)))
25 printPSFont (FILE * out, struct HeadTable *ht,
26 char **strings, int nglyphs, int postType,
27 struct PostTable *pt, struct GlyphName *gnt, int fd)
29 printPSHeader (out, ht, strings, pt);
30 printPSData (out, fd);
31 printPSTrailer (out, nglyphs, postType, gnt);
35 printPSHeader (FILE * out, struct HeadTable *ht,
36 char **strings, struct PostTable *pt)
38 fprintf (out, "%%!PS-TrueTypeFont\n");
40 fprintf (out, "%%%%VMUsage: %ld %ld\n", pt->minMemType42,
42 fprintf (out, "%d dict begin\n", 11);
43 fprintf (out, "/FontName /%s def\n", strings[6] ? strings[6] : "Unknown");
44 fprintf (out, "/Encoding StandardEncoding def\n");
45 fprintf (out, "/PaintType 0 def\n/FontMatrix [1 0 0 1 0 0] def\n");
46 fprintf (out, "/FontBBox [%ld %ld %ld %ld] def\n",
47 ht->xMin * 1000L / ht->unitsPerEm,
48 ht->yMin * 1000L / ht->unitsPerEm,
49 ht->xMax * 1000L / ht->unitsPerEm,
50 ht->yMax * 1000L / ht->unitsPerEm);
51 fprintf (out, "/FontType 42 def\n");
52 fprintf (out, "/FontInfo 8 dict dup begin\n");
53 fprintf (out, "/version (%d.%d) def\n",
54 ht->fontRevision.mantissa, ht->fontRevision.fraction);
57 fprintf (out, "/Notice (");
58 fputpss (strings[0], out);
59 fprintf (out, ") def\n");
63 fprintf (out, "/FullName (");
64 fputpss (strings[4], out);
65 fprintf (out, ") def\n");
69 fprintf (out, "/FamilyName (");
70 fputpss (strings[1], out);
71 fprintf (out, ") def\n");
73 fprintf (out, "/isFixedPitch %s def\n",
74 pt->isFixedPitch ? "true" : "false");
75 fprintf (out, "/UnderlinePosition %ld def\n",
76 pt->underlinePosition * 1000L / ht->unitsPerEm);
77 fprintf (out, "/UnderlineThickness %ld def\n",
78 pt->underlineThickness * 1000L / ht->unitsPerEm);
79 fprintf (out, "end readonly def\n");
83 printPSData (FILE * out, int fd)
85 static char xdigits[] = "0123456789ABCDEF";
87 unsigned char *buffer;
90 surely_lseek (fd, 0, SEEK_SET);
92 buffer = mymalloc (CHUNKSIZE);
94 fprintf (out, "/sfnts [");
97 i = read (fd, buffer, CHUNKSIZE);
100 fprintf (out, "\n<");
101 for (j = 0; j < i; j++)
103 if (j != 0 && j % 36 == 0)
105 /* fprintf(out,"%02X",(int)buffer[j]) is too slow */
106 putc (xdigits[(buffer[j] & 0xF0) >> 4], out);
107 putc (xdigits[buffer[j] & 0x0F], out);
109 fprintf (out, "00>"); /* Adobe bug? */
113 fprintf (out, "\n] def\n");
118 printPSTrailer (FILE * out, int nglyphs, int postType, struct GlyphName *gnt)
123 fprintf (out, "/CharStrings %d dict dup begin\n", nglyphs);
127 for (n = i = 0; i < nglyphs; i++)
129 if (n != 0 && n % 4 == 0)
134 fprintf (out, "/%s %d def ", name, i);
144 "No glyph name table; assuming MacGlyphEncoding\n");
146 for (i = 0; i < 258 && i < nglyphs; i++)
148 fprintf (out, "/%s %d def ", macGlyphEncoding[i], i);
149 if (i != 0 && i % 4 == 0)
154 fprintf (out, "end readonly def\n");
155 fprintf (out, "FontName currentdict end definefont pop\n");