]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/define-markup-commands.scm
Merge branch 'lilypond/translation' of ssh://git.sv.gnu.org/srv/git/lilypond into...
[lilypond.git] / scm / define-markup-commands.scm
index 311faf463ed8613cc77127a49434b78cd85f8f74..7836da51a150fca38bf2594cc4865739e1d912a0 100644 (file)
@@ -2,7 +2,7 @@
 ;;;;
 ;;;;  source file of the GNU LilyPond music typesetter
 ;;;; 
-;;;; (c) 2000--2008  Han-Wen Nienhuys <hanwen@xs4all.nl>
+;;;; (c) 2000--2009  Han-Wen Nienhuys <hanwen@xs4all.nl>
 ;;;;                  Jan Nieuwenhuizen <janneke@gnu.org>
 
 
@@ -470,34 +470,23 @@ This inserts @var{str} directly into the output as a PostScript
 command string.
 
 @lilypond[verbatim,quote]
-eyeglassesps = #\"
+ringsps = #\"
   0.15 setlinewidth
-  -0.9 0 translate
-  1.1 1.1 scale
-  1.2 0.7 moveto
-  0.7 0.7 0.5 0 361 arc
+  0.9 0.6 moveto
+  0.4 0.6 0.5 0 361 arc
   stroke
-  2.20 0.70 0.50 0 361 arc
+  1.0 0.6 0.5 0 361 arc
   stroke
-  1.45 0.85 0.30 0 180 arc
-  stroke
-  0.20 0.70 moveto
-  0.80 2.00 lineto
-  0.92 2.26 1.30 2.40 1.15 1.70 curveto
-  stroke
-  2.70 0.70 moveto
-  3.30 2.00 lineto
-  3.42 2.26 3.80 2.40 3.65 1.70 curveto
-  stroke\"
+  \"
 
-eyeglasses = \\markup {
-  \\with-dimensions #'(0 . 4.4) #'(0 . 2.5)
-  \\postscript #eyeglassesps
+rings = \\markup {
+  \\with-dimensions #'(-0.2 . 1.6) #'(0 . 1.2)
+  \\postscript #ringsps
 }
 
 \\relative c'' {
-  c2^\\eyeglasses
-  a2_\\eyeglasses
+  c2^\\rings
+  a2_\\rings
 }
 @end lilypond"
   ;; FIXME
@@ -1014,7 +1003,7 @@ the line width, where @var{X} is the number of staff spaces.
 @lilypond[verbatim,quote]
 \\header {
   title = \"My title\"
-  description = \"Lorem ipsum dolor sit amet, consectetur adipisicing
+  myText = \"Lorem ipsum dolor sit amet, consectetur adipisicing
     elit, sed do eiusmod tempor incididunt ut labore et dolore magna
     aliqua.  Ut enim ad minim veniam, quis nostrud exercitation ullamco
     laboris nisi ut aliquip ex ea commodo consequat.\"
@@ -1025,7 +1014,7 @@ the line width, where @var{X} is the number of staff spaces.
     \\column {
       \\fill-line { \\fromproperty #'header:title }
       \\null
-      \\wordwrap-field #'header:descr
+      \\wordwrap-field #'header:myText
     }
   }
 }
@@ -1048,7 +1037,7 @@ the line width, where @var{X} is the number of staff spaces.
 @lilypond[verbatim,quote]
 \\header {
   title = \"My title\"
-  description = \"Lorem ipsum dolor sit amet, consectetur adipisicing
+  myText = \"Lorem ipsum dolor sit amet, consectetur adipisicing
     elit, sed do eiusmod tempor incididunt ut labore et dolore magna
     aliqua.  Ut enim ad minim veniam, quis nostrud exercitation ullamco
     laboris nisi ut aliquip ex ea commodo consequat.\"
@@ -1059,7 +1048,7 @@ the line width, where @var{X} is the number of staff spaces.
     \\column {
       \\fill-line { \\fromproperty #'header:title }
       \\null
-      \\justify-field #'header:description
+      \\justify-field #'header:myText
     }
   }
 }
@@ -2579,6 +2568,94 @@ figured bass notation.
 @end lilypond"
   (slashed-digit-internal layout props num #f font-size thickness))
 
+;; eyeglasses
+(define eyeglassesps 
+     "0.15 setlinewidth
+      -0.9 0 translate
+      1.1 1.1 scale
+      1.2 0.7 moveto
+      0.7 0.7 0.5 0 361 arc
+      stroke
+      2.20 0.70 0.50 0 361 arc
+      stroke
+      1.45 0.85 0.30 0 180 arc
+      stroke
+      0.20 0.70 moveto
+      0.80 2.00 lineto
+      0.92 2.26 1.30 2.40 1.15 1.70 curveto
+      stroke
+      2.70 0.70 moveto
+      3.30 2.00 lineto
+      3.42 2.26 3.80 2.40 3.65 1.70 curveto
+      stroke")
+
+(define-builtin-markup-command (eyeglasses layout props) () other ()
+  "Prints out eyeglasses, indicating strongly to look at the conductor.
+@lilypond[verbatim,quote]
+\\markup { \\eyeglasses }
+@end lilypond"
+  (interpret-markup layout props
+    (make-with-dimensions-markup '(-0.61 . 3.21) '(0.21 . 2.4)
+      (make-postscript-markup eyeglassesps))))
+
+(define-builtin-markup-command (left-brace layout props size)
+  (number?)
+  other
+  ()
+  "
+A feta brace in point size @var{size}.
+
+@lilypond[verbatim,quote]
+\\markup {
+  \\left-brace #35
+  \\hspace #2
+  \\left-brace #45
+}
+@end lilypond"
+  (let* ((font (ly:paper-get-font layout
+                                  (cons '((font-encoding . fetaBraces)
+                                          (font-name . #f))
+                                        props)))
+        (glyph-count (1- (ly:otf-glyph-count font)))
+         (scale (ly:output-def-lookup layout 'output-scale))
+         (scaled-size (/ (ly:pt size) scale))
+         (glyph (lambda (n)
+                  (ly:font-get-glyph font (string-append "brace"
+                                                        (number->string n)))))
+        (get-y-from-brace (lambda (brace)
+                            (interval-length
+                             (ly:stencil-extent (glyph brace) Y))))
+         (find-brace (binary-search 0 glyph-count get-y-from-brace scaled-size))
+         (glyph-found (glyph find-brace)))
+
+    (if (or (null? (ly:stencil-expr glyph-found))
+           (< scaled-size (interval-length (ly:stencil-extent (glyph 0) Y)))
+           (> scaled-size (interval-length
+                           (ly:stencil-extent (glyph glyph-count) Y))))
+        (begin
+          (ly:warning (_ "no brace found for point size ~S ") size)
+          (ly:warning (_ "defaulting to ~S pt")
+                     (/ (* scale (interval-length
+                                  (ly:stencil-extent glyph-found Y)))
+                        (ly:pt 1)))))
+    glyph-found))
+
+(define-builtin-markup-command (right-brace layout props size)
+  (number?)
+  other
+  ()
+  "
+A feta brace in point size @var{size}, rotated 180 degrees.
+
+@lilypond[verbatim,quote]
+\\markup {
+  \\right-brace #45
+  \\hspace #2
+  \\right-brace #35
+}
+@end lilypond"
+  (interpret-markup layout props (markup #:rotate 180 #:left-brace size)))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; the note command.
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;