2 font-metric.cc -- implement Font_metric
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2006 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 replace_all (s, '-', 'M');
36 int idx = name_to_index (s);
42 expr = scm_list_3 (ly_symbol2scm ("named-glyph"),
44 scm_makfrom0str (s.c_str ()));
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 (size_t) const
76 return Box (Interval (0, 0), Interval (0, 0));
80 Font_metric::get_indexed_char (size_t k) const
82 return get_ascii_char (k);
86 Font_metric::name_to_index (string) const
92 Font_metric::get_indexed_wxwy (size_t) 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");
140 Font_metric::index_to_ascii (size_t i) const
146 Font_metric::index_to_charcode (size_t i) const
148 return index_to_ascii (i);
152 Font_metric::get_ascii_char_stencil (size_t code) const
154 SCM at = scm_list_3 (ly_symbol2scm ("char"), self_scm (),
155 scm_from_unsigned (code));
156 Box b = get_ascii_char (code);
157 return Stencil (b, at);
161 Font_metric::get_indexed_char_stencil (size_t code) const
163 size_t idx = index_to_ascii (code);
164 SCM at = scm_list_3 (ly_symbol2scm ("char"), self_scm (),
165 scm_from_unsigned (idx));
166 Box b = get_indexed_char (code);
167 return Stencil (b, at);
171 Font_metric::attachment_point (string) const
173 return Offset (0, 0);
177 Font_metric::sub_fonts () const
183 Font_metric::text_stencil (string str) const
185 SCM lst = scm_list_3 (ly_symbol2scm ("text"),
187 scm_makfrom0str (str.c_str ()));
189 Box b = text_dimension (str);
190 return Stencil (b, lst);
194 Font_metric::text_dimension (string) const
196 return Box (Interval (0, 0), Interval (0, 0));