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
{
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);
{
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);
}
#include "molecule.hh"
#include "text-def.hh"
#include "dimension.hh"
+#include <ctype.h>
Direction
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;
}
{
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;
}