[EMAIL PROTECTED] said:
> [EMAIL PROTECTED] writes:
> > There will always be TeX commands (or Postscript or whatever output
> > language
> > Lilypond will use) in text scripts and in lyrics, so it will always be
> > impossible to calculate the exact extent of the text unless we
> > implement
> > TeX or call TeX and look at the output. However, the current solution
> > (text_str_.length_i() * const) is not sufficient. It's probably better
> > on
> > the average to count each TeX command as a single symbol in the
> > approximation.
>
> That sounds like a passable solution for now.
Here is a patch for the length calculations. Also changed the
alignment of textual scripts to LEFT. Even better would be to
set this from a property.
/Mats
Generated by (address unknown) using package-diff 0.62,
>From = lilypond-1.0.3, To = lilypond-1.0.3.mb1
usage
cd lilypond-source-dir; patch -E -p1 < lilypond-1.0.3.mb1.diff
Patches do not contain automatically generated files
or (urg) empty directories,
i.e., you should rerun autoconf, configure
and possibly make outdirs.
--state
1.0.3
1.0.3.mb1
++state
diff -urN ../lilypond-1.0.3/NEWS ./NEWS
--- ../lilypond-1.0.3/NEWS Wed Aug 19 12:01:05 1998
+++ ./NEWS Fri Aug 21 02:14:27 1998
@@ -1,3 +1,9 @@
+pl 3.mb1
+ - Changed text script alignment: center -> left
+ - TeX commands counts as one character when calculating
+ the length of a Text_def
+
+*********
pl 2.uu1
- solaris 2.6 compile/make website fixes.
- rm'd WWW.make
diff -urN ../lilypond-1.0.3/VERSION ./VERSION
--- ../lilypond-1.0.3/VERSION Wed Aug 19 11:38:16 1998
+++ ./VERSION Fri Aug 21 02:11:27 1998
@@ -2,7 +2,7 @@
MAJOR_VERSION=1
MINOR_VERSION=0
PATCH_LEVEL=3
-MY_PATCH_LEVEL=
+MY_PATCH_LEVEL=mb1
# use the above to send patches, always empty for released version:
# please don't move these comments up; the patch should fail if
diff -urN ../lilypond-1.0.3/lily/VERSION ./lily/VERSION
--- ../lilypond-1.0.3/lily/VERSION Wed Aug 19 11:38:21 1998
+++ ./lily/VERSION Fri Aug 21 02:16:08 1998
@@ -2,7 +2,7 @@
MAJOR_VERSION=1
MINOR_VERSION=0
PATCH_LEVEL=3
-MY_PATCH_LEVEL=
+MY_PATCH_LEVEL=mb1
# use the above to send patches, always empty for released version:
# please don't move these comments up; the patch should fail if
diff -urN ../lilypond-1.0.3/lily/parser.yy ./lily/parser.yy
--- ../lilypond-1.0.3/lily/parser.yy Fri Jul 31 11:22:26 1998
+++ ./lily/parser.yy Fri Aug 21 01:08:00 1998
@@ -1112,7 +1112,7 @@
gen_script_def:
text_def {
$$ = $1;
- ((Text_def*) $$)->align_dir_ = CENTER; /* UGH */
+ ((Text_def*) $$)->align_dir_ = LEFT; /* UGH */
}
| mudela_script {
$$ = $1;
diff -urN ../lilypond-1.0.3/lily/text-def.cc ./lily/text-def.cc
--- ../lilypond-1.0.3/lily/text-def.cc Thu Aug 13 22:33:18 1998
+++ ./lily/text-def.cc Fri Aug 21 01:09:05 1998
@@ -12,6 +12,7 @@
#include "molecule.hh"
#include "text-def.hh"
#include "dimension.hh"
+#include <ctype.h>
Direction
Text_def::staff_dir () const
@@ -26,10 +27,18 @@
{
Atom a = get_atom (p,CENTER);
- /* TODO: check string for \texcommand
- */
- Real guess_width_f = text_str_.length_i() * a.dim_.x ().length (); // ugh
+ // 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++)
+ ;
+ }
+ Real guess_width_f = length * a.dim_.x ().length (); // ugh
Interval i (0, guess_width_f);
i += - (align_dir_ + 1)* i.center();
return i;
@@ -62,7 +71,17 @@
{
Atom a= p->lookup_l(0)->text (style_str_, text_str_);
- Real guess_width_f = text_str_.length_i() * a.dim_.x ().length (); // ugh
+ // 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++)
+ ;
+ }
+ Real guess_width_f = length * a.dim_.x ().length (); // ugh
a.translate_axis (-(align_dir_ + 1)* guess_width_f/ 2, X_AXIS);
return a;
diff -urN ../lilypond-1.0.3/make/STATE-VECTOR ./make/STATE-VECTOR
--- ../lilypond-1.0.3/make/STATE-VECTOR Wed Aug 19 11:38:19 1998
+++ ./make/STATE-VECTOR Fri Aug 21 02:15:59 1998
@@ -64,3 +64,4 @@
1.0.2
1.0.2.hwn1
1.0.3
+1.0.3.mb1