Jun, Thank you. I add a few punctuation to your code.
David, I don't know scheme. That's why I did a lousy job. I add few more
punctuation to the Jun's latest code. It works.
Thank you both. I have been looking this for a long time.
Ming.
>________________________________
> From: Jun Wang <[email protected]>
>To: David Nalesnik <[email protected]>; MING TSANG <[email protected]>
>Cc: "[email protected]" <[email protected]>
>Sent: Saturday, May 4, 2013 7:28:46 AM
>Subject: RE: Lyrics and Punctuations Alignment Issue?
>
>
>
>
>Ming and David,
>
>
>I modified a bit more (see attached code), It seems to be working.
>
>
>Thanks
>Jun
>
>
>
>________________________________
>Date: Fri, 3 May 2013 22:06:22 -0500
>Subject: Re: Lyrics and Punctuations Alignment Issue?
>From: [email protected]
>To: [email protected]
>CC: [email protected]; [email protected]
>
>
>Ming,
>
>
>
>
>
>
>
>On Fri, May 3, 2013 at 9:08 PM, MING TSANG <[email protected]> wrote:
>
>David,
>>
>>
>>Thank you very much. I try to do two punctuation to the left, but I cannot
>>make it work. Any help is appreciated. Please refer to "a" and "c" from the
>>.png
>
>
>As I explained in my email, if you need additional punctuation you need to add
>it to the respective variables.
>
>
>--David
>
>
%%%%%%%%%%%%%%%%%%%%%%%%%
\version "2.16"
#(define (drop-punctuation-right str)
(let ((punct-right '("." "," ";" ":" "?" "!" "\"" "'" "ã" "ï¼½" "ï¼" "ï¼" "ï¼" "ï¼" "ï¼" "ï¼")))
(let loop ((elt punct-right))
(if (null? elt)
#f
(if (string-suffix? (car elt) str)
(string-drop-right str (string-length (car elt)))
(loop (cdr elt)))))))
#(define (drop-all-punctuation-right str)
(let ((core (drop-punctuation-right str)))
(if core
(drop-all-punctuation-right core)
str)))
#(define (drop-punctuation-left str)
(let ((punct-left '("\"" "â" "ï¼»" "ï¼")))
(let loop ((elt punct-left))
(if (null? elt)
#f
(if (string-prefix? (car elt) str)
(string-drop str (string-length (car elt)))
(loop (cdr elt)))))))
#(define (drop-all-punctuation-left str)
(let ((core (drop-punctuation-left str)))
(if core
(drop-all-punctuation-left core)
str)))
#(define (align grob)
(let* ((stil (ly:grob-property grob 'stencil))
(stil-X (ly:stencil-extent stil X))
(text (ly:grob-property grob 'text))
; determine X-extent of text stencil without punctuation at end
(text-L (drop-all-punctuation-right text))
(text-L-stil (grob-interpret-markup grob text-L))
(text-L-stil-X (ly:stencil-extent text-L-stil X))
(displacement (/ (- (cdr text-L-stil-X) (cdr stil-X)) 2))
; determine X-extent of text stencil without punctuation at start
(text-R (drop-all-punctuation-left text))
(text-R-stil (grob-interpret-markup grob text-R))
(text-R-stil-X (ly:stencil-extent text-R-stil X))
(displacement (+ displacement
(/ (- (cdr stil-X) (cdr text-R-stil-X)) 2))))
(- (ly:self-alignment-interface::aligned-on-x-parent grob)
displacement)))
\paper {
ragged-right = ##f
}
\relative c' {
\time 3/4 e4 e4. e8
d4 e d c d e
}
\addlyrics { \set stanza = "1. "
\override LyricText #'X-offset = #align
"\"I" am so lone -- "ly,\"" said she
}
\addlyrics { \set stanza = "2. "
\override LyricText #'X-offset = #align
ï¼»æ¨ æ¥µï¼½ ï¼å¯¶ åï¼ è²ï¼ åã åï¼ æï¼ 天ï¼
}
\addlyrics { \set stanza = "3. "
\override LyricText #'X-offset = #align
a b c d e f g h i
}
\addlyrics { \set stanza = "4. "
\override LyricText #'X-offset = #align
(æ¨ æ¥µ) "\"寶" å è² å. å, æ? 天!
}_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user