Since this issue is so common, I wonder if we could add this feature to the
lilypond code base? I thought the requirement is following:
1. The feature should be turned on by default with list of ascii punctuations,
like ",.?{}()! :2. The list of punctuation can be override/customized with any
unicode character list. 3. The feature can be turned off by override/set the
punctuation list to empty.
Is it feasible? If it is ok, I would like to help, but with my limited
lilypond and Scheme knowledge, I wonder If I could make it.
ThanksJun
Date: Sun, 5 May 2013 06:24:26 -0700
From: [email protected]
Subject: Re: Lyrics and Punctuations Alignment Issue?
To: [email protected]
CC: [email protected]; [email protected]
David & Jun:
I complete the punctuation and parenthesis to the "align grob". The following
is the .ly UTF-8 file with test. I also attacha png file for your reference.
Thank you for your help,Ming
\version "2.17"
#(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
}
\markup {" The following is lyric with override LyricText ................"}
\relative c' {
\time 3/4 e4 e4. e8
d4 e d c d e
}
\addlyrics { \set stanza = "1. "
\override LyricText #'X-offset = #align
a "\"bb" ccc -- "dddd\"" eeeee f 'g h i'
}
%{
\addlyrics { \set stanza = "2. "
\override LyricText #'X-offset = #align
"\"I" am so lone -- "ly,\"" said she
}
%}
\addlyrics { \set stanza = "3. "
\override LyricText #'X-offset = #align
[�� �O] (�� 名) ��; 名。 啊: 明? 天!
}
\addlyrics { \set stanza = "4. "
\override LyricText #'X-offset = #align
"\"��" "�O\"" (�� 名) ��; 名. 啊: 明? 天!
}
\markup { " " }
\markup { " " }
\markup { " " }
\markup {"The following is normal lyric ie. no override LyricText
.............."}
\relative c' {
\time 3/4 e4 e4. e8
d4 e d c d e
}
\addlyrics { \set stanza = "1. "
a bb ccc dddd eeeee f 'g h' i
}
\addlyrics { \set stanza = "5. "
[�� �O] (�� 名) ��; 名。 啊: 明? 天!
}
\addlyrics { \set stanza = "6. "
"\"��" "�O\"" (�� 名) ��; 名. 啊: 明? 天!
}
From: MING TSANG <[email protected]>
To: David Nalesnik <[email protected]>
Cc: Jun Wang <[email protected]>; "[email protected]"
<[email protected]>
Sent: Saturday, May 4, 2013 6:01:13 PM
Subject: Re: Lyrics and Punctuations Alignment Issue?
David,
Yes, left and right UTF-8 parenthese -
UTF-8.
Thanks,Ming
From: David Nalesnik <[email protected]>
To: MING TSANG <[email protected]>
Cc: Jun Wang <[email protected]>; "[email protected]"
<[email protected]>
Sent: Saturday, May 4, 2013 4:05:37 PM
Subject: Re: Lyrics and Punctuations Alignment Issue?
Ming,
On Sat, May 4, 2013 at 11:16 AM, MING TSANG <[email protected]> wrote:
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.
Nice to hear! By the way, did you mean to add the parentheses at "a" and :b"
to your lists?
-David
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user