-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.
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)."
>
}
foe = \sizeTest
+ bar = \spaceTest
}
\score {
\context Staff \notes \relative c' {
c-\sizeTest % \markup { \center < \roman \caps "foe" > }
+ c-\spaceTest
}
}
#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))
{
return scm_apply_2 (func, paper, props, args);
}
- else
- {
- return SCM_EOL;
- }
+ return SCM_EOL;
}
MAKE_SCHEME_CALLBACK(Text_item,print,1);
+;;;; 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)
(prepend-alist-chain qualifier value props)
arg)))
-
-
(define-public empty-markup
(make-simple-markup ""))
;;;; 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