]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/define-markup-commands.scm
* lily/staff-symbol-referencer.cc (get_position): emergency
[lilypond.git] / scm / define-markup-commands.scm
index 6d765b7182e83c7057a9fedda35dd4717dddcb4c..abcb7e33135eb47c529da350096308b9201a3982 100644 (file)
 ;;     syntax, description and example. 
 
 
-(def-markup-command (word paper props str) (string?)
-  "A single word."
-  (interpret-markup paper props str))
-  
+(def-markup-command (stencil paper props stil) (ly:stencil?)
+  "Stencil as markup"
+  stil)
+
+
+(def-markup-command (score paper props score) (ly:score?)
+  (let*
+      ((systems (ly:score-embedded-format score paper))
+       (1st (vector-ref systems 0))
+       (stencil (ly:paper-system-stencil 1st)) )
+
+    (ly:stencil-align-to! stencil Y CENTER)
+    stencil))
+
 (def-markup-command (simple paper props str) (string?)
-  "A simple text-string; @code{\\markup @{ foo @}} is equivalent with
+  "A simple text string; @code{\\markup @{ foo @}} is equivalent with
 @code{\\markup @{ \\simple #\"foo\" @}}."
-    (interpret-markup paper props
-                     (make-line-markup
-                      (map make-word-markup (string-tokenize str)))))
+    (interpret-markup paper props str))
+
+(def-markup-command (encoded-simple paper props sym str) (symbol? string?)
+  "A text string, encoded with encoding @var{sym}. "
+  (Text_item::interpret_string paper
+                              props sym str))
+
+;; TODO: use font recoding.
+;;                   (make-line-markup
+;;                    (map make-word-markup (string-tokenize str)))))
 
 (define-public empty-markup
   (make-simple-markup ""))
@@ -48,9 +65,9 @@
                           (if (= word-count 1) 2 (- word-count 1)))))
        (line-stencils (if (= word-count 1)
                           (map (lambda (x) (interpret-markup paper props x))
-                               (list (make-word-markup "")
-                                     (car markups)
-                                     (make-word-markup "")))
+                               (list (make-simple-markup "")
+                                     (make-stencil-markup (car stencils))
+                                     (make-simple-markup "")))
                                stencils)))
     (stack-stencil-line fill-space line-stencils)))
   
@@ -69,9 +86,11 @@ determines the space between each markup in @var{args}."
 
 (def-markup-command (combine paper props m1 m2) (markup? markup?)
   "Print two markups on top of each other."
-  (ly:stencil-add
-   (interpret-markup paper props m1)
-   (interpret-markup paper props m2)))
+  (let*
+      ((s1 (interpret-markup paper props m1))
+       (s2 (interpret-markup paper props m2)))
+            
+    (ly:stencil-add s1 s2)))
 
 (def-markup-command (finger paper props arg) (markup?)
   "Set the argument as small numbers."
@@ -80,7 +99,7 @@ determines the space between each markup in @var{args}."
                     arg))
 
 (def-markup-command (fontsize paper props mag arg) (number? markup?)
-  "This sets the relative font size, eg.
+  "This sets the relative font size, e.g.
 @example
 A \\fontsize #2 @{ B C @} D
 @end example
@@ -120,7 +139,7 @@ Use @code{\\fontsize} otherwise."
   "Set font family to @code{number}, which yields the font used for
 time signatures and fingerings.  This font only contains numbers and
 some punctuation. It doesn't have any letters.  "
-  (interpret-markup paper (prepend-alist-chain 'font-family 'number props) arg))
+  (interpret-markup paper (prepend-alist-chain 'font-encoding 'fetaNumber props) arg))
 
 (def-markup-command (roman paper props arg) (markup?)
   "Set font family to @code{roman}."
@@ -160,11 +179,11 @@ some punctuation. It doesn't have any letters.  "
 
 (def-markup-command (dynamic paper props arg) (markup?)
   "Use the dynamic font.  This font only contains @b{s}, @b{f}, @b{m},
-@b{z}, @b{p}, and @b{r}.  When producing phrases, like ``piu @b{f}'', the
-normal words (like ``piu'') should be done in a different font.  The
+@b{z}, @b{p}, and @b{r}.  When producing phrases, like ``pi@`{u} @b{f}'', the
+normal words (like ``pi@`{u}'') should be done in a different font.  The
 recommend font for this is bold and italic"
   (interpret-markup
-   paper (prepend-alist-chain 'font-family 'dynamic props) arg))
+   paper (prepend-alist-chain 'font-encoding 'fetaDynamic props) arg))
 
 (def-markup-command (italic paper props arg) (markup?)
   "Use italic @code{font-shape} for @var{arg}. "
@@ -237,6 +256,12 @@ of the @code{#'direction} layout property."
          (cmols (map (lambda (x) (ly:stencil-align-to! x X CENTER)) mols)))
     (stack-lines -1 0.0 (chain-assoc-get 'baseline-skip props) mols)))
 
+(def-markup-command (vcenter paper props arg) (markup?)
+  "Align @code{arg} to its center. "
+  (let* ((mol (interpret-markup paper props arg)))
+    (ly:stencil-align-to! mol Y CENTER)
+    mol))
+
 (def-markup-command (right-align paper props arg) (markup?)
   (let* ((m (interpret-markup paper props arg)))
     (ly:stencil-align-to! m X RIGHT)
@@ -249,6 +274,14 @@ of the @code{#'direction} layout property."
     (ly:stencil-align-to! m X LEFT)
     m))
 
+(def-markup-command (general-align paper props axis dir arg)  (integer? number? markup?)
+  "Align @var{arg} in @var{axis} direction to the @var{dir} side."
+  (let* ((m (interpret-markup paper props arg)))
+
+    (ly:stencil-align-to! m axis dir)
+    m
+  ))
+
 (def-markup-command (halign paper props dir arg) (number? markup?)
   "Set horizontal alignment. If @var{dir} is -1, then it is
 left-aligned, while+1 is right. Values in between interpolate alignment
@@ -265,10 +298,7 @@ accordingly."
 See @usermanref{The Feta font} for  a complete listing of the possible glyphs.
 "
   (ly:find-glyph-by-name
-   (ly:paper-get-font paper (cons '((font-name . ())
-                                    (font-shape . *)
-                                    (font-series . *)
-                                    (font-family . music))
+   (ly:paper-get-font paper (cons '((font-encoding . fetaMusic))
                                   props))
    glyph-name))
 
@@ -330,7 +360,7 @@ and/or @code{extra-offset} properties. "
   "Construct a note symbol, with stem.  By using fractional values for
 @var{dir}, you can obtain longer or shorter stems."
   
-  (let* ((font (ly:paper-get-font paper (cons '((font-family .  music)) props)))
+  (let* ((font (ly:paper-get-font paper (cons '((font-encoding . fetaMusic)) props)))
          (stemlen (max 3 (- log 1)))
          (headgl (ly:find-glyph-by-name
                   font
@@ -388,7 +418,7 @@ and/or @code{extra-offset} properties. "
     (lambda (z) (inexact->exact (/ (log z) divisor)))))
 
 (define (parse-simple-duration duration-string)
-  "Parse the `duration-string', eg ''4..'' or ''breve.'', and return a (log dots) list."
+  "Parse the `duration-string', e.g. ''4..'' or ''breve.'', and return a (log dots) list."
   (let ((match (regexp-exec (make-regexp "(breve|longa|maxima|[0-9]+)(\\.*)") duration-string)))
     (if (and match (string=? duration-string (match:substring match 0)))
         (let ((len  (match:substring match 1))
@@ -518,7 +548,7 @@ any sort of property supported by @internalsref{font-interface} and
 (def-markup-command (smaller paper props arg) (markup?)
   "Decrease the font size relative to current setting"
   (let* ((fs (chain-assoc-get 'font-size props 0))
-         (entry (cons 'font-size (- fs 1))))
+        (entry (cons 'font-size (- fs 1))))
     (interpret-markup paper (cons (list entry) props) arg)))