X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fdefine-markup-commands.scm;h=57e2e8893a26334a2d5af498ba518668b158ed03;hb=ea03bb1d323aef010eea00c1709d3dab56c0bf0b;hp=4844dcd75e321d60b5adec7849900bbfdf1be344;hpb=47db9a3883d726ca53e2133a3b2298f78dd6a32e;p=lilypond.git diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index 4844dcd75e..57e2e8893a 100644 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -509,6 +509,16 @@ in the PDF backend. (ly:stencil-add (ly:make-stencil link-expr xextent yextent) stil))) +(define-public (book-first-page layout props) + "Return the @code{'first-page-number} of the entire book" + (define (ancestor layout) + "Return the topmost layout ancestor" + (let ((parent (ly:output-def-parent layout))) + (if (not (ly:output-def? parent)) + layout + (ancestor parent)))) + (ly:output-def-lookup (ancestor layout) 'first-page-number)) + (define-markup-command (with-link layout props label arg) (symbol? markup?) #:category other @@ -529,18 +539,23 @@ only works in the PDF backend. (x-ext (ly:stencil-extent arg-stencil X)) (y-ext (ly:stencil-extent arg-stencil Y))) (ly:stencil-add - (ly:make-stencil - `(delay-stencil-evaluation - ,(delay (let* ((table (ly:output-def-lookup layout 'label-page-table)) - (page-number (if (list? table) - (assoc-get label table) - #f))) - (list 'page-link page-number - `(quote ,x-ext) `(quote ,y-ext))))) - x-ext - y-ext) - arg-stencil))) - + (ly:make-stencil + `(delay-stencil-evaluation + ,(delay (let* ((table (ly:output-def-lookup layout 'label-page-table)) + (table-page-number + (if (list? table) + (assoc-get label table) + #f)) + (first-page-number (book-first-page layout props)) + (current-page-number + (if table-page-number + (1+ (- table-page-number first-page-number)) + #f))) + (list 'page-link current-page-number + `(quote ,x-ext) `(quote ,y-ext))))) + x-ext + y-ext) + arg-stencil))) (define-markup-command (beam layout props width slope thickness) (number? number? number?) @@ -707,6 +722,7 @@ Rotate object with @var{ang} degrees around its center. (define-markup-command (whiteout layout props arg) (markup?) #:category other + #:properties ((thickness 3)) " @cindex adding a white background to text @@ -716,10 +732,34 @@ Provide a white background for @var{arg}. \\markup { \\combine \\filled-box #'(-1 . 10) #'(-3 . 4) #1 - \\whiteout whiteout + \\override #'(thickness . 1.5) \\whiteout whiteout +} +@end lilypond" + (stencil-whiteout + (interpret-markup layout props arg) + (* thickness + (ly:output-def-lookup layout 'line-thickness)))) + +(define-markup-command (whiteout-box layout props arg) + (markup?) + #:category other + #:properties ((thickness 0)) + " +@cindex adding a rectangular white background to text + +Provide a rectangular white background for @var{arg}. + +@lilypond[verbatim,quote] +\\markup { + \\combine + \\filled-box #'(-1 . 10) #'(-3 . 4) #1 + \\override #'(thickness . 1.5) \\whiteout-box whiteout-box } @end lilypond" - (stencil-whiteout (interpret-markup layout props arg))) + (stencil-whiteout-box + (interpret-markup layout props arg) + (* thickness + (ly:output-def-lookup layout 'line-thickness)))) (define-markup-command (pad-markup layout props amount arg) (number? markup?) @@ -1700,11 +1740,7 @@ the line width, where @var{X} is the number of staff spaces. 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 +curly braces as an argument; for this purpose use @code{\\overlay} instead. @lilypond[verbatim,quote] \\markup { @@ -1719,6 +1755,27 @@ curly braces as an argument; the follow example will not compile: (s2 (interpret-markup layout props arg2))) (ly:stencil-add s1 s2))) +(define-markup-command (overlay layout props args) + (markup-list?) + #:category align + " +@cindex merging text + +Takes a list of markups combining them. + +@lilypond[verbatim,quote] +\\markup { + \\fontsize #5 + \\override #'(thickness . 2) + \\overlay { + \\draw-line #'(0 . 4) + \\arrow-head #Y #DOWN ##f + \\translate #'(0 . 4)\\arrow-head #Y #UP ##f + } +} +@end lilypond" + (apply ly:stencil-add (interpret-markup-list layout props args))) + ;; ;; TODO: should extract baseline-skip from each argument somehow.. ;; @@ -3468,24 +3525,17 @@ Supported flag-styles are @code{default}, @code{old-straight-flag}, (thickness-offset (cons 0 (* -1 thickness dir))) (spacing (* -1 flag-spacing factor dir)) (start (cons (- half-stem-thickness) (* half-stem-thickness dir))) - ;; The points of a round-filled-polygon need to be given in - ;; clockwise order, otherwise the polygon will be enlarged by - ;; blot-size*2! - (points (if stem-up - (list start - flag-end - (offset-add flag-end thickness-offset) - (offset-add start thickness-offset)) - (list start - (offset-add start thickness-offset) - (offset-add flag-end thickness-offset) - flag-end))) + (points (list start + flag-end + (offset-add flag-end thickness-offset) + (offset-add start thickness-offset))) (stencil (ly:round-filled-polygon points half-stem-thickness)) ;; Log for 1/8 is 3, so we need to subtract 3 (flag-stencil (buildflags stencil (- log 3) stencil spacing))) flag-stencil)) - (let* ((font (ly:paper-get-font layout (cons '((font-encoding . fetaMusic)) + (let* ((font (ly:paper-get-font layout (cons '((font-encoding . fetaMusic) + (font-name . #f)) props))) (size-factor (magstep font-size)) (blot (ly:output-def-lookup layout 'blot-diameter)) @@ -3701,7 +3751,9 @@ A rest or multi-measure-rest symbol. (let* ((font (ly:paper-get-font layout - (cons '((font-encoding . fetaMusic)) props))) + (cons '((font-encoding . fetaMusic) + (font-name . #f)) + props))) (rest-glyph-name (let ((result (get-glyph-name font