#define PS_MAXWIDTH 255
static void ps_comment(FILE *fp, char const *leader, word *words);
-static void ps_token(FILE *fp, int *cc, char const *fmt, ...);
static void ps_string_len(FILE *fp, int *cc, char const *str, int len);
static void ps_string(FILE *fp, int *cc, char const *str);
fprintf(fp, "%%%%DocumentNeededResources:\n");
for (fe = doc->fonts->head; fe; fe = fe->next)
/* XXX This may request the same font multiple times. */
- if (!fe->font->info->fp)
+ if (!fe->font->info->fontfile)
fprintf(fp, "%%%%+ font %s\n", fe->font->info->name);
- fprintf(fp, "%%%%DocumentSuppliedResources: procset Halibut 0 2\n");
+ fprintf(fp, "%%%%DocumentSuppliedResources: procset Halibut 0 3\n");
for (fe = doc->fonts->head; fe; fe = fe->next)
/* XXX This may request the same font multiple times. */
- if (fe->font->info->fp)
+ if (fe->font->info->fontfile)
fprintf(fp, "%%%%+ font %s\n", fe->font->info->name);
fprintf(fp, "%%%%EndComments\n");
fprintf(fp, "%%%%BeginProlog\n");
- fprintf(fp, "%%%%BeginResource: procset Halibut 0 2\n");
+ fprintf(fp, "%%%%BeginResource: procset Halibut 0 3\n");
/*
* Supply a prologue function which allows a reasonably
* compressed representation of the text on the pages.
* "p" generates a named destination referencing this page.
* "x" generates a link to a named destination.
* "u" generates a link to a URI.
+ * "o" generates an outline entry.
+ * "m" generates a general pdfmark.
*
* They all do nothing if pdfmark is undefined.
*/
" /u { 2 dict dup /Subtype /URI put dup /URI 4 -1 roll put\n"
" [ /Action 3 -1 roll /Rect 5 -1 roll /Border [0 0 0]\n"
" /Subtype /Link /ANN pdfmark } bind def\n"
- "} {\n"
+ " /o { [ /Count 3 -1 roll /Dest 5 -1 roll /Title 7 -1 roll\n"
+ " /OUT pdfmark } bind def\n"
+ " /m /pdfmark load def\n"
+ "}\n");
+ fprintf(fp, "{\n"
" /p { pop } bind def\n"
" /x { pop pop } bind def\n"
" /u /x load def\n"
+ " /o { pop pop pop } bind def\n"
+ " /m /cleartomark load def\n"
"} ifelse\n");
fprintf(fp, "%%%%EndResource\n");
doc->paper_height / FUNITS_PER_PT);
ps_token(fp, &cc, "} if\n");
- /* Outline etc, only if pdfmark is supported */
- ps_token(fp, &cc, "/pdfmark where { pop %% if\n");
- ps_token(fp, &cc, " [/PageMode/UseOutlines/DOCVIEW pdfmark\n");
+ ps_token(fp, &cc, "[/PageMode/UseOutlines/DOCVIEW m\n");
noe = doc->n_outline_elements;
for (oe = doc->outline_elements; noe; oe++, noe--) {
char *title;
title = pdf_outline_convert(oe->pdata->outline_title, &titlelen);
if (oe->level == 0) {
- ps_token(fp, &cc, " [/Title");
+ ps_token(fp, &cc, "[/Title");
ps_string_len(fp, &cc, title, titlelen);
- ps_token(fp, &cc, "/DOCINFO pdfmark\n");
+ ps_token(fp, &cc, "/DOCINFO m\n");
}
count = 0;
count++;
if (oe->level > 0) count = -count;
- ps_token(fp, &cc, " [/Title");
ps_string_len(fp, &cc, title, titlelen);
sfree(title);
- ps_token(fp, &cc, "/Dest%s/Count %d/OUT pdfmark\n",
+ ps_token(fp, &cc, "%s %d o\n",
(char *)oe->pdata->first->page->spare, count);
}
- ps_token(fp, &cc, "} if\n");
for (fe = doc->fonts->head; fe; fe = fe->next) {
/* XXX This may request the same font multiple times. */
- if (fe->font->info->fp) {
- char buf[512];
- size_t len;
+ if (fe->font->info->fontfile) {
fprintf(fp, "%%%%BeginResource: font %s\n", fe->font->info->name);
- rewind(fe->font->info->fp);
- do {
- len = fread(buf, 1, sizeof(buf), fe->font->info->fp);
- fwrite(buf, 1, len, fp);
- } while (len == sizeof(buf));
+ if (fe->font->info->filetype == TYPE1)
+ pf_writeps(fe->font->info, fp);
+ else
+ sfnt_writeps(fe->font->info, fp);
fprintf(fp, "%%%%EndResource\n");
} else {
fprintf(fp, "%%%%IncludeResource: font %s\n",
ps_token(fp, &cc, "{1 index /FID ne {def} {pop pop} ifelse} forall\n");
ps_token(fp, &cc, "/Encoding [\n");
for (i = 0; i < 256; i++)
- ps_token(fp, &cc, "/%s",
- fe->vector[i] ? fe->vector[i] : ".notdef");
+ ps_token(fp, &cc, "/%s", glyph_extern(fe->vector[i]));
ps_token(fp, &cc, "] def\n");
ps_token(fp, &cc, "currentdict end\n");
ps_token(fp, &cc, "/fontname-%s exch definefont /%s exch def\n",
fprintf(fp, "\n");
}
-static void ps_token(FILE *fp, int *cc, char const *fmt, ...) {
+void ps_token(FILE *fp, int *cc, char const *fmt, ...) {
va_list ap;
va_start(ap, fmt);