From: fred <fred>
Date: Sun, 24 Mar 2002 20:13:55 +0000 (+0000)
Subject: lilypond-1.0.4
X-Git-Tag: release/1.5.59~2974
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=712730f5a1fceb57551dc23dde6cb885e9cc3159;p=lilypond.git

lilypond-1.0.4
---

diff --git a/VERSION b/VERSION
index 7453b04628..875f4fb000 100644
--- a/VERSION
+++ b/VERSION
@@ -1,7 +1,7 @@
 PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=0
-PATCH_LEVEL=3
+PATCH_LEVEL=4
 MY_PATCH_LEVEL=
 
 # use the above to send patches, always empty for released version:
diff --git a/init/property.ly b/init/property.ly
index 75d8f10669..a53eccbf6e 100644
--- a/init/property.ly
+++ b/init/property.ly
@@ -29,6 +29,10 @@ slurydirection		-1	force stem down		\slurdown
 slurydirection		0  	stem direction free	\slurboth
 slurydirection		1	force stem up		\slurup
 
+textalignment		-1	left alignment of text
+textalignment		0	center alignment of text
+textalignment		1	right alignment of text
+
 [Score?]
 beamslopedamping	0	no damping		\beamslopeproportional	
 beamslopedamping	1	damping1)		\beamslopedamped
diff --git a/lily/VERSION b/lily/VERSION
index 7453b04628..875f4fb000 100644
--- a/lily/VERSION
+++ b/lily/VERSION
@@ -1,7 +1,7 @@
 PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=0
-PATCH_LEVEL=3
+PATCH_LEVEL=4
 MY_PATCH_LEVEL=
 
 # use the above to send patches, always empty for released version:
diff --git a/lily/include/text-def.hh b/lily/include/text-def.hh
index 296350de45..e4b42d1233 100644
--- a/lily/include/text-def.hh
+++ b/lily/include/text-def.hh
@@ -36,6 +36,8 @@ public:
   Text_def();
   virtual void print() const;
   virtual Interval width (Paper_def*) const;
+private:
+  Real guess_width_f(Atom&) const;
 };
 
 #endif // TEXT_DEF_HH
diff --git a/lily/lyric-engraver.cc b/lily/lyric-engraver.cc
index 8ed3989043..ceba7c467e 100644
--- a/lily/lyric-engraver.cc
+++ b/lily/lyric-engraver.cc
@@ -44,6 +44,11 @@ Lyric_engraver::do_process_requests()
 	{
 	  td_p->style_str_ = style;
 	}
+      Scalar alignment = get_property ("textalignment");
+      if (alignment.isnum_b())
+	{
+	  td_p->align_dir_= (Direction)(int)alignment;
+	}
       
       lyric_item_p_ =  new Text_item (td_p);
 
diff --git a/lily/parser.yy b/lily/parser.yy
index 4b9ec9fd2f..5df3722a0a 100644
--- a/lily/parser.yy
+++ b/lily/parser.yy
@@ -1112,7 +1112,7 @@ script_req:
 gen_script_def:
 	text_def	{ 
 		$$ = $1;
-		((Text_def*) $$)->align_dir_ = CENTER; /* UGH */
+		((Text_def*) $$)->align_dir_ = LEFT; /* UGH */
 	}
 	| mudela_script	{ 
 		$$ = $1;
diff --git a/lily/script-engraver.cc b/lily/script-engraver.cc
index 435e312729..671ca17e38 100644
--- a/lily/script-engraver.cc
+++ b/lily/script-engraver.cc
@@ -69,6 +69,11 @@ Script_engraver::do_pre_move_processing()
 	    {
 	      td_l->style_str_= style;
 	    }
+	  Scalar alignment = get_property ("textalignment");
+	  if (alignment.isnum_b())
+	    {
+	      td_l->align_dir_= (Direction)(int)alignment;
+	    }
 	}
       typeset_element (script_p);
     }
diff --git a/lily/text-def.cc b/lily/text-def.cc
index b0dbaf5611..6c1664017b 100644
--- a/lily/text-def.cc
+++ b/lily/text-def.cc
@@ -12,6 +12,7 @@
 #include "molecule.hh"
 #include "text-def.hh"
 #include "dimension.hh"
+#include <ctype.h>
 
 Direction
 Text_def::staff_dir () const
@@ -21,16 +22,29 @@ Text_def::staff_dir () const
   return DOWN;
 }
 
+Real
+Text_def::guess_width_f(Atom& a) const
+{
+  // Count each TeX command as one character, ugh
+  int index, length=0;
+  int total_length=text_str_.length_i();
+  const char* str=text_str_.ch_C();
+  for (index=0;index<total_length;index++) {
+    length++;
+    if (str[index]=='\\')
+      for (index++;(index < total_length) && isalpha(str[index]);index++)
+	;
+  }
+  return length * a.dim_.x ().length (); // ugh
+}
+
 Interval
 Text_def::width (Paper_def * p) const
 {
   Atom a = get_atom (p,CENTER);
 
-  /* TODO: check string for \texcommand
-   */
 
-  Real guess_width_f = text_str_.length_i() * a.dim_.x ().length (); // ugh
-  Interval i (0, guess_width_f);
+  Interval i (0, guess_width_f(a));
   i += - (align_dir_ + 1)* i.center();
   return i;
 }
@@ -62,8 +76,7 @@ Text_def::get_atom (Paper_def *p, Direction) const
 {
   Atom a= p->lookup_l(0)->text (style_str_, text_str_);
 
-  Real guess_width_f = text_str_.length_i() * a.dim_.x ().length (); // ugh
-  a.translate_axis (-(align_dir_ + 1)* guess_width_f/ 2, X_AXIS);
+  a.translate_axis (-(align_dir_ + 1)* guess_width_f (a) / 2, X_AXIS);
   
   return a;
 }