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 ()
28 Adobe_font_char_metric::code ()
34 Adobe_font_char_metric::width ()
39 Adobe_font_char_metric::Adobe_font_char_metric ()
41 B_ = Box( Interval(0,0), Interval (0,0));
47 Adobe_font_metric::Adobe_font_metric ()
50 IsFixedPitch_ = false;
51 UnderlinePosition_ =0.;
52 UnderlineThickness_=0.;
57 Adobe_font_char_metric::dimensions () const
61 b[X_AXIS] *= size_ / 1000.0;
62 b[Y_AXIS] *= size_ / 1000.0;
69 #define APPEND_CHAR_METRIC_ELT(k) outstr += to_str (#k) + " " + to_str (k ## _) + "; "
74 return to_str (b[X_AXIS][SMALLER]) + " " +
75 to_str(b[Y_AXIS][SMALLER]) + " " +
76 to_str (b[X_AXIS][BIGGER]) + " "+
77 to_str (b[Y_AXIS][BIGGER]);
80 #define APPEND_BOX(k) outstr += to_str (#k) + " " + box_str (k ## _) + ";"
83 Adobe_font_char_metric::str () const
87 APPEND_CHAR_METRIC_ELT (C);
88 APPEND_CHAR_METRIC_ELT(N);
89 APPEND_CHAR_METRIC_ELT(WX);
95 #define WRITESTRING(k) outstr += String (#k) + " " + to_str (k ## _) + "\n"
98 Adobe_font_metric::str () const
101 WRITESTRING(FontName);
102 WRITESTRING(FullName);
103 WRITESTRING(FamilyName);
105 WRITESTRING(Version);
107 WRITESTRING(EncodingScheme);
108 WRITESTRING(ItalicAngle);
109 WRITESTRING(UnderlineThickness);
110 WRITESTRING(UnderlinePosition);
111 outstr += "FontBBox " + box_str (FontBBox_) + "\n";
113 for (int i=0; i < char_metrics_.size (); i++)
114 outstr += char_metrics_[i].str ();
119 Adobe_font_char_metric dummy_static_char_metric;
121 Adobe_font_char_metric const &
122 Adobe_font_metric::find_char (String nm, bool warn) const
124 if (!name_to_metric_dict_.elem_b (nm))
128 warning (_f ("Can't find character called: `%s'", nm.ch_C()));
130 return dummy_static_char_metric;
133 return char_metrics_[name_to_metric_dict_ [nm]];
137 Character_metric const *
138 Adobe_font_metric::get_char (int code, bool warn) const
140 return &find_ascii (code,warn);
143 Adobe_font_char_metric const &
144 Adobe_font_metric::find_ascii (int a , bool warn) const
146 int code = ascii_to_metric_idx_[a];
149 return char_metrics_[code];
153 warning (_f ("Can't find character number: %d", a));
155 return dummy_static_char_metric;