2 font-metric.cc -- implement Font_metric
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 Mats Bengtsson <matsb@s3.kth.se> (the ugly TeX parsing in text_dimension)
14 #include "molecule.hh"
15 #include "ly-smobs.icc"
16 #include "font-metric.hh"
20 Font_metric::text_dimension (String text) const
25 for (int i = 0; i < text.length_i (); i++)
31 for (i++; (i < text.length_i ()) && !isspace(text[i])
32 && text[i]!='{' && text[i]!='}'; i++)
35 i--; // Compensate for the increment in the outer loop!
37 case '{': // Skip '{' and '}'
42 Box b = get_char ((unsigned char)text[i]);
44 // Ugh, use the width of 'x' for unknown characters
45 if (b[X_AXIS].length () == 0)
46 b = get_char ((unsigned char)'x');
48 w += b[X_AXIS].length ();
49 ydims.unite (b[Y_AXIS]);
54 ydims = Interval (0,0);
56 return Box(Interval (0, w), ydims);
61 Font_metric::~Font_metric ()
65 Font_metric::Font_metric ()
67 description_ = SCM_EOL;
72 Font_metric::Font_metric (Font_metric const &s)
78 Font_metric::get_char (int )const
80 return Box (Interval(0,0),Interval (0,0));
85 Font_metric::mark_smob (SCM s)
87 Font_metric * m = (Font_metric*) SCM_CELL_WORD_1(s);
88 return m->description_;
92 Font_metric::print_smob (SCM s, SCM port, scm_print_state * )
94 Font_metric *m = unsmob_metrics (s);
95 scm_puts ("#<Font_metric ", port);
96 scm_write (m->description_, port);
102 IMPLEMENT_UNSMOB (Font_metric, metrics);
103 IMPLEMENT_SMOBS (Font_metric);
104 IMPLEMENT_DEFAULT_EQUAL_P(Font_metric);
105 IMPLEMENT_TYPE_P (Font_metric, "font-metric?");
108 Font_metric::find_by_name (String) const