diff options
author | Mats Bengtsson <mats.bengtsson@s3.kth.se> | 2000-04-30 18:06:58 +0200 |
---|---|---|
committer | Mats Bengtsson <mats.bengtsson@s3.kth.se> | 2000-04-30 18:06:58 +0200 |
commit | f15b2ffdd283bacb74ba6db27f68dd26843a193f (patch) | |
tree | f2e3cfe5aecf0aa7f5e906db412ebcf6926ade9e /lily | |
parent | d3c90f63573d53cfb191cc48f8f6ee672a5ca37a (diff) |
patch::: 1.3.47.mb1
1.3.47.mb1
===========
* Simplified ly2dvi using the power of the geometry package.
* Improved heuristic size calculation of TeX macros. Handles e.g.
"\\u{a}", "\\"{o}" and "\\^{u}" correctly.
Diffstat (limited to 'lily')
-rw-r--r-- | lily/font-metric.cc | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/lily/font-metric.cc b/lily/font-metric.cc index 1f54aa5ead..f11483f8f0 100644 --- a/lily/font-metric.cc +++ b/lily/font-metric.cc @@ -4,7 +4,8 @@ source file of the GNU LilyPond music typesetter (c) 1999--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl> - + + Mats Bengtsson <matsb@s3.kth.se> (the ugly TeX parsing in text_dimension) */ #include <math.h> @@ -22,23 +23,29 @@ Font_metric::text_dimension (String text) const for (int i = 0; i < text.length_i (); i++) { - if (text[i]=='\\') + switch (text[i]) { - for (i++; (i < text.length_i ()) && isalpha(text[i]); i++) + case '\\': + for (i++; (i < text.length_i ()) && !isspace(text[i]) + && text[i]!='{' && text[i]!='}'; i++) ; // ugh. i--; // Compensate for the increment in the outer loop! - } - else - { + break; + case '{': // Skip '{' and '}' + case '}': + break; + + default: Box b = get_char ((unsigned char)text[i],false); - + // Ugh, use the width of 'x' for unknown characters if (b[X_AXIS].length () == 0) b = get_char ((unsigned char)'x',false); w += b[X_AXIS].length (); ydims.unite (b[Y_AXIS]); + break; } } if (ydims.empty_b ()) @@ -74,7 +81,6 @@ Font_metric::Font_metric (Font_metric const &) } - Box Font_metric::get_char (int, bool)const { |