]> git.donarmstrong.com Git - lilypond.git/blobdiff - ps/lilyponddefs.ps
* ps/music-drawing-routines.ps:
[lilypond.git] / ps / lilyponddefs.ps
index 48b4bfb7b7f883b57b42d245ab448500a5a4f0fb..cc4bf26f4e8ad04c02b0de118c66667c41b5ea0c 100644 (file)
-%!PS-Adobe-1.0: lilyponddefs
+%!PS-Adobe-1.0: lilyponddefs.ps
+%
+% Functions for direct PostScript output
 
 % hmm
-/setgray { 1 add } bind def
+/setgray { 1 add } bind def
 
-/xoffset 30 def
-/yoffset 700 def
-/staffrulethickness 1 def
-/staffheight 20 def
+/staff-line-thickness lilypondpaperlinethickness def
+/staff-height lilypondpaperstaffheight def
+/line-width lilypondpaperlinewidth def
 
-/placebox
-{
-       /object exch def
-       gsave
-       %exch translate
-       translate
-       0 0 moveto
-       object
-       grestore
-} bind def
+% FIXME: why isn't this set (by default) by lily?
+% /text-height lilypondpapertextheight 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 ')'
+/set-ps-scale-to-lily-scale
 {
-       gsave
-       % urg
-       /Times-Italic findfont 12 scalefont setfont
-       show
-       grestore
+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
-{
+% FIXME
+% urg, read from paper block
+% fixed base line skip value, for single line staves
+/base-line-skip lilypondpaperlineheight def
+
+/init-paper {
        gsave
-       4 -1 roll neg 0 translate
-       vrule
+       .1 setlinewidth
+       clippath pathbbox newpath
+       /vsize exch def
+       /hsize exch def  pop pop pop
+
+       %FIXME:
+       %vsize text-height sub 2 div /top-margin exch def
+       144 2 div /top-margin exch def
+       hsize line-width sub 2 div /left-margin exch def
        grestore
 } bind def
 
-/widthbar % height width
+/place-box
 {
+       /object exch def
        gsave
-       setlinewidth
-       2 div dup neg 0 exch moveto
-       0 exch lineto stroke
-       2 div
+       %exch translate
+       translate
+       0 0 moveto
+       object
        grestore
 } bind def
 
-/thickbar % height
+/start-system % height
 {
-       stafflinethickness 2 mul widthbar
+       dup base-line-skip gt {
+               /line-height exch def
+       }
+       {
+               pop /line-height base-line-skip def
+       } ifelse
+       line-y top-margin sub base-line-skip lt {
+               showpage
+               /line-y vsize top-margin sub def
+       } if
+       gsave
+       line-x line-y translate
 } bind def
 
-/thinbar % height
-{
-       stafflinethickness 1.6 mul widthbar
+/stop-system
+{ 
+       /the-line exch def
+       the-line
+       stroke
+       grestore
+       line-y line-height output-scale mul sub /line-y exch def
 } bind def
 
-/maatstreep % height
-{
-       thinbar
+% FIXME: font definitions should come from LilyPond
+%        built-in ps fonts are ugly
+/huge-bold-font {
+       /Palatino-Bold findfont 20.7 scalefont setfont
 } bind def
 
-/fatdoublebar
-{
-       thickbar
+/Large-bold-font {
+       /Palatino-Bold findfont 17.3 scalefont setfont
 } bind def
 
-/finishbar
-{
-       thickbar
+/large-bold-font {
+       /Palatino-Bold findfont 14.4 scalefont setfont
 } bind def
 
-/generalmeter % num den
-{
-       pop pop
+/large-font {
+       /Palatino-Roman findfont 14.4 scalefont setfont
 } bind def
 
-/pianobrace % '(' char ')'
-{
-       gsave
-       /feta-braces20 findfont 12 scalefont setfont%
-       show
-       grestore
+/large-smallcaps-font {
+       % urg
+       /Bookman-Light findfont 14.4 scalefont setfont
 } bind def
 
-/doublebar
-{
-       thinbar
+/normal-font {
+       /Palatino-Roman findfont 12 scalefont setfont
 } bind def
 
-/repeatbar
-{
-       thickbar
+/footnote-font {
+       /Palatino-Roman findfont 10 scalefont setfont
 } bind def
 
-/repeatbarstartrepeat
+/get-text-dimensions % path .. width height
 {
-       thickbar
+       dup true charpath pathbbox
+       newpath
+       line-x line-y moveto
+       exch 4 -1 roll
+       sub
+       3 1 roll
+       exch sub
 } bind def
 
-/startbar
+/set-centered
 {
-       thickbar
+       line-x line-y moveto
+       get-text-dimensions
+       neg line-y add /line-y exch def
+       neg line-width add 2 div 0 rmoveto
+       show
 } bind def
 
-/startrepeat
+/set-left
 {
-       thickbar
+       line-x line-y moveto
+       get-text-dimensions
+       neg line-y add /line-y exch def
+       pop
+       show
 } bind def
 
-/stoprepeat
+/set-right
 {
-       thickbar
+       line-x line-y moveto
+       get-text-dimensions
+       neg line-y add /line-y exch def
+       neg line-width add 0 rmoveto
+       show
 } bind def
 
-/start_line
-{ 
-       gsave
-       xoffset yoffset translate
+/make-lilypond-title
+{
+       currentdict /lilyponddedication known {
+               normal-font lilyponddedication set-centered
+               line-y 10 sub /line-y exch def
+       } if
+       currentdict /lilypondtitle known {
+               huge-bold-font lilypondtitle set-centered
+               line-y 5 sub /line-y exch def
+       } if
+       currentdict /lilypondsubtitle known {
+               Large-bold-font lilypondsubtitle set-centered
+               line-y 5 sub /line-y exch def
+       } if
+       currentdict /lilypondsubsubtitle known {
+               large-bold-font lilypondsubsubtitle set-centered
+       } if
+       line-y /mini-page exch def
+       currentdict /lilypondcomposer known {
+               large-smallcaps-font lilypondcomposer set-right
+               line-y 2 sub /line-y exch def
+       } if
+       currentdict /lilypondopus known {
+               normal-font lilypondopus set-right
+               line-y 3 sub /line-y exch def
+       } if
+       currentdict /lilypondarranger known {
+               normal-font lilypondarranger set-right
+               line-y 3 sub /line-y exch def
+       } if
+       currentdict /lilypondpoet known {
+               mini-page /line-y exch def
+               normal-font lilypondpoet set-left
+               line-y 3 sub /line-y exch def
+       } if
+       currentdict /lilypondtexttranslator known {
+               normal-font lilypondtexttranslator set-left
+               line-y 3 sub /line-y exch def
+       } if
+       currentdict /lilypondinstrument known {
+               large-font lilypondinstrument set-centered
+       } if
+       currentdict /lilypondpiece known {
+               large-smallcaps-font lilypondpiece set-left
+       } if
+} bind def
+
+/end-lilypond-output
+{
+       /line-y top-margin def
+       footnote-font lilypondtagline set-left
+       showpage
 } 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
-} bind def
+/turnOnExperimentalFeatures { } bind def
 
-/unknown { (U) setbold } bind def
-/empty { (E) setbold } bind def
+staff-line-thickness setlinewidth
 
-/turnOnExperimentalFeatures { } bind def
+% set postscript paper size
+paper-size
 
-/rulesym % thick length
-{
-       gsave
-       exch setlinewidth
-       0 lineto stroke
-       grestore
-} bind def
+% initialise paper dimensions
+staff-height init-paper
 
-(lily.ps) findlibfile 
-{
-       exch pop //systemdict /run get exec
-} 
-{ 
-       /undefinedfilename signalerror 
-} ifelse
+/line-x left-margin output-scale div def
+/line-y vsize top-margin sub def
 
-stafflinethickness setlinewidth
+make-lilypond-title
 
 % see if we're there...
 % 10 setlinewidth 0 0 moveto 400 800 lineto stroke
+
+% end lilyponddefs.ps