X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fmodified-font-metric.cc;h=5ad26a3548ddeecddaa645377a745ac15fa5e7fc;hb=f1e6a812cca9ab3b58ce8f36acacde0c7f035448;hp=9a5488f1ccca0c971cdea50044ba60f39a24d8b6;hpb=a276a19dc6bd57832db3107f2f2cbb04cb4677b6;p=lilypond.git diff --git a/lily/modified-font-metric.cc b/lily/modified-font-metric.cc index 9a5488f1cc..5ad26a3548 100644 --- a/lily/modified-font-metric.cc +++ b/lily/modified-font-metric.cc @@ -1,19 +1,30 @@ /* - modified-font-metric.cc -- declare Modified_font_metric + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 1999--2010 Han-Wen Nienhuys - (c) 1999--2007 Han-Wen Nienhuys + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ #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" +#include "program-option.hh" Modified_font_metric::Modified_font_metric (Font_metric *fm, Real magnification) @@ -101,69 +112,14 @@ 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 (Output_def* state, + 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 (state, text, feta); Box b = stc.extent_box (); @@ -172,45 +128,7 @@ Modified_font_metric::text_stencil (string text) const return scaled; } - return Font_metric::text_stencil (text); -} - -Box -Modified_font_metric::text_dimension (string text) const -{ - SCM stext = ly_string2scm (text); - - Box b; - if (output_backend_global == "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++) - { - Box b = get_ascii_char ((unsigned char)text[i]); - - w += b[X_AXIS].length (); - ydims.unite (b[Y_AXIS]); - } - if (ydims.is_empty ()) - ydims = Interval (0, 0); - - b = Box (Interval (0, w), ydims); - return b; + return Font_metric::text_stencil (state, text, feta); } Font_metric *