2 font-metric.cc -- implement Font_metric
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2005 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;
32 Font_metric::find_by_name (String s) const
34 s.substitute ('-', 'M');
35 int idx = name_to_index (s);
41 expr = scm_list_3 (ly_symbol2scm ("named-glyph"),
43 scm_makfrom0str (s.to_str0 ()));
44 b = get_indexed_char (idx);
51 Font_metric::Font_metric ()
53 description_ = SCM_EOL;
58 Font_metric::Font_metric (Font_metric const &)
62 Font_metric::~Font_metric ()
67 Font_metric::count () const
73 Font_metric::get_ascii_char (int) const
75 return Box (Interval (0, 0), Interval (0, 0));
79 Font_metric::get_indexed_char (int k) const
81 return get_ascii_char (k);
85 Font_metric::name_to_index (String) const
91 Font_metric::get_indexed_wxwy (int) const
97 Font_metric::derived_mark () const
102 Font_metric::mark_smob (SCM s)
104 Font_metric *m = (Font_metric *) SCM_CELL_WORD_1 (s);
106 return m->description_;
110 Font_metric::print_smob (SCM s, SCM port, scm_print_state *)
112 Font_metric *m = unsmob_metrics (s);
113 scm_puts ("#<", port);
114 scm_puts (classname (m), port);
115 scm_puts (" ", port);
116 scm_write (m->description_, port);
117 scm_puts (">", port);
121 IMPLEMENT_SMOBS (Font_metric);
122 IMPLEMENT_DEFAULT_EQUAL_P (Font_metric);
123 IMPLEMENT_TYPE_P (Font_metric, "ly:font-metric?");
126 Font_metric::font_file_name () const
128 return scm_car (description_);
132 Font_metric::font_name () const
134 String s ("unknown");
141 Font_metric::index_to_ascii (int i) const
147 Font_metric::index_to_charcode (int i) const
149 return (unsigned) index_to_ascii (i);
153 Font_metric::get_ascii_char_stencil (int code) const
155 SCM at = scm_list_3 (ly_symbol2scm ("char"), self_scm (),
157 Box b = get_ascii_char (code);
158 return Stencil (b, at);
162 Font_metric::get_indexed_char_stencil (int code) const
164 int idx = index_to_ascii (code);
165 SCM at = scm_list_3 (ly_symbol2scm ("char"), self_scm (), scm_int2num (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.to_str0 ()));
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));