/* ----- init_ps ------- */ void init_ps (FILE *fp, char *str, int is_epsf, float bx1, float by1, float bx2, float by2) { time_t ltime; char tstr[41]; int i; if (is_epsf) { if (vb>=8) printf("Open EPS file with title \"%s\"\n", str); fprintf (fp, "%%!PS-Adobe-3.0 EPSF-3.0\n"); fprintf (fp, "%%%%BoundingBox: %.0f %.0f %.0f %.0f\n", bx1,by1,bx2,by2); } else { if (vb>=8) printf("Open PS file with title \"%s\"\n", str); fprintf (fp, "%%!PS-Adobe-3.0\n"); } /* Title */ fprintf (fp, "%%%%Title: %s\n", str); /* CreationDate */ time(<ime); strcpy (tstr, ctime(<ime)); tstr[24]='\0'; tstr[16]='\0'; fprintf (fp, "%%%%Creator: abctab2ps %s.%s\n", VERSION, REVISION); fprintf (fp, "%%%%CreationDate: %s %s\n", tstr+4,tstr+20); /* Author */ if (!noauthor) fprintf (fp, "%%%%For: %s\n", get_real_user_name().c_str()); if (PS_LEVEL == 2) fprintf (fp, "%%%%LanguageLevel: 2\n"); if (!is_epsf) fprintf (fp, "%%%%Pages: (atend)\n"); fprintf (fp, "%%%%EndComments\n\n"); if (is_epsf) fprintf (fp, "gsave /origstate save def mark\n100 dict begin\n\n"); fprintf (fp, "%%%%BeginSetup\n"); if (PS_LEVEL < 2) level1_fix (fp); if (vb>=7) printf ("\nDefining ISO fonts in file header:\n"); for (i=0;i<nfontnames;i++) { define_font (fp,fontnames[i],i); if (vb>=7) printf (" F%d %s\n", i,fontnames[i]); } define_symbols (fp); fprintf (fp, "\n/T {translate} bind def\n/M {moveto} bind def\n"); fprintf (fp, "\n0 setlinecap 0 setlinejoin 0.8 setlinewidth\n"); fprintf (fp, "%%%%EndSetup\n"); file_initialized=1; }
/* -- initialize the postscript file (PS or EPS) -- */ static void init_ps(char *str) { time_t ltime; unsigned i; char version[32]; if (epsf) { cur_lmarg = min_lmarg - 10; fprintf(fout, "%%!PS-Adobe-2.0 EPSF-2.0\n" "%%%%BoundingBox: 0 0 %.0f %.0f\n", ((p_fmt->landscape ? p_fmt->pageheight : p_fmt->pagewidth) - cur_lmarg - max_rmarg + 10) * PPI_96_72, -bposy * PPI_96_72); marg_init(); } else { if (!fout) open_fout(); fprintf(fout, "%%!PS-Adobe-2.0\n"); fprintf(fout, "%%%%BoundingBox: 0 0 %.0f %.0f\n", p_fmt->pagewidth * PPI_96_72, p_fmt->pageheight * PPI_96_72); } fprintf(fout, "%%%%Title: %s\n", str); time(<ime); #ifndef WIN32 strftime(tex_buf, TEX_BUF_SZ, "%b %e, %Y %H:%M", localtime(<ime)); #else strftime(tex_buf, TEX_BUF_SZ, "%b %#d, %Y %H:%M", localtime(<ime)); #endif fprintf(fout, "%%%%Creator: abcm2ps-" VERSION "\n" "%%%%CreationDate: %s\n", tex_buf); if (!epsf) fprintf(fout, "%%%%Pages: (atend)\n"); fprintf(fout, "%%%%LanguageLevel: 3\n" "%%%%EndComments\n" "%%CommandLine:"); for (i = 1; i < (unsigned) s_argc; i++) { char *p, *q; int space; p = s_argv[i]; space = strchr(p, ' ') != NULL || strchr(p, '\n') != NULL; fputc(' ', fout); if (space) fputc('\'', fout); for (;;) { q = strchr(p, '\n'); if (!q) break; fprintf(fout, " %.*s\n%%", (int) (q - p), p); p = q + 1; } fprintf(fout, "%s", p); if (space) fputc('\'', fout); } fprintf(fout, "\n\n"); if (epsf) fprintf(fout, "save\n"); strcpy(version, "/creator [(abcm2ps) " VERSION "] def"); for (i = 0; i < strlen(version); i++) { if (version[i] == '.') version[i] = ' '; } fprintf(fout, "%%%%BeginSetup\n" "/!{bind def}bind def\n" "/bdef{bind def}!\n" /* for compatibility */ "/T/translate load def\n" "/M/moveto load def\n" "/RM/rmoveto load def\n" "/L/lineto load def\n" "/RL/rlineto load def\n" "/C/curveto load def\n" "/RC/rcurveto load def\n" "/SLW/setlinewidth load def\n" "/defl 0 def\n" /* decoration flags - see deco.c for values */ "/dlw{0.7 SLW}!\n" "%s\n", version); define_symbols(); output = fprintf; user_ps_write(); define_fonts(); if (!epsf) fprintf(fout, "/setpagedevice where{pop\n" " <</PageSize[%.0f %.0f]>>setpagedevice}if\n", p_fmt->pagewidth * PPI_96_72, p_fmt->pageheight * PPI_96_72); fprintf(fout, "%%%%EndSetup\n"); file_initialized = 1; }