From: Mark Hindley <mark@hindley.uklinux.net>
Date: Sat, 27 Oct 2001 07:27:23 +0000 (+0100)
Subject: patch::: 1.5.18.moh1: [PATCH] 1.4 Lyric alignment
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=dfe0c6ad15227d6d3646bd7445df5de6aa386ff7;p=lilypond.git

patch::: 1.5.18.moh1: [PATCH] 1.4 Lyric alignment

1.5.18.moh1
===========

* Further work on more flexible control of lyric alignment.
   - new properties "alignment", "ignore-length-mismatch", "begin-alignment" and "end-alignment" to control non-centered lyric alignment

1.5.18
======

---
Generated by mark@hindley.uklinux.net,
>From = lilypond-1.5.18, To = lilypond-1.5.18.moh1

usage

    cd lilypond-source-dir; patch -E -p1 < lilypond-1.5.18.moh1.diff

Patches do not contain automatically generated files
or (urg) empty directories,
i.e., you should rerun autoconf, configure
---

diff --git a/CHANGES b/CHANGES
index adf38b49a5..ae84c1a5bb 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,18 @@
-1.5.18.jcn1
+--- ../lilypond-1.5.18/CHANGES	Sat Oct 27 08:12:57 2001
+++ b/CHANGES	Sat Oct 27 07:46:59 2001
+@@ -1,3 +1,12 @@
+1.5.18.moh1
+===========
+
+* Further work on more flexible control of lyric alignment.
+   - new properties "alignment", "ignore-length-mismatch", "begin-alignment" and "end-alignment" to control non-centered lyric alignment
+
+1.5.18
+======
+
+ 1.5.17.jcn6 - aka: `pgwit!  Ah, dacht dat-i zo wel aardig was.'
+ ===========
+ 1.5.18.jcn1
 ===========
 
 * Moved python modules to ./python.
diff --git a/VERSION b/VERSION
index e1235b82e6..8211834251 100644
--- a/VERSION
+++ b/VERSION
@@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=5
 PATCH_LEVEL=18
-MY_PATCH_LEVEL=jcn1
+MY_PATCH_LEVEL=moh1
 
 # use the above to send patches: MY_PATCH_LEVEL is always empty for a
 # released version.
diff --git a/input/regression/lyric-align.ly b/input/regression/lyric-align.ly
new file mode 100644
index 0000000000..a660e4ce7e
--- /dev/null
+++ b/input/regression/lyric-align.ly
@@ -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 --git a/lily/syllable-group.cc b/lily/syllable-group.cc
index 1dfbad8d98..65aa936a37 100644
--- a/lily/syllable-group.cc
+++ b/lily/syllable-group.cc
@@ -104,7 +104,7 @@ Syllable_group::set_lyric_align (const char *punc, Grob *default_notehead_l)
 
   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 @@ Syllable_group::set_lyric_align (const char *punc, Grob *default_notehead_l)
 /** determine the distance to translate lyrics to get correct alignment
     Rules: If alignment is centre, translate = 0
            Otherwise,
-	      If (length of longest lyric) < property("end-alignment") * (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 @@ Syllable_group::amount_to_translate ()
 {
   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 () / gh_scm2double (longest_lyric_l_->get_grob_property("end-alignment"));
-    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 @@ Syllable_group::amount_to_translate ()
 
 
 /** 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 --git a/scm/grob-description.scm b/scm/grob-description.scm
index d5de3abb57..89e2f803b0 100644
--- a/scm/grob-description.scm
+++ b/scm/grob-description.scm
@@ -316,7 +316,9 @@
 		(self-alignment-X . 0)
 		(non-rhythmic . #t)
 		(word-space . 0.6)
-               (end-alignment . 5)
+                (ignore-length-mismatch . #f)
+                (begin-alignment . 4)
+                (end-alignment . 2)
 		(font-family . roman)
 		(font-shape . upright)
 		(meta . ,(grob-description lyric-syllable-interface text-interface font-interface ))
diff --git a/scm/grob-property-description.scm b/scm/grob-property-description.scm
index 9de5556f70..a3543deb0f 100644
--- a/scm/grob-property-description.scm
+++ b/scm/grob-property-description.scm
@@ -381,7 +381,10 @@ function of type (beam multiplicity dy staff-line-thickness) -> real.  Default v
 (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 'end-alignment number? "proportion of lyric length to align with note-head for non-centered lyrics.")
+(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 --git a/scm/interface-description.scm b/scm/interface-description.scm
index e0de47c3f8..1f837c0589 100644
--- a/scm/interface-description.scm
+++ b/scm/interface-description.scm
@@ -533,6 +533,9 @@ that helps show the length of a melissima (tied/slurred note)."
    "a single piece of lyrics"
    '(
     word-space
+    alignment
+    ignore-length-mismatch
+    begin-alignment
     end-alignment
     ))