2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1999--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
5 Mats Bengtsson <matsb@s3.kth.se> (the ugly TeX parsing in text_dimension)
7 LilyPond is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 LilyPond is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
21 #include "font-metric.hh"
27 #include "dimensions.hh"
28 #include "modified-font-metric.hh"
29 #include "open-type-font.hh"
33 #include "ly-smobs.icc"
36 Font_metric::design_size () const
38 return 1.0 * point_constant;
42 Font_metric::find_by_name (string s) const
44 replace_all (&s, '-', 'M');
45 int idx = name_to_index (s);
51 expr = scm_list_3 (ly_symbol2scm ("named-glyph"),
54 b = get_indexed_char (idx);
61 Font_metric::Font_metric ()
63 description_ = SCM_EOL;
68 Font_metric::Font_metric (Font_metric const &)
72 Font_metric::~Font_metric ()
77 Font_metric::count () const
83 Font_metric::get_ascii_char (size_t) const
85 return Box (Interval (0, 0), Interval (0, 0));
89 Font_metric::get_indexed_char (size_t k) const
91 return get_ascii_char (k);
95 Font_metric::name_to_index (string) const
101 Font_metric::get_indexed_wxwy (size_t) const
103 return Offset (0, 0);
107 Font_metric::derived_mark () const
112 Font_metric::mark_smob (SCM s)
114 Font_metric *m = (Font_metric *) SCM_CELL_WORD_1 (s);
116 return m->description_;
120 Font_metric::print_smob (SCM s, SCM port, scm_print_state *)
122 Font_metric *m = unsmob_metrics (s);
123 scm_puts ("#<", port);
124 scm_puts (m->class_name (), port);
125 scm_puts (" ", port);
126 scm_write (m->description_, port);
127 scm_puts (">", port);
131 IMPLEMENT_SMOBS (Font_metric);
132 IMPLEMENT_DEFAULT_EQUAL_P (Font_metric);
133 IMPLEMENT_TYPE_P (Font_metric, "ly:font-metric?");
136 Font_metric::font_file_name () const
138 return scm_car (description_);
142 Font_metric::font_name () const
144 string s ("unknown");
149 Font_metric::index_to_ascii (size_t i) const
155 Font_metric::index_to_charcode (size_t i) const
157 return index_to_ascii (i);
161 Font_metric::get_ascii_char_stencil (size_t code) const
163 SCM at = scm_list_3 (ly_symbol2scm ("char"), self_scm (),
164 scm_from_unsigned (code));
165 Box b = get_ascii_char (code);
166 return Stencil (b, at);
170 Font_metric::get_indexed_char_stencil (size_t code) const
172 size_t idx = index_to_ascii (code);
173 SCM at = scm_list_3 (ly_symbol2scm ("char"), self_scm (),
174 scm_from_unsigned (idx));
175 Box b = get_indexed_char (code);
176 return Stencil (b, at);
180 Font_metric::attachment_point (string) const
182 return Offset (0, 0);
186 Font_metric::sub_fonts () const
192 Font_metric::word_stencil (string str, bool feta) const
194 return text_stencil (str, feta);
198 Font_metric::text_stencil (string, bool) const
200 programming_error ("Cannot get a text stencil from this font");
201 return Stencil (Box (), SCM_EOL);
205 Font_metric::text_dimension (string) const
207 return Box (Interval (0, 0), Interval (0, 0));