X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fdefine-markup-commands.scm;h=449f3c7cdb6656ce66267e5d4811ed32b535fa2d;hb=fb3cbeb081c0362f9ede37d95104e43bfa66044d;hp=b81cd9428b9a383dac97cd8e81e0c8ba5659554a;hpb=a03fa4e3eb5a71fd4ab2f548802d61db54489f0c;p=lilypond.git diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index b81cd9428b..449f3c7cdb 100644 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -1,14 +1,106 @@ ;;;; define-markup-commands.scm -- markup commands ;;;; ;;;; source file of the GNU LilyPond music typesetter -;;;; -;;;; (c) 2000--2007 Han-Wen Nienhuys +;;;; +;;;; (c) 2000--2009 Han-Wen Nienhuys ;;;; Jan Nieuwenhuizen - -;;; markup commands -;;; * each markup function should have a doc string with -;; syntax, description and example. +;;; +;;; Markup commands and markup-list commands definitions. +;;; +;;; Markup commands which are part of LilyPond, are defined +;;; in the (lily) module, which is the current module in this file, +;;; using the `define-builtin-markup-command' macro. +;;; +;;; Usage: +;;; +;;; (define-builtin-markup-command (command-name layout props args...) +;;; args-signature +;;; category +;;; property-bindings +;;; documentation-string +;;; ..body..) +;;; +;;; with: +;;; command-name +;;; the name of the markup command +;;; +;;; layout and props +;;; arguments that are automatically passed to the command when it +;;; is interpreted. +;;; `layout' is an output def, which properties can be accessed +;;; using `ly:output-def-lookup'. +;;; `props' is a list of property settings which can be accessed +;;; using `chain-assoc-get' (more on that below) +;;; +;;; args... +;;; the command arguments. There are restrictions on the +;;; possible arguments for a markup command. +;;; First, arguments are distingued according to their type: +;;; 1) a markup (or a string), corresponding to type predicate `markup?' +;;; 2) a list of markups, corresponding to type predicate `markup-list?' +;;; 3) any scheme object, corresponding to type predicates such as +;;; `list?', 'number?', 'boolean?', etc. +;;; The supported arrangements of arguments, according to their type, are: +;;; - no argument +;;; - markup +;;; - scheme +;;; - markup, markup +;;; - markup-list +;;; - scheme, scheme +;;; - scheme, markup +;;; - scheme, scheme, markup +;;; - scheme, scheme, markup, markup +;;; - scheme, markup, markup +;;; - scheme, scheme, scheme +;;; This combinations are hard-coded in the lexer and in the parser +;;; (lily/lexer.ll and lily/parser.yy) +;;; +;;; args-signature +;;; the arguments signature, i.e. a list of type predicates which +;;; are used to type check the arguments, and also to define the general +;;; argument types (markup, markup-list, scheme) that the command is +;;; expecting. +;;; For instance, if a command expects a number, then a markup, the +;;; signature would be: (number? markup?) +;;; +;;; category +;;; for documentation purpose, builtin markup commands are grouped by +;;; category. This can be any symbol. When documentation is generated, +;;; the symbol is converted to a capitalized string, where hyphens are +;;; replaced by spaces. +;;; +;;; property-bindings +;;; this is used both for documentation generation, and to ease +;;; programming the command itself. It is list of +;;; (property-name default-value) +;;; or (property-name) +;;; elements. Each property is looked-up in the `props' argument, and +;;; the symbol naming the property is bound to its value. +;;; When the property is not found in `props', then the symbol is bound +;;; to the given default value. When no default value is given, #f is +;;; used instead. +;;; Thus, using the following property bindings: +;;; ((thickness 0.1) +;;; (font-size 0)) +;;; is equivalent to writing: +;;; (let ((thickness (chain-assoc-get 'thickness props 0.1)) +;;; (font-size (chain-assoc-get 'font-size props 0))) +;;; ..body..) +;;; When a command `B' internally calls an other command `A', it may +;;; desirable to see in `B' documentation all the properties and +;;; default values used by `A'. In that case, add `A-markup' to the +;;; property-bindings of B. (This is used when generating +;;; documentation, but won't create bindings.) +;;; +;;; documentation-string +;;; the command documentation string (used to generate manuals) +;;; +;;; body +;;; the command body. The function is supposed to return a stencil. +;;; +;;; Each markup command definition shall have a documentation string +;;; with description, syntax and example. (use-modules (ice-9 regex)) @@ -42,22 +134,16 @@ A simple line. thickness)) (x (car dest)) (y (cdr dest))) - (ly:make-stencil - `(draw-line - ,th - 0 0 - ,x ,y) - (cons (min x 0) (max x 0)) - (cons (min y 0) (max y 0))))) - -(define-builtin-markup-command (draw-circle layout props radius thickness fill) + (make-line-stencil th 0 0 x y))) + +(define-builtin-markup-command (draw-circle layout props radius thickness filled) (number? number? boolean?) graphic () " @cindex drawing circles within text -A circle of radius @var{radius}, thickness @var{thickness} and +A circle of radius @var{radius} and thickness @var{thickness}, optionally filled. @lilypond[verbatim,quote] @@ -67,7 +153,7 @@ optionally filled. \\draw-circle #2 #0 ##t } @end lilypond" - (make-circle-stencil radius thickness fill)) + (make-circle-stencil radius thickness filled)) (define-builtin-markup-command (triangle layout props filled) (boolean?) @@ -169,7 +255,7 @@ Create a beam with the specified parameters. (half (/ thickness 2))) (ly:make-stencil - `(polygon ',(list + `(polygon ',(list 0 (/ thickness -2) width (+ (* width slope) (/ thickness -2)) width (+ (* width slope) (/ thickness 2)) @@ -188,13 +274,15 @@ Create a beam with the specified parameters. @cindex underlining text Underline @var{arg}. Looks at @code{thickness} to determine line -thickness and y offset. +thickness and y-offset. @lilypond[verbatim,quote] \\markup { + default + \\hspace #2 \\override #'(thickness . 2) \\underline { - CONTENTS + underline } } @end lilypond" @@ -204,10 +292,7 @@ thickness and y offset. (x1 (car (ly:stencil-extent markup X))) (x2 (cdr (ly:stencil-extent markup X))) (y (* thick -2)) - (line (ly:make-stencil - `(draw-line ,thick ,x1 ,y ,x2 ,y) - (cons (min x1 0) (max x2 0)) - (cons thick thick)))) + (line (make-line-stencil thick x1 y x2 y))) (ly:stencil-add markup line))) (define-builtin-markup-command (box layout props arg) @@ -251,7 +336,7 @@ Draw a box with rounded corners of dimensions @var{xext} and @end verbatim creates a box extending horizontally from -0.3 to 1.8 and vertically from -0.3 up to 1.8, with corners formed from a -circle of diameter@tie{}0 (i.e. sharp corners). +circle of diameter@tie{}0 (i.e., sharp corners). @lilypond[verbatim,quote] \\markup { @@ -272,21 +357,21 @@ circle of diameter@tie{}0 (i.e. sharp corners). (corner-radius 1) (font-size 0) (box-padding 0.5)) - "@cindex enclosing text in a bow with rounded corners + "@cindex enclosing text in a box with rounded corners @cindex drawing boxes with rounded corners around text Draw a box with rounded corners around @var{arg}. Looks at @code{thickness}, @code{box-padding} and @code{font-size} properties to determine line thickness and padding around the markup; the @code{corner-radius} property -makes possible to define another shape for the corners (default is 1). +makes it possible to define another shape for the corners (default is 1). -@lilypond[quote,verbatim,fragment,relative=2] +@lilypond[quote,verbatim,relative=2] c4^\\markup { \\rounded-box { Overtura } } c,8. c16 c4 r -@end lilypond" +@end lilypond" (let ((th (* (ly:output-def-lookup layout 'line-thickness) thickness)) (pad (* (magstep font-size) box-padding)) @@ -301,7 +386,18 @@ c,8. c16 c4 r " @cindex rotating text -Rotate object with @var{ang} degrees around its center." +Rotate object with @var{ang} degrees around its center. + +@lilypond[verbatim,quote] +\\markup { + default + \\hspace #2 + \\rotate #45 + \\line { + rotated 45° + } +} +@end lilypond" (let* ((stil (interpret-markup layout props arg))) (ly:stencil-rotate stil ang 0 0))) @@ -312,10 +408,18 @@ Rotate object with @var{ang} degrees around its center." " @cindex adding a white background to text -Provide a white background for @var{arg}." +Provide a white background for @var{arg}. + +@lilypond[verbatim,quote] +\\markup { + \\combine + \\filled-box #'(-1 . 10) #'(-3 . 4) #1 + \\whiteout whiteout +} +@end lilypond" (stencil-whiteout (interpret-markup layout props arg))) -(define-builtin-markup-command (pad-markup layout props padding arg) +(define-builtin-markup-command (pad-markup layout props amount arg) (number? markup?) align () @@ -323,7 +427,21 @@ Provide a white background for @var{arg}." @cindex padding text @cindex putting space around text -Add space around a markup object." +Add space around a markup object. + +@lilypond[verbatim,quote] +\\markup { + \\box { + default + } + \\hspace #2 + \\box { + \\pad-markup #1 { + padded + } + } +} +@end lilypond" (let* ((stil (interpret-markup layout props arg)) (xext (ly:stencil-extent stil X)) @@ -331,8 +449,8 @@ Add space around a markup object." (ly:make-stencil (ly:stencil-expr stil) - (interval-widen xext padding) - (interval-widen yext padding)))) + (interval-widen xext amount) + (interval-widen yext amount)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; space @@ -360,15 +478,7 @@ Create a box of the same height as the space in the current font." " @cindex creating horizontal spaces in text -This produces an invisible object taking horizontal space. For example, - -@example -\\markup @{ A \\hspace #2.0 B @} -@end example - -@noindent -puts extra space between A and@tie{}B, on top of the space that is -normally inserted before elements on a line. +Create an invisible object taking up horizontal space @var{amount}. @lilypond[verbatim,quote] \\markup { @@ -383,6 +493,33 @@ normally inserted before elements on a line. (ly:make-stencil "" (cons 0 amount) '(-1 . 1)) (ly:make-stencil "" (cons amount amount) '(-1 . 1)))) +;; todo: fix negative space +(define-builtin-markup-command (vspace layout props amount) + (number?) + align + () + " +@cindex creating vertical spaces in text + +Create an invisible object taking up vertical space +of @var{amount} multiplied by 3. + +@lilypond[verbatim,quote] +\\markup { + \\center-column { + one + \\vspace #2 + two + \\vspace #5 + three + } +} +@end lilypond" + (let ((amount (* amount 3.0))) + (if (> amount 0) + (ly:make-stencil "" (cons -1 1) (cons 0 amount)) + (ly:make-stencil "" (cons -1 1) (cons amount amount))))) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; importing graphics. @@ -395,7 +532,13 @@ normally inserted before elements on a line. " @cindex importing stencils into text -Use a stencil as markup." +Use a stencil as markup. + +@lilypond[verbatim,quote] +\\markup { + \\stencil #(make-circle-stencil 2 0 #t) +} +@end lilypond" stil) (define bbox-regexp @@ -405,12 +548,12 @@ Use a stencil as markup." "Extract the bbox from STRING, or return #f if not present." (let* ((match (regexp-exec bbox-regexp string))) - + (if match (map (lambda (x) (string->number (match:substring match x))) (cdr (iota 5))) - + #f))) (define-builtin-markup-command (epsfile layout props axis size file-name) @@ -442,60 +585,27 @@ Inline an EPS image. The image is scaled along @var{axis} to () " @cindex inserting PostScript directly into text - This inserts @var{str} directly into the output as a PostScript -command string. Due to technicalities of the output backends, -different scales should be used for the @TeX{} and PostScript backend, -selected with @code{-f}. - -For the @TeX{} backend, the following string prints a rotated text - -@example -0 0 moveto /ecrm10 findfont -1.75 scalefont setfont 90 rotate (hello) show -@end example - -@noindent -The magical constant 1.75 scales from LilyPond units (staff spaces) to -@TeX{} dimensions. - -For the postscript backend, use the following - -@example -gsave /ecrm10 findfont - 10.0 output-scale div - scalefont setfont 90 rotate (hello) show grestore -@end example +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 @@ -513,7 +623,7 @@ grestore (define-builtin-markup-command (score layout props score) (ly:score?) music - () + ((baseline-skip)) " @cindex inserting music into text @@ -558,11 +668,13 @@ Inline an image of music. } } @end lilypond" - (let* ((output (ly:score-embedded-format score layout))) + (let ((output (ly:score-embedded-format score layout))) (if (ly:music-output? output) - (paper-system-stencil - (vector-ref (ly:paper-score-paper-systems output) 0)) + (stack-stencils Y DOWN baseline-skip + (map paper-system-stencil + (vector->list + (ly:paper-score-paper-systems output)))) (begin (ly:warning (_"no systems found in \\score markup, does it have a \\layout block?")) empty-stencil)))) @@ -597,6 +709,9 @@ An empty markup with extents of a single point. A simple text string; @code{\\markup @{ foo @}} is equivalent with @code{\\markup @{ \\simple #\"foo\" @}}. +Note: for creating standard text markup or defining new markup commands, +the use of @code{\\simple} is unnecessary. + @lilypond[verbatim,quote] \\markup { \\simple #\"simple\" @@ -628,7 +743,7 @@ Like simple-markup, but use tie characters for @q{~} tilde symbols. (join-stencil (interpret-markup layout props tie-str)) ) - (interpret-markup layout + (interpret-markup layout (prepend-alist-chain 'word-space (/ (interval-length (ly:stencil-extent join-stencil X)) -3.5) @@ -651,10 +766,10 @@ Like simple-markup, but use tie characters for @q{~} tilde symbols. Return a list of paddings." (cond ((null? text-widths) '()) - + ;; special case first padding ((= (length text-widths) word-count) - (cons + (cons (- (- (/ line-width (1- word-count)) (car text-widths)) (/ (car (cdr text-widths)) 2)) (get-fill-space word-count line-width (cdr text-widths)))) @@ -663,12 +778,12 @@ Like simple-markup, but use tie characters for @q{~} tilde symbols. (list (- (/ line-width (1- word-count)) (+ (/ (car text-widths) 2) (car (cdr text-widths)))) 0)) (else - (cons + (cons (- (/ line-width (1- word-count)) (/ (+ (car text-widths) (car (cdr text-widths))) 2)) (get-fill-space word-count line-width (cdr text-widths)))))) -(define-builtin-markup-command (fill-line layout props markups) +(define-builtin-markup-command (fill-line layout props args) (markup-list?) align ((text-direction RIGHT) @@ -695,7 +810,7 @@ If there are no arguments, return an empty stencil. } } @end lilypond" - (let* ((orig-stencils (interpret-markup-list layout props markups)) + (let* ((orig-stencils (interpret-markup-list layout props args)) (stencils (map (lambda (stc) (if (ly:stencil-empty? stc) @@ -713,14 +828,14 @@ If there are no arguments, return an empty stencil. (line-width (or line-width (ly:output-def-lookup layout 'line-width))) (fill-space (cond - ((= word-count 1) + ((= word-count 1) (list (/ (- line-width text-width) 2) (/ (- line-width text-width) 2))) ((= word-count 2) (list (- line-width text-width))) - (else + (else (get-fill-space word-count line-width text-widths)))) (fill-space-normal (map (lambda (x) @@ -728,7 +843,7 @@ If there are no arguments, return an empty stencil. word-space x)) fill-space)) - + (line-stencils (if (= word-count 1) (list point-stencil @@ -743,19 +858,19 @@ If there are no arguments, return an empty stencil. empty-stencil (stack-stencils-padding-list X RIGHT fill-space-normal line-stencils)))) - + (define-builtin-markup-command (line layout props args) (markup-list?) align ((word-space) (text-direction RIGHT)) "Put @var{args} in a horizontal line. The property @code{word-space} -determines the space between each markup in @var{args}. +determines the space between markups in @var{args}. @lilypond[verbatim,quote] \\markup { \\line { - A simple line of text + one two three } } @end lilypond" @@ -774,20 +889,17 @@ determines the space between each markup in @var{args}. @cindex concatenating text @cindex ligatures in text -Concatenate @var{args} in a horizontal line, without spaces inbetween. +Concatenate @var{args} in a horizontal line, without spaces in between. Strings and simple markups are concatenated on the input level, allowing ligatures. For example, @code{\\concat @{ \"f\" \\simple #\"i\" @}} is equivalent to @code{\"fi\"}. @lilypond[verbatim,quote] \\markup { - \\bold { - au - \\concat { - Mouv - \\super - t - } + \\concat { + one + two + three } } @end lilypond" @@ -812,7 +924,7 @@ equivalent to @code{\"fi\"}. (define (wordwrap-stencils stencils justify base-space line-width text-dir) - "Perform simple wordwrap, return stencil of each line." + "Perform simple wordwrap, return stencil of each line." (define space (if justify ;; justify only stretches lines. (* 0.7 base-space) @@ -842,7 +954,7 @@ equivalent to @code{\"fi\"}. line-stencils)))) (line-word-space (cond ((not justify) space) ;; don't stretch last line of paragraph. - ;; hmmm . bug - will overstretch the last line in some case. + ;; hmmm . bug - will overstretch the last line in some case. ((null? (cdr line-break)) base-space) ((null? line-stencils) 0.0) @@ -886,9 +998,20 @@ equivalent to @code{\"fi\"}. " @cindex justifying text -Like wordwrap, but with lines stretched to justify the margins. +Like @code{\\wordwrap}, but with lines stretched to justify the margins. Use @code{\\override #'(line-width . @var{X})} to set the line width; -@var{X}@tie{}is the number of staff spaces." +@var{X}@tie{}is the number of staff spaces. + +@lilypond[verbatim,quote] +\\markup { + \\justify { + 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. + } +} +@end lilypond" (stack-lines DOWN 0.0 baseline-skip (wordwrap-internal-markup-list layout props #t args))) @@ -898,7 +1021,18 @@ Use @code{\\override #'(line-width . @var{X})} to set the line width; ((baseline-skip) wordwrap-internal-markup-list) "Simple wordwrap. Use @code{\\override #'(line-width . @var{X})} to set -the line width, where @var{X} is the number of staff spaces." +the line width, where @var{X} is the number of staff spaces. + +@lilypond[verbatim,quote] +\\markup { + \\wordwrap { + 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. + } +} +@end lilypond" (stack-lines DOWN 0.0 baseline-skip (wordwrap-internal-markup-list layout props #f args))) @@ -934,7 +1068,24 @@ the line width, where @var{X} is the number of staff spaces." align ((baseline-skip) wordwrap-string-internal-markup-list) - "Wordwrap a string. Paragraphs may be separated with double newlines." + "Wordwrap a string. Paragraphs may be separated with double newlines. + +@lilypond[verbatim,quote] +\\markup { + \\override #'(line-width . 40) + \\wordwrap-string #\"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. + + + Excepteur sint occaecat cupidatat non proident, sunt in culpa + qui officia deserunt mollit anim id est laborum\" +} +@end lilypond" (stack-lines DOWN 0.0 baseline-skip (wordwrap-string-internal-markup-list layout props #f arg))) @@ -943,7 +1094,24 @@ the line width, where @var{X} is the number of staff spaces." align ((baseline-skip) wordwrap-string-internal-markup-list) - "Justify a string. Paragraphs may be separated with double newlines" + "Justify a string. Paragraphs may be separated with double newlines + +@lilypond[verbatim,quote] +\\markup { + \\override #'(line-width . 40) + \\justify-string #\"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. + + + Excepteur sint occaecat cupidatat non proident, sunt in culpa + qui officia deserunt mollit anim id est laborum\" +} +@end lilypond" (stack-lines DOWN 0.0 baseline-skip (wordwrap-string-internal-markup-list layout props #t arg))) @@ -951,7 +1119,31 @@ the line width, where @var{X} is the number of staff spaces." (symbol?) align () - "Wordwrap the data which has been assigned to @var{symbol}." + "Wordwrap the data which has been assigned to @var{symbol}. + +@lilypond[verbatim,quote] +\\header { + title = \"My title\" + 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.\" +} + +\\paper { + bookTitleMarkup = \\markup { + \\column { + \\fill-line { \\fromproperty #'header:title } + \\null + \\wordwrap-field #'header:myText + } + } +} + +\\markup { + \\null +} +@end lilypond" (let* ((m (chain-assoc-get symbol props))) (if (string? m) (wordwrap-string-markup layout props m) @@ -961,13 +1153,37 @@ the line width, where @var{X} is the number of staff spaces." (symbol?) align () - "Justify the data which has been assigned to @var{symbol}." + "Justify the data which has been assigned to @var{symbol}. + +@lilypond[verbatim,quote] +\\header { + title = \"My title\" + 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.\" +} + +\\paper { + bookTitleMarkup = \\markup { + \\column { + \\fill-line { \\fromproperty #'header:title } + \\null + \\justify-field #'header:myText + } + } +} + +\\markup { + \\null +} +@end lilypond" (let* ((m (chain-assoc-get symbol props))) (if (string? m) (justify-string-markup layout props m) empty-stencil))) -(define-builtin-markup-command (combine layout props m1 m2) +(define-builtin-markup-command (combine layout props arg1 arg2) (markup? markup?) align () @@ -975,22 +1191,30 @@ the line width, where @var{X} is the number of staff spaces." @cindex merging text Print two markups on top of each other. + +Note: @code{\\combine} cannot take a list of markups enclosed in +curly braces as an argument; the follow example will not compile: + +@example +\\combine @{ a list @} +@end example + @lilypond[verbatim,quote] \\markup { \\fontsize #5 \\override #'(thickness . 2) \\combine - \\draw-line #'(0 . 4) - \\arrow-head #Y #DOWN ##f + \\draw-line #'(0 . 4) + \\arrow-head #Y #DOWN ##f } @end lilypond" - (let* ((s1 (interpret-markup layout props m1)) - (s2 (interpret-markup layout props m2))) + (let* ((s1 (interpret-markup layout props arg1)) + (s2 (interpret-markup layout props arg2))) (ly:stencil-add s1 s2))) ;; ;; TODO: should extract baseline-skip from each argument somehow.. -;; +;; (define-builtin-markup-command (column layout props args) (markup-list?) align @@ -999,8 +1223,8 @@ Print two markups on top of each other. @cindex stacking text in a column Stack the markups in @var{args} vertically. The property -@code{baseline-skip} determines the space between each -markup in @var{args}. +@code{baseline-skip} determines the space between markups +in @var{args}. @lilypond[verbatim,quote] \\markup { @@ -1023,19 +1247,26 @@ markup in @var{args}. " @cindex changing direction of text columns -Make a column of args, going up or down, depending on the setting -of the @code{#'direction} layout property. +Make a column of @var{args}, going up or down, depending on the +setting of the @code{direction} layout property. @lilypond[verbatim,quote] \\markup { - \\override #'(direction . 1) { + \\override #`(direction . ,UP) { \\dir-column { going up } } + \\hspace #1 \\dir-column { going down } + \\hspace #1 + \\override #'(direction . 1) { + \\dir-column { + going up + } + } } @end lilypond" (stack-lines (if (number? direction) direction -1) @@ -1043,7 +1274,13 @@ of the @code{#'direction} layout property. baseline-skip (interpret-markup-list layout props args))) -(define-builtin-markup-command (center-align layout props args) +(define (general-column align-dir baseline mols) + "Stack @var{mols} vertically, aligned to @var{align-dir} horizontally." + + (let* ((aligned-mols (map (lambda (x) (ly:stencil-aligned-to x X align-dir)) mols))) + (stack-lines -1 0.0 baseline aligned-mols))) + +(define-builtin-markup-command (center-column layout props args) (markup-list?) align ((baseline-skip)) @@ -1054,16 +1291,54 @@ Put @code{args} in a centered column. @lilypond[verbatim,quote] \\markup { - \\center-align { + \\center-column { + one + two + three + } +} +@end lilypond" + (general-column CENTER baseline-skip (interpret-markup-list layout props args))) + +(define-builtin-markup-command (left-column layout props args) + (markup-list?) + align + ((baseline-skip)) + " +@cindex text columns, left-aligned + +Put @code{args} in a left-aligned column. + +@lilypond[verbatim,quote] +\\markup { + \\left-column { + one + two + three + } +} +@end lilypond" + (general-column LEFT baseline-skip (interpret-markup-list layout props args))) + +(define-builtin-markup-command (right-column layout props args) + (markup-list?) + align + ((baseline-skip)) + " +@cindex text columns, right-aligned + +Put @code{args} in a right-aligned column. + +@lilypond[verbatim,quote] +\\markup { + \\right-column { one two three } } @end lilypond" - (let* ((mols (interpret-markup-list layout props args)) - (cmols (map (lambda (x) (ly:stencil-aligned-to x X CENTER)) mols))) - (stack-lines -1 0.0 baseline-skip cmols))) + (general-column RIGHT baseline-skip (interpret-markup-list layout props args))) (define-builtin-markup-command (vcenter layout props arg) (markup?) @@ -1076,16 +1351,16 @@ Align @code{arg} to its Y@tie{}center. @lilypond[verbatim,quote] \\markup { - \\arrow-head #X #RIGHT ##f + one \\vcenter - Centered - \\arrow-head #X #LEFT ##f + two + three } @end lilypond" (let* ((mol (interpret-markup layout props arg))) (ly:stencil-aligned-to mol Y CENTER))) -(define-builtin-markup-command (hcenter layout props arg) +(define-builtin-markup-command (center-align layout props arg) (markup?) align () @@ -1097,9 +1372,10 @@ Align @code{arg} to its X@tie{}center. @lilypond[verbatim,quote] \\markup { \\column { - ↓ - \\hcenter - centered + one + \\center-align + two + three } } @end lilypond" @@ -1118,9 +1394,10 @@ Align @var{arg} on its right edge. @lilypond[verbatim,quote] \\markup { \\column { - ↓ + one \\right-align - right-aligned + two + three } } @end lilypond" @@ -1139,9 +1416,10 @@ Align @var{arg} on its left edge. @lilypond[verbatim,quote] \\markup { \\column { - ↓ + one \\left-align - left-aligned + two + three } } @end lilypond" @@ -1155,7 +1433,37 @@ Align @var{arg} on its left edge. " @cindex controlling general text alignment -Align @var{arg} in @var{axis} direction to the @var{dir} side." +Align @var{arg} in @var{axis} direction to the @var{dir} side. + +@lilypond[verbatim,quote] +\\markup { + \\column { + one + \\general-align #X #LEFT + two + three + \\null + one + \\general-align #X #CENTER + two + three + \\null + \\line { + one + \\general-align #Y #UP + two + three + } + \\null + \\line { + one + \\general-align #Y #3.2 + two + three + } + } +} +@end lilypond" (let* ((m (interpret-markup layout props arg))) (ly:stencil-aligned-to m axis dir))) @@ -1173,20 +1481,25 @@ alignment accordingly. @lilypond[verbatim,quote] \\markup { \\column { - ↓ + one \\halign #LEFT - Left - ↓ + two + three + \\null + one \\halign #CENTER - Center - ↓ + two + three + \\null + one \\halign #RIGHT - Right - ↓ - \\halign #1.2 - \\line { - Arbitrary alignment - } + two + three + \\null + one + \\halign #-5 + two + three } } @end lilypond" @@ -1200,7 +1513,7 @@ alignment accordingly. " @cindex setting extent of text objects -Set the dimensions of @var{arg} to @var{x} and@tie{}@var{y}." +Set the dimensions of @var{arg} to @var{x} and@tie{}@var{y}." (let* ((m (interpret-markup layout props arg))) (ly:make-stencil (ly:stencil-expr m) x y))) @@ -1208,7 +1521,21 @@ Set the dimensions of @var{arg} to @var{x} and@tie{}@var{y}." (number? markup?) align () - "Add padding @var{amount} all around @var{arg}." + "Add padding @var{amount} all around @var{arg}. + +@lilypond[verbatim,quote] +\\markup { + \\box { + default + } + \\hspace #2 + \\box { + \\pad-around #0.5 { + padded + } + } +} +@end lilypond" (let* ((m (interpret-markup layout props arg)) (x (ly:stencil-extent m X)) (y (ly:stencil-extent m Y))) @@ -1223,7 +1550,21 @@ Set the dimensions of @var{arg} to @var{x} and@tie{}@var{y}." " @cindex padding text horizontally -Add padding @var{amount} around @var{arg} in the X@tie{}direction." +Add padding @var{amount} around @var{arg} in the X@tie{}direction. + +@lilypond[verbatim,quote] +\\markup { + \\box { + default + } + \\hspace #4 + \\box { + \\pad-x #2 { + padded + } + } +} +@end lilypond" (let* ((m (interpret-markup layout props arg)) (x (ly:stencil-extent m X)) (y (ly:stencil-extent m Y))) @@ -1231,8 +1572,8 @@ Add padding @var{amount} around @var{arg} in the X@tie{}direction." (interval-widen x amount) y))) -(define-builtin-markup-command (put-adjacent layout props arg1 axis dir arg2) - (markup? integer? ly:dir? markup?) +(define-builtin-markup-command (put-adjacent layout props axis dir arg1 arg2) + (integer? ly:dir? markup? markup?) align () "Put @var{arg2} next to @var{arg1}, without moving @var{arg1}." @@ -1244,7 +1585,15 @@ Add padding @var{amount} around @var{arg} in the X@tie{}direction." (markup?) other () - "Make the argument transparent." + "Make @var{arg} transparent. + +@lilypond[verbatim,quote] +\\markup { + \\transparent { + invisible text + } +} +@end lilypond" (let* ((m (interpret-markup layout props arg)) (x (ly:stencil-extent m X)) (y (ly:stencil-extent m Y))) @@ -1254,7 +1603,21 @@ Add padding @var{amount} around @var{arg} in the X@tie{}direction." (number-pair? number-pair? markup?) align () - "Make @var{arg} take at least @var{x-ext}, @var{y-ext} space." + "Make @var{arg} take at least @var{x-ext}, @var{y-ext} space. + +@lilypond[verbatim,quote] +\\markup { + \\box { + default + } + \\hspace #4 + \\box { + \\pad-to-box #'(0 . 10) #'(0 . 3) { + padded + } + } +} +@end lilypond" (let* ((m (interpret-markup layout props arg)) (x (ly:stencil-extent m X)) (y (ly:stencil-extent m Y))) @@ -1267,12 +1630,32 @@ Add padding @var{amount} around @var{arg} in the X@tie{}direction." align () "Center @var{arg} horizontally within a box of extending -@var{length}/2 to the left and right." +@var{length}/2 to the left and right. + +@lilypond[quote,verbatim] +\\new StaffGroup << + \\new Staff { + \\set Staff.instrumentName = \\markup { + \\hcenter-in #12 + Oboe + } + c''1 + } + \\new Staff { + \\set Staff.instrumentName = \\markup { + \\hcenter-in #12 + Bassoon + } + \\clef tenor + c'1 + } +>> +@end lilypond" (interpret-markup layout props (make-pad-to-box-markup (cons (/ length -2) (/ length 2)) '(0 . 0) - (make-hcenter-markup arg)))) + (make-center-align-markup arg)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; property @@ -1284,7 +1667,21 @@ Add padding @var{amount} around @var{arg} in the X@tie{}direction." () "Read the @var{symbol} from property settings, and produce a stencil from the markup contained within. If @var{symbol} is not defined, it -returns an empty markup." +returns an empty markup. + +@lilypond[verbatim,quote] +\\header { + myTitle = \"myTitle\" + title = \\markup { + from + \\italic + \\fromproperty #'header:myTitle + } +} +\\markup { + \\null +} +@end lilypond" (let ((m (chain-assoc-get symbol props))) (if (markup? m) (interpret-markup layout props m) @@ -1309,13 +1706,28 @@ returns an empty markup." " @cindex overriding properties within text markup -Add the first argument in to the property list. Properties may be -any sort of property supported by @rinternals{font-interface} and -@rinternals{text-interface}, for example +Add the argument @var{new-prop} to the property list. Properties +may be any property supported by @rinternals{font-interface}, +@rinternals{text-interface} and +@rinternals{instrument-specific-markup-interface}. -@example -\\override #'(font-family . married) \"bla\" -@end example" +@lilypond[verbatim,quote] +\\markup { + \\line { + \\column { + default + baseline-skip + } + \\hspace #2 + \\override #'(baseline-skip . 4) { + \\column { + increased + baseline-skip + } + } + } +} +@end lilypond" (interpret-markup layout (cons (list new-prop) props) arg)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1326,11 +1738,12 @@ any sort of property supported by @rinternals{font-interface} and (string?) other () - "Read the contents of a file, and include it verbatim. + "Read the contents of file @var{name}, and include it verbatim. @lilypond[verbatim,quote] \\markup { \\verbatim-file #\"simple.ly\" +} @end lilypond" (interpret-markup layout props (if (ly:get-option 'safe) @@ -1344,34 +1757,13 @@ any sort of property supported by @rinternals{font-interface} and ;; fonts. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(define-builtin-markup-command (bigger layout props arg) - (markup?) - font - () - "Increase the font size relative to current setting. - -@lilypond[verbatim,quote] -\\markup { - \\huge { - huge - \\hspace #2 - \\bigger { - bigger - } - \\hspace #2 - huge - } -} -@end lilypond" - (interpret-markup layout props - `(,fontsize-markup 1 ,arg))) (define-builtin-markup-command (smaller layout props arg) (markup?) font () - "Decrease the font size relative to current setting. - + "Decrease the font size relative to the current setting. + @lilypond[verbatim,quote] \\markup { \\fontsize #3.5 { @@ -1392,7 +1784,7 @@ any sort of property supported by @rinternals{font-interface} and (markup?) font () - "Copy of the @code{\\bigger} command. + "Increase the font size relative to the current setting. @lilypond[verbatim,quote] \\markup { @@ -1402,13 +1794,15 @@ any sort of property supported by @rinternals{font-interface} and larger } @end lilypond" - (interpret-markup layout props (make-bigger-markup arg))) + (interpret-markup layout props + `(,fontsize-markup 1 ,arg))) (define-builtin-markup-command (finger layout props arg) (markup?) font () - "Set the argument as small numbers. + "Set @var{arg} as small numbers. + @lilypond[verbatim,quote] \\markup { \\finger { @@ -1425,7 +1819,8 @@ any sort of property supported by @rinternals{font-interface} and font () "Use @var{size} as the absolute font size to display @var{arg}. -Adjust baseline skip and word space accordingly. +Adjusts @code{baseline-skip} and @code{word-space} accordingly. + @lilypond[verbatim,quote] \\markup { default text font size @@ -1453,7 +1848,9 @@ Adjust baseline skip and word space accordingly. ((font-size 0) (word-space 1) (baseline-skip 2)) - "Add @var{increment} to the font-size. Adjust baseline skip accordingly. + "Add @var{increment} to the font-size. Adjusts @code{baseline-skip} +accordingly. + @lilypond[verbatim,quote] \\markup { default @@ -1495,7 +1892,7 @@ Use @code{\\fontsize} otherwise. } @end lilypond" (interpret-markup - layout + layout (prepend-alist-chain 'font-size (magnification->font-size sz) props) arg)) @@ -1504,7 +1901,7 @@ Use @code{\\fontsize} otherwise. font () "Switch to bold font-series. - + @lilypond[verbatim,quote] \\markup { default @@ -1519,8 +1916,8 @@ Use @code{\\fontsize} otherwise. (markup?) font () - "Switch to the sans serif family. - + "Switch to the sans serif font family. + @lilypond[verbatim,quote] \\markup { default @@ -1537,8 +1934,8 @@ Use @code{\\fontsize} otherwise. font () "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. +time signatures and fingerings. This font contains numbers and +some punctuation; it has no letters. @lilypond[verbatim,quote] \\markup { @@ -1554,7 +1951,7 @@ some punctuation. It doesn't have any letters. font () "Set font family to @code{roman}. - + @lilypond[verbatim,quote] \\markup { \\sans \\bold { @@ -1607,7 +2004,7 @@ some punctuation. It doesn't have any letters. font () "Set font size to default. - + @lilypond[verbatim,quote] \\markup { \\teeny { @@ -1628,7 +2025,7 @@ some punctuation. It doesn't have any letters. font () "Set font size to -1. - + @lilypond[verbatim,quote] \\markup { default @@ -1644,7 +2041,7 @@ some punctuation. It doesn't have any letters. font () "Set font size to -2. - + @lilypond[verbatim,quote] \\markup { default @@ -1660,7 +2057,7 @@ some punctuation. It doesn't have any letters. font () "Set font size to -3. - + @lilypond[verbatim,quote] \\markup { default @@ -1675,11 +2072,14 @@ some punctuation. It doesn't have any letters. (markup?) font () - "Set @code{font-shape} to @code{caps}" + "Set @code{font-shape} to @code{caps} + +Note: @code{\\fontCaps} requires the installation and selection of +fonts which support the @code{caps} font shape." (interpret-markup layout (prepend-alist-chain 'font-shape 'caps props) arg)) ;; Poor man's caps -(define-builtin-markup-command (smallCaps layout props text) +(define-builtin-markup-command (smallCaps layout props arg) (markup?) font () @@ -1723,9 +2123,9 @@ Note: @code{\\smallCaps} does not support accented characters. currents current-is-lower) prev-result))))))) (interpret-markup layout props - (if (string? text) - (make-small-caps (string->list text) (list) #f (list)) - text))) + (if (string? arg) + (make-small-caps (string->list arg) (list) #f (list)) + arg))) (define-builtin-markup-command (caps layout props arg) (markup?) @@ -1767,7 +2167,7 @@ done in a different font. The recommended font for this is bold and italic. font () "Use a text font instead of music symbol or music alphabet font. - + @lilypond[verbatim,quote] \\markup { \\number { @@ -1805,7 +2205,7 @@ done in a different font. The recommended font for this is bold and italic. font () "Use @code{font-family} typewriter for @var{arg}. - + @lilypond[verbatim,quote] \\markup { default @@ -1821,7 +2221,8 @@ done in a different font. The recommended font for this is bold and italic. (markup?) font () - "Set font shape to @code{upright}. This is the opposite of @code{italic}. + "Set @code{font-shape} to @code{upright}. This is the opposite +of @code{italic}. @lilypond[verbatim,quote] \\markup { @@ -1843,7 +2244,7 @@ done in a different font. The recommended font for this is bold and italic. (markup?) font () - "Switch to medium font series (in contrast to bold). + "Switch to medium font-series (in contrast to bold). @lilypond[verbatim,quote] \\markup { @@ -1916,7 +2317,7 @@ normal text font, no matter what font was used earlier. \\sesquisharp } @end lilypond" - (interpret-markup layout props (markup #:musicglyph (assoc-get 3/4 standard-alteration-glyph-name-alist "")))) + (interpret-markup layout props (markup #:musicglyph (assoc-get 3/4 standard-alteration-glyph-name-alist "")))) (define-builtin-markup-command (sharp layout props) () @@ -1935,7 +2336,7 @@ normal text font, no matter what font was used earlier. () music () - "Draw a semi sharp symbol. + "Draw a semisharp symbol. @lilypond[verbatim,quote] \\markup { @@ -2016,17 +2417,30 @@ normal text font, no matter what font was used earlier. " @cindex coloring text -Draw @var{arg} in color specified by @var{color}." +Draw @var{arg} in color specified by @var{color}. + +@lilypond[verbatim,quote] +\\markup { + \\with-color #red + red + \\hspace #2 + \\with-color #green + green + \\hspace #2 + \\with-color #blue + blue +} +@end lilypond" (let ((stil (interpret-markup layout props arg))) (ly:make-stencil (list 'color color (ly:stencil-expr stil)) (ly:stencil-extent stil X) (ly:stencil-extent stil Y)))) - + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; glyphs ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(define-builtin-markup-command (arrow-head layout props axis direction filled) +(define-builtin-markup-command (arrow-head layout props axis dir filled) (integer? ly:dir? boolean?) graphic () @@ -2051,7 +2465,7 @@ Use the filled head if @var{filled} is specified. "close" "open") axis - direction))) + dir))) (ly:font-get-glyph (ly:paper-get-font layout (cons '((font-encoding . fetaMusic)) props)) @@ -2076,7 +2490,7 @@ the possible glyphs. (let* ((font (ly:paper-get-font layout (cons '((font-encoding . fetaMusic) (font-name . #f)) - + props))) (glyph (ly:font-get-glyph font glyph-name))) (if (null? (ly:stencil-expr glyph)) @@ -2090,7 +2504,7 @@ the possible glyphs. other () "Lookup a glyph by name. - + @lilypond[verbatim,quote] \\markup { \\override #'(font-encoding . fetaBraces) { @@ -2108,8 +2522,14 @@ the possible glyphs. (integer?) other () - "Produce a single character. For example, @code{\\char #65} produces the -letter @q{A}." + "Produce a single character. Characters encoded in hexadecimal +format require the prefix @code{#x}. + +@lilypond[verbatim,quote] +\\markup { + \\char #65 \\char ##x00a9 +} +@end lilypond" (ly:text-interface::interpret-markup layout props (ly:wide-char->utf-8 num))) (define number->mark-letter-vector (make-vector 25 #\A)) @@ -2128,7 +2548,7 @@ letter @q{A}." (define (number->markletter-string vec n) "Double letters for big marks." (let* ((lst (vector-length vec))) - + (if (>= n lst) (string-append (number->markletter-string vec (1- (quotient n lst))) (number->markletter-string vec (remainder n lst))) @@ -2169,7 +2589,6 @@ and continue with double letters. (number->markletter-string number->mark-alphabet-vector num))) (define-public (horizontal-slash-interval num forward number-interval mag) - (ly:message "Mag step: ~a" mag) (if forward (cond ;((= num 6) (interval-widen number-interval (* mag 0.5))) ;((= num 5) (interval-widen number-interval (* mag 0.5))) @@ -2215,13 +2634,10 @@ and continue with double letters. (num-y (interval-widen (cons center center) (abs dy))) (is-sane (and (interval-sane? num-x) (interval-sane? num-y))) (slash-stencil (if is-sane - (ly:make-stencil - `(draw-line ,thickness - ,(car num-x) ,(- (interval-center num-y) dy) - ,(cdr num-x) ,(+ (interval-center num-y) dy)) - num-x num-y) + (make-line-stencil thickness + (car num-x) (- (interval-center num-y) dy) + (cdr num-x) (+ (interval-center num-y) dy)) #f))) -(ly:message "Num: ~a, X-interval: ~a" num num-x) (if (ly:stencil? slash-stencil) (begin ; for some numbers we need to shift the slash/backslash up or down to make @@ -2273,6 +2689,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.22) '(0.2 . 2.41) + (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. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -2288,7 +2792,7 @@ figured bass notation. @cindex notes within text by log and dot-count Construct a note symbol, with stem. By using fractional values for -@var{dir}, you can obtain longer or shorter stems. +@var{dir}, longer or shorter stems can be obtained. @lilypond[verbatim,quote] \\markup { @@ -2306,14 +2810,14 @@ Construct a note symbol, with stem. By using fractional values for ""))) (list (if (= dir UP) "u" "d") "s"))) - + (define (get-glyph-name font cands) (if (null? cands) "" (if (ly:stencil-empty? (ly:font-get-glyph font (car cands))) (get-glyph-name font (cdr cands)) (car cands)))) - + (let* ((font (ly:paper-get-font layout (cons '((font-encoding . fetaMusic)) props))) (size-factor (magstep font-size)) (stem-length (* size-factor (max 3 (- log 1)))) @@ -2336,7 +2840,7 @@ Construct a note symbol, with stem. By using fractional values for (cons (min stemy (cdr attach-off)) (max stemy (cdr attach-off))) (/ stem-thickness 3)))) - + (dot (ly:font-get-glyph font "dots.dot")) (dotwid (interval-length (ly:stencil-extent dot X))) (dots (and (> dot-count 0) @@ -2372,7 +2876,7 @@ Construct a note symbol, with stem. By using fractional values for stem-glyph))) stem-glyph)) -(define-public log2 +(define-public log2 (let ((divisor (log 2))) (lambda (z) (inexact->exact (/ (log z) divisor))))) @@ -2412,7 +2916,7 @@ a shortened down stem. @end lilypond" (let ((parsed (parse-simple-duration duration))) (note-by-number-markup layout props (car parsed) (cadr parsed) dir))) - + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; translating. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -2425,20 +2929,39 @@ a shortened down stem. @cindex lowering text Lower @var{arg} by the distance @var{amount}. -A negative @var{amount} indicates raising; see also @code{\\raise}." +A negative @var{amount} indicates raising; see also @code{\\raise}. + +@lilypond[verbatim,quote] +\\markup { + one + \\lower #3 + two + three +} +@end lilypond" (ly:stencil-translate-axis (interpret-markup layout props arg) (- amount) Y)) (define-builtin-markup-command (translate-scaled layout props offset arg) (number-pair? markup?) - other + align ((font-size 0)) " @cindex translating text @cindex scaling text Translate @var{arg} by @var{offset}, scaling the offset by the -@code{font-size}." +@code{font-size}. + +@lilypond[verbatim,quote] +\\markup { + \\fontsize #5 { + * \\translate #'(2 . 3) translate + \\hspace #2 + * \\translate-scaled #'(2 . 3) translate-scaled + } +} +@end lilypond" (let* ((factor (magstep font-size)) (scaled (cons (* factor (car offset)) (* factor (cdr offset))))) @@ -2451,7 +2974,7 @@ Translate @var{arg} by @var{offset}, scaling the offset by the () " @cindex raising text - + Raise @var{arg} by the distance @var{amount}. A negative @var{amount} indicates lowering, see also @code{\\lower}. @@ -2538,11 +3061,10 @@ Set @var{arg} in superscript with a normal font size. font ((font-size 0) (baseline-skip)) - " + " @cindex superscript text -Raising and lowering texts can be done with @code{\\super} and -@code{\\sub}: +Set @var{arg} in superscript. @lilypond[verbatim,quote] \\markup { @@ -2568,18 +3090,18 @@ Raising and lowering texts can be done with @code{\\super} and () " @cindex translating text - -This translates an object. Its first argument is a cons of numbers. -@example -A \\translate #(cons 2 -3) @{ B C @} D -@end example +Translate @var{arg} relative to its surroundings. @var{offset} +is a pair of numbers representing the displacement in the X and Y axis. -This moves @q{B C} 2@tie{}spaces to the right, and 3 down, relative to its -surroundings. This command cannot be used to move isolated scripts -vertically, for the same reason that @code{\\raise} cannot be used for -that." - (ly:stencil-translate (interpret-markup layout props arg) +@lilypond[verbatim,quote] +\\markup { + * + \\translate #'(2 . 3) + \\line { translated two spaces right, three up } +} +@end lilypond" + (ly:stencil-translate (interpret-markup layout props arg) offset)) (define-builtin-markup-command (sub layout props arg) @@ -2618,7 +3140,7 @@ Set @var{arg} in subscript. " @cindex setting subscript in standard font size -Set @var{arg} in subscript, in a normal font size. +Set @var{arg} in subscript with a normal font size. @lilypond[verbatim,quote] \\markup { @@ -2632,7 +3154,7 @@ Set @var{arg} in subscript, in a normal font size. (interpret-markup layout props arg) (* -0.5 baseline-skip) Y)) - + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; brackets. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -2643,7 +3165,7 @@ Set @var{arg} in subscript, in a normal font size. () " @cindex placing horizontal brackets around text - + Draw horizontal brackets around @var{arg}. @lilypond[verbatim,quote] @@ -2665,7 +3187,7 @@ Draw horizontal brackets around @var{arg}. () " @cindex placing vertical brackets around text - + Draw vertical brackets around @var{arg}. @lilypond[verbatim,quote] @@ -2678,7 +3200,7 @@ Draw vertical brackets around @var{arg}. (let ((th 0.1) ;; todo: take from GROB. (m (interpret-markup layout props arg))) (bracketify-stencil m Y th (* 2.5 th) th))) - + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Delayed markup evaluation ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -2701,8 +3223,9 @@ when @var{label} is not found." `(delay-stencil-evaluation ,(delay (ly:stencil-expr (let* ((table (ly:output-def-lookup layout 'label-page-table)) - (label-page (and (list? table) (assoc label table))) - (page-number (and label-page (cdr label-page))) + (page-number (if (list? table) + (assoc-get label table) + #f)) (page-markup (if page-number (format "~a" page-number) default)) (page-stencil (interpret-markup layout props page-markup)) (gap (- (interval-length x-ext) @@ -2711,31 +3234,31 @@ when @var{label} is not found." (markup #:concat (#:hspace gap page-markup))))))) x-ext y-ext))) - + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Markup list commands ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define-public (space-lines baseline stils) - (let space-stil ((prev-stil #f) - (stils stils) + (let space-stil ((stils stils) (result (list))) - (cond ((null? stils) - (reverse! result)) - ((not prev-stil) - (space-stil (car stils) (cdr stils) (list (car stils)))) - (else - (let* ((stil (car stils)) - (dy (max (- baseline - (+ (- (interval-bound (ly:stencil-extent prev-stil Y) DOWN)) - (interval-bound (ly:stencil-extent stil Y) UP))) - 0.0)) - (new-stil (ly:make-stencil - (ly:stencil-expr stil) - (ly:stencil-extent stil X) - (cons (interval-bound (ly:stencil-extent stil Y) DOWN) - (+ (interval-bound (ly:stencil-extent stil Y) UP) dy))))) - (space-stil stil (cdr stils) (cons new-stil result))))))) + (if (null? stils) + (reverse! result) + (let* ((stil (car stils)) + (dy-top (max (- (/ baseline 1.5) + (interval-bound (ly:stencil-extent stil Y) UP)) + 0.0)) + (dy-bottom (max (+ (/ baseline 3.0) + (interval-bound (ly:stencil-extent stil Y) DOWN)) + 0.0)) + (new-stil (ly:make-stencil + (ly:stencil-expr stil) + (ly:stencil-extent stil X) + (cons (- (interval-bound (ly:stencil-extent stil Y) DOWN) + dy-bottom) + (+ (interval-bound (ly:stencil-extent stil Y) UP) + dy-top))))) + (space-stil (cdr stils) (cons new-stil result)))))) (define-builtin-markup-list-command (justified-lines layout props args) (markup-list?)