2 font-metric.cc -- implement Font_metric
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
8 Mats Bengtsson <matsb@s3.kth.se> (the ugly TeX parsing in text_dimension)
11 #include "font-metric.hh"
17 #include "dimensions.hh"
18 #include "modified-font-metric.hh"
19 #include "open-type-font.hh"
21 #include "virtual-methods.hh"
24 #include "ly-smobs.icc"
27 Font_metric::design_size () const
29 return 1.0 * point_constant;
33 Font_metric::find_by_name (String s) const
35 s.substitute ('-', 'M');
36 int idx = name_to_index (s);
42 expr = scm_list_3 (ly_symbol2scm ("named-glyph"),
44 scm_makfrom0str (s.to_str0 ()));
45 b = get_indexed_char (idx);
52 Font_metric::Font_metric ()
54 description_ = SCM_EOL;
59 Font_metric::Font_metric (Font_metric const &)
63 Font_metric::~Font_metric ()
68 Font_metric::count () const
74 Font_metric::get_ascii_char (int) const
76 return Box (Interval (0, 0), Interval (0, 0));
80 Font_metric::get_indexed_char (int k) const
82 return get_ascii_char (k);
86 Font_metric::name_to_index (String) const
92 Font_metric::get_indexed_wxwy (int) const
98 Font_metric::derived_mark () const
103 Font_metric::mark_smob (SCM s)
105 Font_metric *m = (Font_metric *) SCM_CELL_WORD_1 (s);
107 return m->description_;
111 Font_metric::print_smob (SCM s, SCM port, scm_print_state *)
113 Font_metric *m = unsmob_metrics (s);
114 scm_puts ("#<", port);
115 scm_puts (m->class_name (), port);
116 scm_puts (" ", port);
117 scm_write (m->description_, port);
118 scm_puts (">", port);
122 IMPLEMENT_SMOBS (Font_metric);
123 IMPLEMENT_DEFAULT_EQUAL_P (Font_metric);
124 IMPLEMENT_TYPE_P (Font_metric, "ly:font-metric?");
127 Font_metric::font_file_name () const
129 return scm_car (description_);
133 Font_metric::font_name () const
135 String s ("unknown");
142 Font_metric::index_to_ascii (int i) const
148 Font_metric::index_to_charcode (int i) const
150 return (unsigned) index_to_ascii (i);
154 Font_metric::get_ascii_char_stencil (int code) const
156 SCM at = scm_list_3 (ly_symbol2scm ("char"), self_scm (),
157 scm_from_int (code));
158 Box b = get_ascii_char (code);
159 return Stencil (b, at);
163 Font_metric::get_indexed_char_stencil (int code) const
165 int idx = index_to_ascii (code);
166 SCM at = scm_list_3 (ly_symbol2scm ("char"), self_scm (), scm_from_int (idx));
167 Box b = get_indexed_char (code);
168 return Stencil (b, at);
172 Font_metric::attachment_point (String) const
174 return Offset (0, 0);
178 Font_metric::sub_fonts () const
184 Font_metric::text_stencil (String str) const
186 SCM lst = scm_list_3 (ly_symbol2scm ("text"),
188 scm_makfrom0str (str.to_str0 ()));
190 Box b = text_dimension (str);
191 return Stencil (b, lst);
195 Font_metric::text_dimension (String) const
197 return Box (Interval (0, 0), Interval (0, 0));