source file of the GNU LilyPond music typesetter
- (c) 1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1998--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
Adobe_font_char_metric::Adobe_font_char_metric ()
{
+ B_ = Box( Interval(0,0), Interval (0,0));
+ WX_ = 0.0;
C_ = 0;
+ C_ = -1;
}
Adobe_font_metric::Adobe_font_metric ()
}
+Box
+Adobe_font_char_metric::dimensions () const
+{
+ Box b= B_;
+
+ b[X_AXIS] *= size_ / 1000.0;
+ b[Y_AXIS] *= size_ / 1000.0;
+
+ return b;
+}
+
+
+
#define APPEND_CHAR_METRIC_ELT(k) outstr += to_str (#k) + " " + to_str (k ## _) + "; "
String
return outstr;
}
-/*
- UGH. should have hashtable.
- */
-Adobe_font_char_metric
-Adobe_font_metric::find_char (String nm) const
+Adobe_font_char_metric dummy_static_char_metric;
+
+Adobe_font_char_metric const &
+Adobe_font_metric::find_char (String nm, bool warn) const
{
- for (int i=0; i < char_metrics_.size (); i++)
- if (char_metrics_[i].N_ == nm)
- return char_metrics_[i];
+ if (!name_to_metric_dict_.elem_b (nm))
+ {
+ if (warn)
+ {
+ warning (_f ("can't find character called `%s'", nm.ch_C()));
+ }
+ return dummy_static_char_metric;
+ }
+
+ return char_metrics_[name_to_metric_dict_ [nm]];
+}
- warning (_f ("can't find character called `%s'", nm.ch_C()));
- Adobe_font_char_metric a;
- return a;
+Character_metric *
+Adobe_font_metric::get_char (int code, bool warn) const
+{
+ return &find_ascii (code,warn);
+}
+
+Adobe_font_char_metric const &
+Adobe_font_metric::find_ascii (int a , bool warn) const
+{
+ int code = ascii_to_metric_idx_[a];
+ if (code>=0)
+ {
+ return char_metrics_[code];
+ }
+ else if (warn )
+ {
+ warning (_f ("can't find character number %d", a));
+ }
+ return dummy_static_char_metric;
}