2 font-metric.cc -- implement Font_metric
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 Mats Bengtsson <matsb@s3.kth.se> (the ugly TeX parsing in text_dimension)
11 #include "font-metric.hh"
16 #include "dimensions.hh"
17 #include "modified-font-metric.hh"
18 #include "open-type-font.hh"
20 #include "virtual-methods.hh"
23 #include "ly-smobs.icc"
26 Font_metric::design_size () const
28 return 1.0 * point_constant;
33 Font_metric::find_by_name (String s) const
35 s.substitute_char ('-', "M");
36 int idx = name_to_index (s);
42 expr = scm_list_3 (ly_symbol2scm ("named-glyph"),
44 scm_makfrom0str (s.to_str0 ())
46 b = get_indexed_char (idx);
53 Font_metric::Font_metric ()
55 description_ = SCM_EOL;
60 Font_metric::Font_metric (Font_metric const &)
65 Font_metric::~Font_metric ()
70 Font_metric::count () const
76 Font_metric::get_ascii_char (int) const
78 return Box (Interval (0, 0), Interval (0, 0));
82 Font_metric::get_indexed_char (int k) const
84 return get_ascii_char (k);
88 Font_metric::name_to_index (String) const
94 Font_metric::get_indexed_wxwy (int) const
100 Font_metric::derived_mark () const
105 Font_metric::mark_smob (SCM s)
107 Font_metric *m = (Font_metric*) SCM_CELL_WORD_1 (s);
109 return m->description_;
113 Font_metric::print_smob (SCM s, SCM port, scm_print_state *)
115 Font_metric *m = unsmob_metrics (s);
116 scm_puts ("#<", port);
117 scm_puts (classname (m), port);
118 scm_puts (" ", port);
119 scm_write (m->description_, port);
120 scm_puts (">", port);
126 IMPLEMENT_SMOBS (Font_metric);
127 IMPLEMENT_DEFAULT_EQUAL_P (Font_metric);
128 IMPLEMENT_TYPE_P (Font_metric, "ly:font-metric?");
132 Font_metric::font_file_name () const
134 return scm_car (description_);
138 Font_metric::font_name () const
140 String s ("unknown");
148 Font_metric::index_to_ascii (int i) const
154 Font_metric::index_to_charcode (int i) const
156 return (unsigned) index_to_ascii (i);
160 Font_metric::get_ascii_char_stencil (int code) const
162 SCM at = scm_list_3 (ly_symbol2scm ("char"), self_scm (),
164 Box b = get_ascii_char (code);
165 return Stencil (b, at);
169 Font_metric::get_indexed_char_stencil (int code) const
171 int idx = index_to_ascii (code);
172 SCM at = scm_list_3 (ly_symbol2scm ("char"), self_scm (), scm_int2num (idx));
173 Box b = get_indexed_char (code);
174 return Stencil (b, at);
179 Font_metric::attachment_point (String) const
181 return Offset (0, 0);
185 Font_metric::sub_fonts () const
191 Font_metric::text_stencil (String str) const
193 SCM lst = scm_list_3 (ly_symbol2scm ("text"),
195 scm_makfrom0str (str.to_str0 ()));
197 Box b = text_dimension (str);
198 return Stencil (b, lst);
202 Font_metric::text_dimension (String) const
204 return Box (Interval (0,0), Interval (0,0));