<-- previous page     Table of Contents    Index    next page -->

Printing braces

Mup prints braces to the left of scores via the brace parameter, but it may sometimes be desired to print a brace somewhere else, and have it scale appropriately for its height. This can be done using an escape to PostScript. Here is a macro definition that can be used to print a brace, and an example of how to use it:

// brace expects an x value and bottom and top y values
define BRACE(TOP, BOTTOM)
       postscript (TOP.w - 1, BOTTOM.s) with _top.y = TOP.n  "
           currentpoint Mup_top.y brace"
@

score
   staffs=2
music

1: c+ =_t;;;;
2: c =_b;;;;
BRACE(_t, _b)
bar

Picture of Mup output

A somewhat more complicated version, which would print a string before the brace, might be:

define BRACE(TOP, BOTTOM, STRING)
       postscript (TOP.w - 1, BOTTOM.s) with _top.y = TOP.n  "
        currentpoint /yloc exch def /xloc exch def
        currentpoint Mup_top.y brace
        /TimesRoman findfont 12 scalefont setfont
        xloc 7.5 sub (" + STRING + ") stringwidth pop sub
        yloc Mup_top.y add 2 div 1.5 sub moveto (" + STRING +") show"
@

score
  staffs=2
music

1: [pad 10] c+ =_t;;;;
2: c =_b;;;;
BRACE(_t, _b, "Label")
bar

Picture of Mup output

That still wouldn't handle things like special characters in the string, or different font sizes, but could handle simple cases, and be a starting point for more complicated ones.


   <-- previous page    Table of Contents    Index    next page -->