/* * This file is part of abc2ps, * Copyright (C) 1996,1997,1998 Michael Methfessel * See file abc2ps.c for details. */ #include "abc2ps.h" #include "syms.h" /* subroutines to define postscript macros which draw symbols */ /* ----- def_misc ------- */ void def_misc (fp) FILE *fp; { fprintf (fp, "\n/cshow { %% usage: string cshow - center at current pt\n" " dup stringwidth pop 2 div neg 0 rmoveto\n" " bx {box} if show\n" "} bind def\n" "\n/lshow { %% usage: string lshow - show left-aligned\n" " dup stringwidth pop neg 0 rmoveto bx {box} if show\n" "} bind def\n" "\n/rshow { %% usage: string rshow - show right-aligned\n" " bx {box} if show\n" "} bind def\n" ); fprintf (fp, "\n/box { %% usage: str box - draw box around string\n" " gsave 0.5 setlinewidth dup stringwidth pop\n" " -2 -2 rmoveto 4 add fh 4 add 2 copy\n" " 0 exch rlineto 0 rlineto neg 0 exch rlineto neg 0 rlineto\n" " stroke grestore\n" "} bind def\n"); fprintf (fp, "\n/wd { moveto bx {box} if show } bind def\n" "/wln {\n" "dup 3 1 roll moveto gsave 0.6 setlinewidth lineto stroke grestore\n" "} bind def\n"); fprintf (fp, "/whf {moveto gsave 0.5 1.2 scale (-) show grestore} bind def\n"); } /* ----- def_typset ------- */ void def_typeset(fp) FILE *fp; { fprintf (fp, "\n/WS { %%usage: w nspaces str WS\n" " dup stringwidth pop 4 -1 roll\n" " sub neg 3 -1 roll div 0 8#040 4 -1 roll\n" " widthshow\n" "} bind def\n"); fprintf (fp, "\n/W1 { show pop pop } bind def\n"); fprintf (fp, "\n/str 50 string def\n" "/W0 {\n" " dup stringwidth pop str cvs exch show ( ) show show pop pop\n" "} bind def\n"); fprintf (fp, "\n/WC { counttomark 1 sub dup 0 eq { 0 }\n" " { ( ) stringwidth pop neg 0 3 -1 roll\n" " { dup 3 add index stringwidth pop ( ) stringwidth pop add\n" " dup 3 index add 4 index lt 2 index 1 lt or\n" " {3 -1 roll add exch 1 add} {pop exit} ifelse\n" " } repeat } ifelse\n" "} bind def\n"); fprintf (fp, "\n/P1 {\n" " { WC dup 0 le {exit} if\n" " exch pop gsave { exch show ( ) show } repeat grestore LF\n" " } loop pop pop pop pop\n" "} bind def\n"); fprintf (fp, "\n/P2 {\n" " { WC dup 0 le {exit} if\n" " dup 1 sub dup 0 eq\n" " { pop exch pop 0.0 }\n" " { 3 2 roll 3 index exch sub exch div } ifelse\n" " counttomark 3 sub 2 index eq { pop 0 } if exch gsave\n" " { 3 2 roll show ( ) show dup 0 rmoveto } repeat\n" " grestore LF pop\n" " } loop pop pop pop pop\n" "} bind def\n"); } /* ----- define_font ------- */ void define_font (fp,name,num) FILE *fp; char name[]; int num; { if (!strcmp(name,"Symbol")) { fprintf (fp, "/F%d { 1 eq {/bx true def} { /bx false def} ifelse\n" " dup 0.72 mul /fh exch def\n" " /%s exch selectfont } bind def\n", num, name); return; } fprintf (fp, "\n/%s findfont\n" "dup length dict begin\n" " {1 index /FID ne {def} {pop pop} ifelse} forall\n" " /Encoding ISOLatin1Encoding def\n" " currentdict\n" "end\n" "/%s-ISO exch definefont pop\n", name, name); fprintf (fp, "/F%d { 1 eq {/bx true def} { /bx false def} ifelse\n" " dup 0.72 mul /fh exch def\n" " /%s-ISO exch selectfont } bind def\n", num, name); } /* ----- def_tsig ------- */ void def_tsig (fp) FILE *fp; { fprintf (fp, "\n/tsig { %% usage: x (top) (bot) tsig -- draw time signature\n" " 3 -1 roll 0 moveto /bx false def\n" " gsave /Times-Bold 16 selectfont 1.2 1 scale\n" " 0 1.0 rmoveto currentpoint 3 -1 roll cshow\n" " moveto 0 12 rmoveto cshow grestore\n" "} bind def\n" ); } /* ----- add_cv ------- */ void add_cv (FILE *fp, float f1, float f2, float p[][2], int i0, int ncv) { int i,i1,m; i1=i0; for (m=0; m