]> git.donarmstrong.com Git - lilypond.git/commitdiff
* input/test/title-markup.ly (spaceTest): Add.
authorJan Nieuwenhuizen <janneke@gnu.org>
Tue, 2 Mar 2004 23:07:45 +0000 (23:07 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Tue, 2 Mar 2004 23:07:45 +0000 (23:07 +0000)
* lily/text-item.cc (interpret_markup): Make line markup from
multi word markup.

* scm/define-markup-commands.scm (word): New markup command.
(simple): Use it.

ChangeLog
input/test/title-markup.ly
lily/text-item.cc
scm/define-markup-commands.scm
scm/output-ps.scm

index 67d362d69d33e48f571cb0aabfc1f930728da44f..252b59fa96b4b336e0639aeb477fa6f6f580c97f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,12 @@
-2004-03-02  Jan Nieuwenhuizen  <janneke@gnu.org>
+2004-03-03  Jan Nieuwenhuizen  <janneke@gnu.org>
+
+       * input/test/title-markup.ly (spaceTest): Add.
+
+       * lily/text-item.cc (interpret_markup): Make line markup from
+       multi word markup.
+
+       * scm/define-markup-commands.scm (word): New markup command.
+       (simple): Use it.
 
        * scm/output-ps.scm (define-fonts): Fix TeX font scaling.
 
index 424e6eb417350f432138d3e1e4ee07229355f5ca..98085979e07b9d59cfa4335fa0b230ffeedae95c 100644 (file)
@@ -25,25 +25,26 @@ texidoc = "
 sizeTest = \markup {
        \column <
             { \normalsize "normalsize"
-              \hspace #10
+              \hspace #5
               \smaller "smaller"
-              \hspace #10
+              \hspace #5
               \smaller \smaller "smaller"
-              \hspace #10
+              \hspace #5
               \smaller \smaller \smaller "smaller"
             }
             " " 
             { \normalsize "normalsize"
-              \hspace #10
+              \hspace #5
               \bigger "bigger"
-              \hspace #10
+              \hspace #5
               \bigger \bigger "bigger"
-              \hspace #10
+              \hspace #5
               \bigger \bigger \bigger "bigger"
             }
        >
 }
 
+spaceTest = \markup { "two space chars" }
 \header {
     texidoc = "Make titles using markup (WIP)."
 
@@ -85,10 +86,12 @@ sizeTest = \markup {
         >
     }
      foe = \sizeTest
+     bar = \spaceTest
 }
 
 \score {
     \context Staff \notes \relative c' {
        c-\sizeTest % \markup { \center < \roman \caps "foe" > }
+        c-\spaceTest
     }
 }
index d79cdb16e35550837341bee5535a3537c8e528c9..bfb24f1b53350142bd04ffdea68e112b5ecfa0a6 100644 (file)
 #include "virtual-font-metric.hh"
 #include "paper-def.hh"
 
-MAKE_SCHEME_CALLBACK(Text_item,interpret_markup,3);
+MAKE_SCHEME_CALLBACK (Text_item, interpret_markup, 3)
 SCM
 Text_item::interpret_markup (SCM paper, SCM props, SCM markup)
 {
   if (gh_string_p (markup))
     {
+      String str = ly_scm2string (markup);
+      if (str.index_any (" \t\n\r") != -1)
+       {
+         /* Multi word string to line markup.  */
+         SCM proc = scm_c_eval_string ("make-simple-markup");
+         return interpret_markup (paper, props, scm_call_1 (proc, markup));
+       }
+
+      /* Simple word.  */
       Paper_def *pap = unsmob_paper (paper);
       Font_metric *fm = select_font (pap, props);
-  
-      SCM list = scm_list_n (ly_symbol2scm ("text"), markup, SCM_UNDEFINED);
+      SCM lst = scm_list_n (ly_symbol2scm ("text"), markup, SCM_UNDEFINED);
       
       if (dynamic_cast<Virtual_font_metric*> (fm))
-       {
-         /*
-           ARGH.
-         */
-         programming_error ("Can't use virtual font for text.");
-       }
+       /* ARGH. */
+       programming_error ("Can't use virtual font for text.");
       else
-       list = fontify_atom (fm, list);
+       lst = fontify_atom (fm, lst);
 
-      Box b = fm->text_dimension (ly_scm2string (markup));
-      return Stencil (b, list).smobbed_copy();
+      Box b = fm->text_dimension (str);
+      return Stencil (b, lst).smobbed_copy ();
     }
   else if (gh_pair_p (markup))
     {
@@ -48,10 +52,7 @@ Text_item::interpret_markup (SCM paper, SCM props, SCM markup)
       
       return scm_apply_2 (func, paper, props, args);
     }
-  else
-    {
-      return SCM_EOL;
-    }
+  return SCM_EOL;
 }
 
 MAKE_SCHEME_CALLBACK(Text_item,print,1);
index c0ceebe06cdabadc8737c5e166794313868cf7c8..a4db180bf53fa3406f3b677e76b163e205da3251 100644 (file)
@@ -1,21 +1,26 @@
+;;;; define-markup-commands.scm -- markup commands
+;;;;
+;;;;  source file of the GNU LilyPond music typesetter
+;;;; 
+;;;; (c)  2000--2004  Han-Wen Nienhuys <hanwen@cs.uu.nl>
+;;;;                  Jan Nieuwenhuizen <janneke@gnu.org>
 
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; markup commands
-;; TODO:
-;; each markup function should have a doc string with
-;; syntax, description and example. 
-;;
+;;; TODO:
+;;;  * each markup function should have a doc string with
+;;     syntax, description and example. 
 
 
+(def-markup-command (word paper props str) (string?)
+  "A single word."
+  (interpret-markup paper props str))
+  
 (def-markup-command (simple paper props str) (string?)
   "A simple text-string; @code{\\markup @{ foo @}} is equivalent with
-@code{\\markup @{ \\simple #\"foo\" @}}.
-"
-  (interpret-markup paper props str))
-
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;; fonts
+@code{\\markup @{ \\simple #\"foo\" @}}."
+  (interpret-markup paper props
+                   (make-line-markup
+                    (map make-word-markup (string-tokenize str)))))
 
 (define (font-markup qualifier value)
   (lambda (paper props arg)
@@ -23,8 +28,6 @@
                      (prepend-alist-chain qualifier value props)
                       arg)))
 
-
-
 (define-public empty-markup
   (make-simple-markup ""))
 
index 96238dcf4c70c178e796b1671e52acf48bd643a8..c472db53041f164201d99af05ca480d475065577 100644 (file)
@@ -9,8 +9,8 @@
 ;;;;       input/test/title-markup.ly
 ;;;; 
 ;;;; TODO:
-;;;;   * UGR: SPACE character in CM* fonts
-;;;;   * text setting, kerning?
+;;;;   * special characters, encoding.
+;;;;   * text setting, kerning.
 ;;;;   * linewidth
 ;;;;   * font properties
 ;;;;   * construction/customisation of title markup