2 afm.cc -- implement Adobe_font_metric
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
12 #include "direction.hh"
16 Adobe_font_char_metric::bbox ()
22 Adobe_font_char_metric::name ()
29 Adobe_font_char_metric::code ()
35 Adobe_font_char_metric::width ()
40 Adobe_font_char_metric::Adobe_font_char_metric ()
42 B_ = Box( Interval(0,0), Interval (0,0));
48 Adobe_font_metric::Adobe_font_metric ()
51 IsFixedPitch_ = false;
52 UnderlinePosition_ =0.;
53 UnderlineThickness_=0.;
58 Adobe_font_char_metric::dimensions () const
62 b[X_AXIS] *= size_ / 1000.0;
63 b[Y_AXIS] *= size_ / 1000.0;
70 #define APPEND_CHAR_METRIC_ELT(k) outstr += to_str (#k) + " " + to_str (k ## _) + "; "
75 return to_str (b[X_AXIS][SMALLER]) + " " +
76 to_str(b[Y_AXIS][SMALLER]) + " " +
77 to_str (b[X_AXIS][BIGGER]) + " "+
78 to_str (b[Y_AXIS][BIGGER]);
81 #define APPEND_BOX(k) outstr += to_str (#k) + " " + box_str (k ## _) + ";"
84 Adobe_font_char_metric::str () const
88 APPEND_CHAR_METRIC_ELT (C);
89 APPEND_CHAR_METRIC_ELT(N);
90 APPEND_CHAR_METRIC_ELT(WX);
96 #define WRITESTRING(k) outstr += String (#k) + " " + to_str (k ## _) + "\n"
99 Adobe_font_metric::str () const
102 WRITESTRING(FontName);
103 WRITESTRING(FullName);
104 WRITESTRING(FamilyName);
106 WRITESTRING(Version);
108 WRITESTRING(EncodingScheme);
109 WRITESTRING(ItalicAngle);
110 WRITESTRING(UnderlineThickness);
111 WRITESTRING(UnderlinePosition);
112 outstr += "FontBBox " + box_str (FontBBox_) + "\n";
114 for (int i=0; i < char_metrics_.size (); i++)
115 outstr += char_metrics_[i].str ();
120 Adobe_font_char_metric dummy_static_char_metric;
122 Adobe_font_char_metric const &
123 Adobe_font_metric::find_char (String nm, bool warn) const
125 if (!name_to_metric_dict_.elem_b (nm))
129 warning (_f ("can't find character called `%s'", nm.ch_C()));
131 return dummy_static_char_metric;
134 return char_metrics_[name_to_metric_dict_ [nm]];
139 Adobe_font_metric::get_char (int code, bool warn) const
141 return &find_ascii (code,warn);
144 Adobe_font_char_metric const &
145 Adobe_font_metric::find_ascii (int a , bool warn) const
147 int code = ascii_to_metric_idx_[a];
150 return char_metrics_[code];
154 warning (_f ("can't find character number %d", a));
156 return dummy_static_char_metric;