[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] 1.4 Lyric alignment
From: |
Mark Hindley |
Subject: |
[PATCH] 1.4 Lyric alignment |
Date: |
Thu, 18 Oct 2001 18:09:04 +0100 (BST) |
Han-Wen Nienhuys writes:
> address@hidden writes:
> > Any comments?
>
> Yes, can we have a test file (input/regression) that describes the
> effect (using the texidoc header string), and demonstrates it as well?
>
I have actually revisited the whole thing, because it still wasn't
flexible enough for what I was trying to do.
Here is the new patch. I have added a regression file as requested.
There are 4 new properties in the lyric-syllable-interface:
alignment:
If set, overrides the automatic determination of
lyric alignment. -1 LEFT, 0 CENTRE, 1 RIGHT.
ignore-length-mismatch:
boolean to control if short lyrics
can be moved away from their parent note. Default #f
begin-alignment,end-alignment:
numbers that specify what proportion of the the longest
lyric to align with the note-head for left and right aligned
lyrics respectively.
Hope that is clear.
It has worked well for me for typesetting church music with long
reciting notes which have multiple syllables, but you want the note to
line up with the beginning of the lyric.
Mark
Generated by address@hidden,
>From = lilypond-1.4.8, To = lilypond-1.4.8.moh2
usage
cd lilypond-source-dir; patch -E -p1 < lilypond-1.4.8.moh2.diff
Patches do not contain automatically generated files
or (urg) empty directories,
i.e., you should rerun autoconf, configure
diff -urN ../lilypond-1.4.8/CHANGES ./CHANGES
--- ../lilypond-1.4.8/CHANGES Wed Oct 17 09:25:04 2001
+++ ./CHANGES Thu Oct 18 14:55:40 2001
@@ -1,3 +1,13 @@
+1.4.8.moh2
+==========
+
+* More flexible lyric alignment:
+ - new properties "alignment", "ignore-length-mismatch", "begin-alignment"
and "end-alignment" to control non-centered lyric alignment
+
+
+1.4.8
+=====
+
1.4.7.jcn2
==========
diff -urN ../lilypond-1.4.8/VERSION ./VERSION
--- ../lilypond-1.4.8/VERSION Wed Oct 17 09:25:04 2001
+++ ./VERSION Thu Oct 18 11:59:28 2001
@@ -2,7 +2,7 @@
MAJOR_VERSION=1
MINOR_VERSION=4
PATCH_LEVEL=8
-MY_PATCH_LEVEL=
+MY_PATCH_LEVEL=moh2
# use the above to send patches: MY_PATCH_LEVEL is always empty for a
# released version.
diff -urN ../lilypond-1.4.8/input/regression/lyric_align.ly
./input/regression/lyric_align.ly
--- ../lilypond-1.4.8/input/regression/lyric_align.ly Thu Jan 1 01:00:00 1970
+++ ./input/regression/lyric_align.ly Thu Oct 18 15:55:23 2001
@@ -0,0 +1,73 @@
+\version "1.3.146"
+\header{
+ texidoc="Lyric alignment
+
+ Lyric alignment is adjustable both interms of alignment between stanzas and
on notehead.
+
+ If the property alignment is not set, there is automatic determination of
alignment type based on punctuation. (ee lyric-phrasing.ly)
+
+"
+}
+
+%\paper { linewidth = -1. }
+\score {
+ \addlyrics
+ \context Voice = "v" \notes \relative c'' {
+ \property Staff.automaticMelismata = ##t
+ \cadenzaOn
+ a\breve \bar "||" a1 \bar "|" a \bar "|" a \bar "||" \break a \bar
"|" a \bar "|" a \bar "|" a \bar "||" \break a \bar "|" a \bar "|."
+ }
+ \context Lyrics <
+ \context LyricsVoice = "v-1" \lyrics {
+% \property LyricsVoice . stanza = "1:"
+ \property Lyrics . LyricText \override #'ignore-length-mismatch = ##t
+ \property Lyrics . LyricText \override #'alignment = #-1
+ \property Lyrics . LyricText \override #'begin-alignment = #8
+
+ "Particularly useful for reciting notes "
+ left
+
+ \property Lyrics . LyricText \override #'alignment = #0
+
+ centered
+
+ \property Lyrics . LyricText \override #'alignment = #1
+
+ right
+
+ \property Lyrics . LyricText \override #'alignment = #-1
+ \property Lyrics . LyricText \override #'begin-alignment = #2
+
+ left_half_way
+
+ \property Lyrics . LyricText \override #'begin-alignment = #4
+
+ left_one_quarter
+
+ \property Lyrics . LyricText \override #'begin-alignment = #10
+
+ left_one_tenth
+
+ \property Lyrics . LyricText \override #'begin-alignment = #1
+
+ left_one_whole
+
+ \property Lyrics . LyricText \override #'ignore-length-mismatch = ##f
+ \property Lyrics . LyricText \override #'begin-alignment = #4
+
+ Very_short_lyrics_remain_in_touch_with_their_note
+
+ \property Lyrics . LyricText \override #'alignment = #1
+ \property Lyrics . LyricText \override #'end-alignment = #1.1
+ \property Lyrics . LyricText \override #'ignore-length-mismatch = ##t
+
+
+ Unless_ignore-length-mismatch_is_true
+
+ }
+ \context LyricsVoice = "v-2" \lyrics {
+% \property LyricsVoice . stanza = "2:"
+ " with many syllables under them." l c r l l l x x x note' true'
+ }
+ >
+}
diff -urN ../lilypond-1.4.8/lily/syllable-group.cc ./lily/syllable-group.cc
--- ../lilypond-1.4.8/lily/syllable-group.cc Wed Mar 28 23:44:44 2001
+++ ./lily/syllable-group.cc Thu Oct 18 14:36:33 2001
@@ -104,7 +104,7 @@
Grob * lyric;
alignment_i_ = appropriate_alignment (punc);
-
+
// If there was no notehead in the matching voice context, use the first
// notehead caught from any voice context (any port in a storm).
if (!notehead_l_) {
@@ -131,7 +131,7 @@
/** determine the distance to translate lyrics to get correct alignment
Rules: If alignment is centre, translate = 0
Otherwise,
- If (length of longest lyric) < 2 * (length of shortest lyric),
+ If (length of longest lyric) < (property {begin,end}-alignment) *
(length of shortest lyric),
- centre longest lyric on notehead
Otherwise
- move so shortest lyric just reaches notehead centre
@@ -141,11 +141,20 @@
{
Real translate = 0.0;
if (alignment_i_ != CENTER) {
- // FIXME: do we really know the lyric extent here? Some font sizing comes
later?
- Real l1 = longest_lyric_l_->extent (longest_lyric_l_, X_AXIS).length () /
2;
- Real l2 = shortest_lyric_l_->extent (shortest_lyric_l_, X_AXIS).length ();
-
- translate = l1 <? l2;
+ switch (alignment_i_) {
+ // FIXME: do we really know the lyric extent here? Some font sizing
comes later?
+ case LEFT:
+ translate = longest_lyric_l_->extent (longest_lyric_l_, X_AXIS).length
() / gh_scm2double (longest_lyric_l_->get_grob_property("begin-alignment"));
+ break;
+ case RIGHT:
+ translate = longest_lyric_l_->extent (longest_lyric_l_, X_AXIS).length
() / gh_scm2double (longest_lyric_l_->get_grob_property("end-alignment"));
+ break;
+ }
+ if
(!gh_scm2bool(longest_lyric_l_->get_grob_property("ignore-length-mismatch"))) {
+ Real l = shortest_lyric_l_->extent (shortest_lyric_l_, X_AXIS).length ();
+ translate = l <? translate;
+ }
+
translate *= alignment_i_ ;
}
return translate;
@@ -153,13 +162,20 @@
/** determine what alignment we want.
- Rules: if first_in_phrase_b_ is set, then alignment is LEFT.
+ Rules: if property alignment is set it specifies the alignment
+ if first_in_phrase_b_ is set, then alignment is LEFT.
otherwise if each syllable ends in punctuation, then alignment is
RIGHT
otherwise alignment is centre.
*/
int
Syllable_group::appropriate_alignment (const char *punc)
{
+
+ SCM s=this->longest_lyric_l_->get_grob_property ("alignment");
+ if (s!=SCM_EOL) {
+ return gh_scm2int (s);
+ }
+
if (first_in_phrase_b_)
return LEFT;
diff -urN ../lilypond-1.4.8/scm/grob-description.scm ./scm/grob-description.scm
--- ../lilypond-1.4.8/scm/grob-description.scm Wed Oct 17 09:24:52 2001
+++ ./scm/grob-description.scm Thu Oct 18 14:35:45 2001
@@ -304,6 +304,9 @@
(self-alignment-X . 0)
(non-rhythmic . #t)
(word-space . 0.6)
+ (ignore-length-mismatch . #f)
+ (begin-alignment . 4)
+ (end-alignment . 2)
(font-family . roman)
(font-shape . upright)
(meta . ,(grob-description "LyricText" lyric-syllable-interface
text-interface font-interface ))
diff -urN ../lilypond-1.4.8/scm/grob-property-description.scm
./scm/grob-property-description.scm
--- ../lilypond-1.4.8/scm/grob-property-description.scm Fri Jul 27 08:02:01 2001
+++ ./scm/grob-property-description.scm Thu Oct 18 15:58:12 2001
@@ -360,6 +360,10 @@
(grob-property-description 'visibility-lambda procedure? "a function that
takes the break direction and returns a cons of booleans containing
(TRANSPARENT . EMPTY).")
(grob-property-description 'when moment? "when does this column happen?.")
(grob-property-description 'word-space number? "elongate left by this much
(FIXME: cumbersome semantics).")
+(grob-property-description 'alignment number? "alignment of lyrics on
notehead, -1 is LEFT, 0 is CENTRE, 1 is RIGHT .")
+(grob-property-description 'ignore-length-mismatch boolean? "if #t, stanzas
with shorter lyrics can be moved away from their respective note-head by the
lyric alignment code.")
+(grob-property-description 'begin-alignment number? "proportion of lyric
length from beginning to align with note-head for left-aligned lyrics.")
+(grob-property-description 'end-alignment number? "proportion of lyric length
from end to align with note-head for right-aligned lyrics.")
(grob-property-description 'x-gap number? "horizontal gap between notehead and
tie.")
(grob-property-description 'y-free number? "minimal vertical gap between slur
and noteheads or stems.")
(grob-property-description 'y-offset number? "extra vertical offset for ties
away from the center line.")
diff -urN ../lilypond-1.4.8/scm/interface-description.scm
./scm/interface-description.scm
--- ../lilypond-1.4.8/scm/interface-description.scm Wed Oct 17 09:24:52 2001
+++ ./scm/interface-description.scm Thu Oct 18 14:35:11 2001
@@ -532,7 +532,11 @@
'lyric-syllable-interface
"a single piece of lyrics"
'(
- word-space
+ word-space
+ alignment
+ ignore-length-mismatch
+ begin-alignment
+ end-alignment
))