X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fmodified-font-metric.cc;h=71b532d61883fb64d2ca4fc1906686c7d008bfc8;hb=58d1c2f39c091da0325d54b19476ee7532d8889f;hp=114b8e38248e4236f69a8b461285aa016c52f62c;hpb=62f221b6b3861ff055dc0384ec3c48cc665688cd;p=lilypond.git diff --git a/lily/modified-font-metric.cc b/lily/modified-font-metric.cc index 114b8e3824..71b532d618 100644 --- a/lily/modified-font-metric.cc +++ b/lily/modified-font-metric.cc @@ -3,14 +3,13 @@ source file of the GNU LilyPond music typesetter - (c) 1999--2008 Han-Wen Nienhuys + (c) 1999--2009 Han-Wen Nienhuys */ #include using namespace std; #include "modified-font-metric.hh" #include "pango-font.hh" -#include "text-metrics.hh" #include "warn.hh" #include "stencil.hh" #include "main.hh" @@ -102,69 +101,13 @@ Modified_font_metric::derived_mark () const { } -/* TODO: put this klutchness behind ly:option switch. */ -Box -Modified_font_metric::tex_kludge (string text) const -{ - Interval ydims; - Real w = 0; - for (ssize i = 0; i < text.length (); i++) - { - switch (text[i]) - { - case '\\': - /* Accent marks use width of base letter */ - if (i < text.length () - 1) - { - if (text[i + 1]=='\'' || text[i + 1]=='`' || text[i + 1]=='"' - || text[i + 1]=='^') - { - i++; - break; - } - /* For string width \\ is a \ and \_ is a _. */ - if (text[i + 1]=='\\' || text[i + 1]=='_') - break; - } - - for (i++; (i < text.length ()) && !isspace (text[i]) - && text[i]!='{' && text[i]!='}'; i++) - ; - - /* Compensate for the auto-increment in the outer loop. */ - i--; - break; - - case '{': // Skip '{' and '}' - case '}': - break; - - default: - Box b = get_ascii_char ((unsigned char)text[i]); - - /* Use the width of 'x' for unknown characters */ - if (b[X_AXIS].length () == 0) - b = get_ascii_char ((unsigned char)'x'); - - w += b[X_AXIS].length (); - ydims.unite (b[Y_AXIS]); - break; - } - } - - if (ydims.is_empty ()) - ydims = Interval (0, 0); - - return Box (Interval (0, w), ydims); -} - Stencil -Modified_font_metric::text_stencil (string text) const +Modified_font_metric::text_stencil (string text, bool feta) const { Box b; if (Pango_font *pf = dynamic_cast (orig_)) { - Stencil stc = pf->text_stencil (text); + Stencil stc = pf->text_stencil (text, feta); Box b = stc.extent_box (); @@ -173,31 +116,14 @@ Modified_font_metric::text_stencil (string text) const return scaled; } - return Font_metric::text_stencil (text); + return Font_metric::text_stencil (text, feta); } Box Modified_font_metric::text_dimension (string text) const { - SCM stext = ly_string2scm (text); - Box b; - if (get_output_backend_name () == "tex") - { - b = lookup_tex_text_dimension (orig_, stext); - - if (!b[Y_AXIS].is_empty ()) - { - b.scale (magnification_); - return b; - } - - b = tex_kludge (text); - return b; - } - Interval ydims; - Real w = 0.0; for (ssize i = 0; i < text.length (); i++)