|
From: | Ben |
Subject: | Re: "Text spanner"-ish thing with text in the middle |
Date: | Sat, 28 Oct 2017 09:24:35 -0400 |
User-agent: | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 |
On 10/28/2017 1:43 AM, Andrew Bernard wrote:Hi James, This comes up so frequently it puzzles me why it is not considered for addition to the lilypond baseline. Here's my function. Andrew === snip \version "2.19.39" % Annotation bracket with centred text. % Andrew Bernard and Thomas Morley TextSpannerCentredText = #(define-music-function (text extra-length) (string? pair?) "Use TextSpanner semantics to create spanner brackets with centred text" #{ \once \override TextSpanner.after-line-breaking = #(lambda (grob) (let* ( ;; get stencil of grob (stil (ly:grob-property grob 'stencil)) ;; get spanner length (spanner-len (interval-length (ly:stencil-extent stil X))) ;; make stencil from text arg (text-stil (grob-interpret-markup grob (markup #:sans #:upright text))) ;; get text length (text-len (interval-length (ly:stencil-extent text-stil X)))) ...................................etc........................ Andrew, Thank you so much for sharing this function. It will come in handy for a project I'll be working on shortly. However, I had one question for you. I just went to try to use the function 'as is' and I'm seeing an error. I cannot use the function at the moment. Do you know what this means, and how I can fix it? (I just simply copied and pasted it into Frescobaldi and attempted to use it - no tweaks) Thanks! Drawing systems... line:31 32:15: In procedure memoization in _expression_ (let* (# # # ...) (ly:grob-set-property! grob # ...)) Bad binding parts in _expression_ (let* ((dir (ly:grob-property grob (quote direction))) (padding 1) (thickness 0.25) (left-ext (car extra-length)) (right-ext (cdr extra-length)) (path-part-len (/ (- spanner-len text-len) 2)) (path-left-part-stil (make-path-stencil (quasiquote (moveto (unquote #) (unquote #) lineto (unquote #) 0 lineto (unquote path-part-len) 0)) thickness 1 1 #f)) (path-right-part-stil (make-path-stencil (quasiquote (moveto (unquote #) (unquote #) lineto (unquote #) 0 lineto 0 0)) thickness 1 1 #f)) parts (full-stil (stack- stencils X RIGHT padding (list path-left-part-stil (centered-stencil text-stil) path-right-part-stil)))) (ly:grob-set-property! grob (quote stencil) full-stil)).......etc............. |
[Prev in Thread] | Current Thread | [Next in Thread] |