- t = time(NULL);
-
- printf("%%!PS-Adobe-3.0\n");
- printf("%%%%Creator: mandoc-%s\n", VERSION);
- printf("%%%%CreationDate: %s", ctime(&t));
- printf("%%%%DocumentData: Clean7Bit\n");
- printf("%%%%Orientation: Portrait\n");
- printf("%%%%Pages: (atend)\n");
- printf("%%%%PageOrder: Ascend\n");
- printf("%%%%DocumentMedia: Default %zu %zu 0 () ()\n",
- AFM2PNT(p, p->engine.ps.width),
- AFM2PNT(p, p->engine.ps.height));
- printf("%%%%DocumentNeededResources: font");
- for (i = 0; i < (int)TERMFONT__MAX; i++)
- printf(" %s", fonts[i].name);
- printf("\n%%%%EndComments\n");
-
- p->engine.ps.pscol = p->engine.ps.left;
- p->engine.ps.psrow = p->engine.ps.top;
- p->engine.ps.flags |= PS_NEWPAGE;
+ if (TERMTYPE_PS == p->type) {
+ width = AFM2PNT(p, p->ps->width);
+ height = AFM2PNT(p, p->ps->height);
+
+ ps_printf(p, "%%!PS-Adobe-3.0\n");
+ ps_printf(p, "%%%%DocumentData: Clean7Bit\n");
+ ps_printf(p, "%%%%Orientation: Portrait\n");
+ ps_printf(p, "%%%%Pages: (atend)\n");
+ ps_printf(p, "%%%%PageOrder: Ascend\n");
+ ps_printf(p, "%%%%DocumentMedia: man-%s %zu %zu 0 () ()\n",
+ p->ps->medianame, width, height);
+ ps_printf(p, "%%%%DocumentNeededResources: font");
+
+ for (i = 0; i < (int)TERMFONT__MAX; i++)
+ ps_printf(p, " %s", fonts[i].name);
+
+ ps_printf(p, "\n%%%%DocumentSuppliedResources: "
+ "procset MandocProcs 1.0 0\n");
+ ps_printf(p, "%%%%EndComments\n");
+ ps_printf(p, "%%%%BeginProlog\n");
+ ps_printf(p, "%%%%BeginResource: procset MandocProcs "
+ "10170 10170\n");
+ /* The font size is effectively hard-coded for now. */
+ ps_printf(p, "/fs %zu def\n", p->ps->scale);
+ for (i = 0; i < (int)TERMFONT__MAX; i++)
+ ps_printf(p, "/f%d { /%s fs selectfont } def\n",
+ i, fonts[i].name);
+ ps_printf(p, "/s { 3 1 roll moveto show } bind def\n");
+ ps_printf(p, "/c { exch currentpoint exch pop "
+ "moveto show } bind def\n");
+ ps_printf(p, "%%%%EndResource\n");
+ ps_printf(p, "%%%%EndProlog\n");
+ ps_printf(p, "%%%%BeginSetup\n");
+ ps_printf(p, "%%%%BeginFeature: *PageSize %s\n",
+ p->ps->medianame);
+ ps_printf(p, "<</PageSize [%zu %zu]>>setpagedevice\n",
+ width, height);
+ ps_printf(p, "%%%%EndFeature\n");
+ ps_printf(p, "%%%%EndSetup\n");
+ } else {
+ ps_printf(p, "%%PDF-1.1\n");
+ pdf_obj(p, 1);
+ ps_printf(p, "<<\n");
+ ps_printf(p, ">>\n");
+ ps_printf(p, "endobj\n");
+
+ for (i = 0; i < (int)TERMFONT__MAX; i++) {
+ pdf_obj(p, (size_t)i + 3);
+ ps_printf(p, "<<\n");
+ ps_printf(p, "/Type /Font\n");
+ ps_printf(p, "/Subtype /Type1\n");
+ ps_printf(p, "/Name /F%d\n", i);
+ ps_printf(p, "/BaseFont /%s\n", fonts[i].name);
+ ps_printf(p, ">>\nendobj\n");
+ }
+ }
+
+ p->ps->pdfbody = (size_t)TERMFONT__MAX + 3;
+ p->ps->pscol = p->ps->left;
+ p->ps->psrow = p->ps->top;
+ p->ps->flags |= PS_NEWPAGE;