2 tfm.cc -- implement Tex_font_metric
4 source file of the GNU LilyPond music typesetter
6 (c) 1999 Jan Nieuwenhuizen <janneke@gnu.org>
9 some code shamelessly copied from GNU fontutils-0.6/tfm/tfm_input.c
13 #include "tfm-reader.hh"
14 #include "string-convert.hh"
19 Tex_font_char_metric::dimensions () const
22 return Box (Interval (0, width_),Interval ( d <? height_, d >? height_));
25 Tex_font_char_metric::Tex_font_char_metric ()
32 italic_correction_ = 0;
36 italic_correction_fix_ = 0;
39 #define APPEND_CHAR_METRIC_ELT(k) outstr += to_str (#k) + " " + to_str (k ## _) + "; "
42 Tex_font_char_metric::str () const
46 APPEND_CHAR_METRIC_ELT (exists_b);
47 APPEND_CHAR_METRIC_ELT (code);
48 APPEND_CHAR_METRIC_ELT (width);
49 APPEND_CHAR_METRIC_ELT (height);
50 APPEND_CHAR_METRIC_ELT (depth);
51 APPEND_CHAR_METRIC_ELT (italic_correction);
56 Tex_font_metric::Tex_font_metric ()
60 static Tex_font_char_metric dummy_static_char_metric;
62 Tex_font_char_metric const *
63 Tex_font_metric::find_ascii (int ascii, bool warn) const
65 if (ascii < ascii_to_metric_idx_.size() && ascii_to_metric_idx_[ascii] >= 0)
66 return & char_metrics_[ascii_to_metric_idx_ [ascii]];
70 warning (_f ("Can't find ascii character: `%d'", ascii));
72 return &dummy_static_char_metric;
76 Tex_font_metric::get_char (int a, bool w) const
78 return find_ascii (a, w)->dimensions ();
83 Tex_font_metric::str () const
86 for (int i=0; i < char_metrics_.size (); i++)
87 outstr += char_metrics_[i].str ();
93 Tex_font_metric::clear (int n)
95 for (int i=0; i < n; i++)
96 ascii_to_metric_idx_.push (-1);