From: Jan Nieuwenhuizen Date: Tue, 2 Mar 2004 23:07:45 +0000 (+0000) Subject: * input/test/title-markup.ly (spaceTest): Add. X-Git-Tag: release/2.1.29~22 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=d1bf739977d9699937ccbe160b0672e8658d5962;p=lilypond.git * 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. --- diff --git a/ChangeLog b/ChangeLog index 67d362d69d..252b59fa96 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,12 @@ -2004-03-02 Jan Nieuwenhuizen +2004-03-03 Jan Nieuwenhuizen + + * 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. diff --git a/input/test/title-markup.ly b/input/test/title-markup.ly index 424e6eb417..98085979e0 100644 --- a/input/test/title-markup.ly +++ b/input/test/title-markup.ly @@ -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 } } diff --git a/lily/text-item.cc b/lily/text-item.cc index d79cdb16e3..bfb24f1b53 100644 --- a/lily/text-item.cc +++ b/lily/text-item.cc @@ -15,29 +15,33 @@ #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 (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); diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index c0ceebe06c..a4db180bf5 100644 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -1,21 +1,26 @@ +;;;; define-markup-commands.scm -- markup commands +;;;; +;;;; source file of the GNU LilyPond music typesetter +;;;; +;;;; (c) 2000--2004 Han-Wen Nienhuys +;;;; Jan Nieuwenhuizen - -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; 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 "")) diff --git a/scm/output-ps.scm b/scm/output-ps.scm index 96238dcf4c..c472db5304 100644 --- a/scm/output-ps.scm +++ b/scm/output-ps.scm @@ -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