45 #define TRMFLT( a ) ( ( fabs( a ) < 5.0e-4 ) ? 0.0 : ( a ) ) 51 "ps:PostScript File (monochrome):0:ps:29:ps\n" 54 "psc:PostScript File (color):0:ps:30:psc\n" 71 static void esc_purge(
unsigned char *,
unsigned char * );
73 const char *menustr,
const char *devnam,
75 #define OUTBUF_LEN 128 83 {
"hrshsym",
DRV_INT, &
hrshsym,
"Use Hershey symbol set (hrshsym=0|1)" },
84 { NULL,
DRV_INT, NULL, NULL } };
89 const int number_of_entries );
100 const char *menustr,
const char *devnam,
103 #ifndef ENABLE_DYNDRIVERS 126 "PostScript File (monochrome)",
"ps",
148 #endif //#ifdef PLD_ps 154 "PostScript File (color)",
"psc",
170 #endif //#ifdef PLD_psc 187 if ( pls->
xdpi <= 0 )
189 if ( pls->
ydpi <= 0 )
215 if ( pls->
dev != NULL )
216 free( (
void *) pls->
dev );
218 pls->
dev = calloc( 1, (
size_t)
sizeof (
PSDev ) );
219 if ( pls->
dev == NULL )
220 plexit(
"ps_init: Out of memory." );
261 fprintf(
OF,
"%%!PS-Adobe-2.0 EPSF-2.0\n" );
262 fprintf(
OF,
"%%%%BoundingBox: \n" );
263 fprintf(
OF,
"%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n" );
265 fprintf(
OF,
"%%%%Title: PLplot Graph\n" );
268 fprintf(
OF,
"%%%%Pages: (atend)\n" );
269 fprintf(
OF,
"%%%%EndComments\n\n" );
274 fprintf(
OF,
"/PSSave save def\n" );
278 fprintf(
OF,
"/PSDict 200 dict def\n" );
279 fprintf(
OF,
"PSDict begin\n" );
281 fprintf(
OF,
"/@restore /restore load def\n" );
282 fprintf(
OF,
"/restore\n" );
283 fprintf(
OF,
" {vmstatus pop\n" );
284 fprintf(
OF,
" dup @VMused lt {pop @VMused} if\n" );
285 fprintf(
OF,
" exch pop exch @restore /@VMused exch def\n" );
286 fprintf(
OF,
" } def\n" );
287 fprintf(
OF,
"/@pri\n" );
288 fprintf(
OF,
" {\n" );
289 fprintf(
OF,
" ( ) print\n" );
290 fprintf(
OF,
" ( ) cvs print\n" );
291 fprintf(
OF,
" } def\n" );
295 fprintf(
OF,
"/@copies\n" );
296 fprintf(
OF,
" {\n" );
297 fprintf(
OF,
" /#copies exch def\n" );
298 fprintf(
OF,
" } def\n" );
302 fprintf(
OF,
"/@start\n" );
303 fprintf(
OF,
" {\n" );
304 fprintf(
OF,
" vmstatus pop /@VMused exch def pop\n" );
305 fprintf(
OF,
" } def\n" );
309 fprintf(
OF,
"/@end\n" );
310 fprintf(
OF,
" {flush\n" );
311 fprintf(
OF,
" end\n" );
312 fprintf(
OF,
" PSSave restore\n" );
313 fprintf(
OF,
" } def\n" );
318 fprintf(
OF,
"/bop\n" );
319 fprintf(
OF,
" {\n" );
320 fprintf(
OF,
" /SaveImage save def\n" );
321 fprintf(
OF,
" } def\n" );
325 fprintf(
OF,
"/eop\n" );
326 fprintf(
OF,
" {\n" );
327 fprintf(
OF,
" showpage\n" );
328 fprintf(
OF,
" SaveImage restore\n" );
329 fprintf(
OF,
" } def\n" );
333 fprintf(
OF,
"/@line\n" );
334 fprintf(
OF,
" {0 setlinecap\n" );
335 fprintf(
OF,
" 0 setlinejoin\n" );
336 fprintf(
OF,
" 1 setmiterlimit\n" );
337 fprintf(
OF,
" } def\n" );
341 fprintf(
OF,
"/@hsize {/hs exch def} def\n" );
342 fprintf(
OF,
"/@vsize {/vs exch def} def\n" );
346 fprintf(
OF,
"/@hoffset {/ho exch def} def\n" );
347 fprintf(
OF,
"/@voffset {/vo exch def} def\n" );
351 fprintf(
OF,
"/lw %d def\n", (
int) (
357 fprintf(
OF,
"/@SetPlot\n" );
358 fprintf(
OF,
" {\n" );
359 fprintf(
OF,
" ho vo translate\n" );
360 fprintf(
OF,
" XScale YScale scale\n" );
361 fprintf(
OF,
" lw setlinewidth\n" );
362 fprintf(
OF,
" } def\n" );
366 fprintf(
OF,
"/XScale\n" );
367 fprintf(
OF,
" {hs %d div} def\n",
YPSSIZE );
368 fprintf(
OF,
"/YScale\n" );
369 fprintf(
OF,
" {vs %d div} def\n",
XPSSIZE );
373 fprintf(
OF,
"/M {moveto} def\n" );
374 fprintf(
OF,
"/D {lineto} def\n" );
375 fprintf(
OF,
"/A {0.5 0 360 arc} def\n" );
376 fprintf(
OF,
"/S {stroke} def\n" );
377 fprintf(
OF,
"/Z {stroke newpath} def\n" );
382 fprintf(
OF,
"/F {closepath gsave eofill grestore stroke} def " );
384 fprintf(
OF,
"/F {closepath gsave fill grestore stroke} def " );
385 fprintf(
OF,
"/N {newpath} def" );
386 fprintf(
OF,
"/C {setrgbcolor} def\n" );
387 fprintf(
OF,
"/G {setgray} def\n" );
388 fprintf(
OF,
"/W {setlinewidth} def\n" );
389 fprintf(
OF,
"/SF {selectfont} def\n" );
390 fprintf(
OF,
"/R {rotate} def\n" );
391 fprintf(
OF,
"/SW {stringwidth 2 index mul exch 2 index mul exch rmoveto pop} bind def\n" );
392 fprintf(
OF,
"/B {Z %d %d M %d %d D %d %d D %d %d D %d %d closepath} def\n",
394 fprintf(
OF,
"/CL {newpath M D D D closepath clip} def\n" );
398 fprintf(
OF,
"end\n\n" );
402 fprintf(
OF,
"PSDict begin\n" );
403 fprintf(
OF,
"@start\n" );
404 fprintf(
OF,
"%d @copies\n",
COPIES );
405 fprintf(
OF,
"@line\n" );
406 fprintf(
OF,
"%d @hsize\n",
YSIZE );
407 fprintf(
OF,
"%d @vsize\n",
XSIZE );
411 fprintf(
OF,
"@SetPlot\n\n" );
424 PLINT x1 = x1a, y1 = y1a, x2 = x2a, y2 = y2a;
447 fprintf(
OF,
" Z\n" );
450 if ( x1 == x2 && y1 == y2 )
483 for ( i = 0; i < npts - 1; i++ )
484 plD_line_ps( pls, xa[i], ya[i], xa[i + 1], ya[i + 1] );
496 fprintf(
OF,
" S\neop\n" );
520 fprintf(
OF,
"%%%%Page: %d %d\n", (
int) pls->
page, 1 );
522 fprintf(
OF,
"%%%%Page: %d %d\n", (
int) pls->
page, (
int) pls->
page );
524 fprintf(
OF,
"bop\n" );
528 if ( pls->
cmap0[0].
r != 0xFF ||
529 pls->
cmap0[0].
g != 0xFF ||
536 fprintf(
OF,
"B %.4f %.4f %.4f C F\n", r, g, b );
559 fprintf(
OF,
"\n%%%%Trailer\n" );
577 fprintf(
OF,
"%%%%Pages: %d\n", (
int) 1 );
579 fprintf(
OF,
"%%%%Pages: %d\n", (
int) pls->
page );
581 fprintf(
OF,
"@end\n" );
582 fprintf(
OF,
"%%%%EOF\n" );
588 fprintf(
OF,
"%%!PS-Adobe-2.0 EPSF-2.0\n" );
589 fprintf(
OF,
"%%%%BoundingBox: %d %d %d %d\n",
612 fprintf(
OF,
" S\n%d W", width );
621 fprintf(
OF,
" S\n%.4f G", ( pls->
icol0 ? 0.0 : 1.0 ) );
624 fprintf(
OF,
" %d %d M \n", (
int) dev->
xold, (
int) dev->
yold );
635 fprintf(
OF,
" S\n%.4f %.4f %.4f C", r, g, b );
640 fprintf(
OF,
" S\n%.4f G", 1.0 - r );
644 fprintf(
OF,
" %d %d M \n", (
int) dev->
xold, (
int) dev->
yold );
680 PLINT n, ix = 0, iy = 0;
683 fprintf(
OF,
" Z\n" );
685 for ( n = 0; n < pls->
dev_npts; n++ )
687 x = pls->
dev_x[ix++];
688 y = pls->
dev_y[iy++];
730 fprintf(
OF,
" F " );
746 t = time( (time_t *) 0 );
748 len = (int) strlen( p );
749 *( p + len - 1 ) =
'\0';
760 # define RISE_FACTOR 0.6 774 PLFLT theta, shear, stride;
776 PLFLT cs, sn, l1, l2;
784 cur_str[PROC_STR_STRING_LENGTH];
785 float font_factor = 1.4f;
786 PLINT clxmin, clxmax, clymin, clymax;
787 PLINT clipx[4], clipy[4];
789 PLFLT scale = 1., up = 0.;
800 PLFLT old_sscale, sscale, old_soffset, soffset, ddup;
821 if ( ( f < PROC_STR_STRING_LENGTH ) && ( s + 3 < PROC_STR_STRING_LENGTH ) )
823 fci_save = cur_text[j];
824 fonts[f++] =
get_font( dev, fci_save );
825 cur_str[s++] = (
unsigned char) esc;
830 else if ( s + 4 < PROC_STR_STRING_LENGTH )
837 PLINT ifamily, istyle, iweight;
838 plgfont( &ifamily, &istyle, &iweight );
839 if ( 0 <= cur_text[j] && cur_text[j] < 256 )
840 cur_str[s++] = cur_text[j];
850 if ( cur_text[j] !=
' ' && cur_str[s] ==
' ' )
859 cur_str[s++] = (
unsigned char) esc;
869 fonts[f++] =
get_font( dev, fci_save );
870 cur_str[s++] = (
unsigned char) esc;
882 pldebug(
"proc_str",
"unicode = 0x%x, type 1 code = %d\n",
883 cur_text[j], cur_str[s - 1] );
894 ft_ht = pls->
chrht * 72.0 / 25.4;
901 tt[0] = t[0] * cs + t[2] * sn;
902 tt[1] = t[1] * cs + t[3] * sn;
903 tt[2] = -t[0] * sn + t[2] * cs;
904 tt[3] = -t[1] * sn + t[3] * cs;
918 if ( args->
base == 2 )
920 else if ( args->
base == 1 )
923 offset = -
ENLARGE * ft_ht / 2.;
927 args->
y += (
PLINT) ( offset * cos( theta ) );
928 args->
x -= (
PLINT) ( offset * sin( theta ) );
932 &( args->
x ), &( args->
y ) );
947 difilt( clipx, clipy, 4, &clxmin, &clxmax, &clymin, &clymax );
949 &clipx[0], &clipy[0] );
951 &clipx[1], &clipy[1] );
953 &clipx[2], &clipy[2] );
955 &clipx[3], &clipy[3] );
956 fprintf(
OF,
" gsave %d %d %d %d %d %d %d %d CL\n", clipx[0], clipy[0], clipx[1], clipy[1], clipx[2], clipy[2], clipx[3], clipy[3] );
959 fprintf(
OF,
" %d %d M\n", args->
x, args->
y );
962 fprintf(
OF,
"gsave %.3f R\n",
TRMFLT( theta * 180. /
PI ) );
971 fprintf(
OF,
"/%s %.3f SF\n", font,
TRMFLT( font_factor *
ENLARGE * ft_ht ) );
977 while ( str[i] !=
'\0' )
979 if ( str[i] ==
'(' || str[i] ==
')' || str[i] ==
'\\' )
980 fprintf(
OF,
"\\%c", str[i] );
982 fprintf(
OF,
"%c", str[i] );
985 fprintf(
OF,
") SW\n" );
996 if ( *cur_strp == esc )
1000 if ( *cur_strp == esc )
1002 *strp++ = *cur_strp++;
1004 else if ( *cur_strp ==
'f' )
1007 if ( *cur_strp++ !=
'f' )
1011 plabort(
"proc_str, internal PLplot logic error;" 1012 "wrong escf escape sequence" );
1016 pldebug(
"proc_str",
"string-specified fci = 0x%x, font name = %s\n", fci, font );
1020 switch ( *cur_strp++ )
1025 &old_sscale, &sscale, &old_soffset, &soffset );
1031 ddup = -0.5 * ( 1.0 - sscale );
1038 &old_sscale, &sscale, &old_soffset, &soffset );
1044 ddup = 0.5 * ( 1.0 - sscale );
1054 plwarn(
"'+', '-', and 'b/B' text escape sequences not processed." );
1062 while ( *cur_strp && *cur_strp != esc )
1064 if ( *cur_strp ==
'(' || *cur_strp ==
')' || *cur_strp ==
'\\' )
1066 *strp++ = *cur_strp++;
1070 if ( fabs( up ) < 0.001 )
1074 fprintf(
OF,
"/%s [%.3f %.3f %.3f %.3f 0 0] SF\n",
1084 fprintf(
OF,
"gsave %.3f %.3f rmoveto\n",
TRMFLT( up * tt[1] ),
TRMFLT( up * tt[3] ) );
1087 fprintf(
OF,
"(%s) show\n", str );
1091 fprintf(
OF,
"grestore (%s) stringwidth rmoveto\n", str );
1092 }
while ( *cur_strp );
1094 fprintf(
OF,
"grestore\n" );
1095 fprintf(
OF,
"grestore\n" );
1108 l1 = -i * args->
just;
1109 l2 = i * ( 1. - args->
just );
1115 dev->
llx = (int) (
MIN( dev->
llx, args->
x + (
MIN( l1 * cs, l2 * cs ) - 1.5 ) * font_factor * ft_ht *
ENLARGE ) );
1116 dev->
lly = (int) (
MIN( dev->
lly, args->
y + (
MIN( l1 * sn, l2 * sn ) - 1.5 ) * font_factor * ft_ht *
ENLARGE ) );
1117 dev->
urx = (int) (
MAX( dev->
urx, args->
x + (
MAX( l1 * cs, l2 * cs ) + 1.5 ) * font_factor * ft_ht * ENLARGE ) );
1118 dev->
ury = (int) (
MAX( dev->
ury, args->
y + (
MAX( l1 * sn, l2 * sn ) + 1.5 ) * font_factor * ft_ht * ENLARGE ) );
1171 static unsigned char 1176 int jlo = -1, jmid, jhi = nlookup;
1177 while ( jhi - jlo > 1 )
1183 jmid = ( jlo + jhi ) / 2;
1184 if ( index > lookup[jmid].Unicode )
1186 else if ( index < lookup[jmid].Unicode )
1192 return ( lookup[jmid].Type1 );
1229 pldebug(
"set_font",
"fci = 0x%x, font name = %s\n", fci, font );
int plParseDrvOpts(DrvOpt *acc_opt)
void plP_script_scale(PLBOOL ifupper, PLINT *level, PLFLT *old_scale, PLFLT *scale, PLFLT *old_offset, PLFLT *offset)
void plexit(PLCHAR_VECTOR errormsg)
PLDLLIMPEXP_DRIVER void plD_dispatch_init_psc(PLDispatchTable *pdt)
void plD_init_psc(PLStream *)
static const Unicode_to_Type1_table unicode_to_symbol_lookup_table[194]
const Unicode_to_Type1_table * lookup
void plOpenFile(PLStream *pls)
void plCloseFile(PLStream *pls)
static const int number_of_entries_in_unicode_to_standard_table
void plGetFam(PLStream *pls)
void(* plD_tidy_fp)(struct PLStream_struct *)
static void ps_init(PLStream *)
void plD_init_ps(PLStream *)
void plD_esc_ps(PLStream *pls, PLINT op, void *ptr)
void(* plD_init_fp)(struct PLStream_struct *)
static char * ps_getdate(void)
void(* plD_eop_fp)(struct PLStream_struct *)
void plabort(PLCHAR_VECTOR errormsg)
void plD_state_ps(PLStream *pls, PLINT op)
PLDLLIMPEXP_DRIVER void plD_dispatch_init_ps(PLDispatchTable *pdt)
void plFamInit(PLStream *pls)
static void ps_dispatch_init_helper(PLDispatchTable *pdt, const char *menustr, const char *devnam, int type, int seq, plD_init_fp init)
static const int number_of_entries_in_unicode_to_symbol_table
void(* plD_line_fp)(struct PLStream_struct *, short, short, short, short)
static unsigned char plunicode2type1(const PLUNICODE index, const Unicode_to_Type1_table lookup[], const int number_of_entries)
void(* plD_esc_fp)(struct PLStream_struct *, PLINT, void *)
void(* plD_polyline_fp)(struct PLStream_struct *, short *, short *, PLINT)
static const char * get_font(PSDev *dev, PLUNICODE fci)
void difilt(PLINT *xsc, PLINT *ysc, PLINT npts, PLINT *clpxmi, PLINT *clpxma, PLINT *clpymi, PLINT *clpyma)
void plD_tidy_ps(PLStream *pls)
static const FCI_to_FontName_Table Type1Lookup[N_Type1Lookup]
static void proc_str(PLStream *, EscText *)
void plP_setpxl(PLFLT xpmm, PLFLT ypmm)
void plD_line_ps(PLStream *pls, short x1a, short y1a, short x2a, short y2a)
#define PLDLLIMPEXP_DRIVER
static void fill_polygon(PLStream *pls)
static PLStream * pls[PL_NSTREAMS]
void plP_setphy(PLINT xmin, PLINT xmax, PLINT ymin, PLINT ymax)
void plRotationShear(PLFLT *xFormMatrix, PLFLT *rotation, PLFLT *shear, PLFLT *stride)
static void esc_purge(unsigned char *, unsigned char *)
unsigned short unicode_array_len
PLDLLIMPEXP_DRIVER const char * plD_DEVICE_INFO_ps
void plD_bop_ps(PLStream *pls)
void(* plD_bop_fp)(struct PLStream_struct *)
void plRotPhy(PLINT orient, PLINT xmin, PLINT ymin, PLINT xmax, PLINT ymax, PLINT *px, PLINT *py)
PLCHAR_VECTOR plP_FCI2FontName(PLUNICODE fci, const FCI_to_FontName_Table lookup[], const int nlookup)
void plwarn(PLCHAR_VECTOR errormsg)
static char outbuf[OUTBUF_LEN]
#define PROC_STR_STRING_LENGTH
static DrvOpt ps_options[]
void plD_polyline_ps(PLStream *pls, short *xa, short *ya, PLINT npts)
static const Unicode_to_Type1_table unicode_to_standard_lookup_table[154]
plD_polyline_fp pl_polyline
void(* plD_state_fp)(struct PLStream_struct *, PLINT)
PLUNICODE * unicode_array
void plD_eop_ps(PLStream *pls)