-%!PS-Adobe-1.0: lilyponddefs
+%!PS-Adobe-2.0: lilyponddefs.ps
+% TODO:
+% * junk all magic, start-line/stop-line just: placebox @ x.y
+%
+% Functions for direct PostScript output
-% hmm
-/setgray { 1 add } bind def
+% /setgray { 1 add } bind def
-/xoffset 30 def
-/yoffset 700 def
-/stafflinethickness 1 def
-/staffheight 20 def
+% To let gs load fonts from builddir, do:
+% export GS_LIB=$(pwd)/mf/out:/usr/share/texmf/fonts/type1/bluesky/cm
-/placebox
-{
- /object exch def
- gsave
- %exch translate
- translate
- 0 0 moveto
- object
- grestore
-} bind def
+/staff-line-thickness lilypondpaperlinethickness def
+/staff-height lilypondpaperstaffheight def
+/line-width lilypondpaperlinewidth def
-/setbold % '(' text ')'
-{
- settext
-} bind def
-
-/settext % '(' text ')'
-{
- gsave
- % urg
- /Times-Roman findfont 12 scalefont setfont
- show
- grestore
-} bind def
+/lily-output-units 2.83464 def %% milimeter
+% /lily-output-units 0.996264 def %% true points.
-/setfinger % '(' text ')'
-{
- gsave
- % urg
- /feta-nummer5 findfont 12 scalefont setfont
- show
- grestore
-} bind def
+/output-scale lilypondpaperoutputscale lily-output-units mul def
-/setitalic % '(' text ')'
-{
- gsave
- % urg
- /Times-Italic findfont 12 scalefont setfont
- show
- grestore
-} bind def
+/set-ps-scale-to-lily-scale { output-scale output-scale scale } bind def
-/vrule % width height depth
-{
- gsave
- 3 -1 roll setlinewidth
- neg 0 exch moveto
- 0 exch lineto stroke
- grestore
-} bind def
+/paper-size { lilypondpaperpapersize } bind def
-/draw_stem % kern width height depth
-{
+/init-paper {
gsave
- 4 -1 roll neg 0 translate
- vrule
+ .1 setlinewidth
+ clippath pathbbox newpath
+ /vsize exch def
+ /hsize exch def pop pop pop pop
+ % FIXME
+ /top-margin 2 def
+ hsize line-width sub 2 div /left-margin exch def
grestore
} bind def
-/extender % width
+/place-box
{
+ /object exch def
gsave
+ %exch translate
+ translate
0 0 moveto
- stafflinethickness 0.8 mul setlinewidth
- 0 lineto stroke
+ object
grestore
} bind def
-/widthbar % height width
-{
- gsave
- setlinewidth
- 2 div dup neg 0 exch moveto
- 0 exch lineto stroke
- 2 div
- grestore
-} bind def
+%% http://bibliofile.mc.duke.edu/gww/fonts/postscript-utilities/encoding-vectors.html
-/thickbar % height
-{
- stafflinethickness 2 mul widthbar
-} bind def
+%/FONTLENGTH 256 bind def
-/thinbar % height
+%<font> <encoding> <name> reencode-font
+/reencode-dict 5 dict def
+/reencode-font
{
- stafflinethickness 1.6 mul widthbar
+ reencode-dict
+ begin
+ /name exch def
+ /encoding exch def
+ /base-font exch def
+ % note: Needs ps level 2
+ /font base-font maxlength dict def
+ base-font {
+ exch dup dup /FID ne exch /Encoding ne and
+ { exch font 3 1 roll put }
+ { pop pop } ifelse
+ } forall
+ font /FontName name put
+ font /Encoding encoding put
+ name font definefont pop
+ end
} bind def
-/maatstreep % height
+/start-page
{
- thinbar
} bind def
-/fatdoublebar
+/stop-page
{
- thickbar
+ showpage
} bind def
-/finishbar
+/stop-last-page
{
- thickbar
} bind def
-/generalmeter % num den
+/start-system % x y
{
- pop pop
+ gsave
+ exch output-scale mul exch
+ output-scale mul vsize exch sub translate
} bind def
-/pianobrace % '(' char ')'
-{
- gsave
- /feta-braces20 findfont 12 scalefont setfont%
- show
- grestore
-} bind def
-
-/doublebar
-{
- thinbar
-} bind def
-
-/repeatbar
-{
- thickbar
-} bind def
-
-/repeatbarstartrepeat
-{
- thickbar
-} bind def
-
-/startbar
-{
- thickbar
-} bind def
-
-/startrepeat
-{
- thickbar
-} bind def
-
-/stoprepeat
-{
- thickbar
-} bind def
-
-/start_line
+/stop-system
{
- gsave
- xoffset yoffset translate
-} bind def
-
-/stop_line
-{
- /object exch def
- 0 0 moveto pathbbox exch pop sub exch pop
- object
- grestore
- yoffset add /yoffset exch def
- % urg...
- yoffset staffheight 8 mul sub /yoffset exch def
+ /the-line exch def
+ the-line stroke grestore
} bind def
-/unknown { (U) setbold } bind def
-/empty { (E) setbold } bind def
-
-/turnOnExperimentalFeatures { } bind def
-
-/rulesym % thick length
+/end-lilypond-output
{
- gsave
- exch setlinewidth
- 0 lineto stroke
- grestore
+% showpage
} bind def
-(lily.ps) findlibfile
-{
- exch pop //systemdict /run get exec
-}
-{
- /undefinedfilename signalerror
-} ifelse
+staff-line-thickness setlinewidth
+
+% set postscript paper size
+paper-size
-stafflinethickness setlinewidth
+% initialise paper dimensions
+staff-height init-paper
-% see if we're there...
-% 10 setlinewidth 0 0 moveto 400 800 lineto stroke
+% end lilyponddefs.ps