]> git.donarmstrong.com Git - lilypond.git/blob - lily/font-metric.cc
Issue 4082/3: Run scripts/auxiliar/smob-convert.sh
[lilypond.git] / lily / font-metric.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1999--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "font-metric.hh"
21
22 #include <cmath>
23 #include <cctype>
24 using namespace std;
25
26 #include "dimensions.hh"
27 #include "modified-font-metric.hh"
28 #include "open-type-font.hh"
29 #include "stencil.hh"
30 #include "warn.hh"
31
32
33 Real
34 Font_metric::design_size () const
35 {
36   return 1.0 * point_constant;
37 }
38
39 Stencil
40 Font_metric::find_by_name (string s) const
41 {
42   replace_all (&s, '-', 'M');
43   int idx = name_to_index (s);
44   Box b;
45
46   SCM expr = SCM_EOL;
47   if (idx >= 0)
48     {
49       expr = scm_list_3 (ly_symbol2scm ("named-glyph"),
50                          self_scm (),
51                          ly_string2scm (s));
52       b = get_indexed_char_dimensions (idx);
53     }
54
55   Stencil q (b, expr);
56   return q;
57 }
58
59 Font_metric::Font_metric ()
60 {
61   description_ = SCM_EOL;
62   smobify_self ();
63 }
64
65 Font_metric::Font_metric (Font_metric const &)
66 {
67 }
68
69 Font_metric::~Font_metric ()
70 {
71 }
72
73 size_t
74 Font_metric::count () const
75 {
76   return 0;
77 }
78
79 Box
80 Font_metric::get_indexed_char_dimensions (size_t) const
81 {
82   return Box (Interval (0, 0), Interval (0, 0));
83 }
84
85 Offset
86 Font_metric::get_indexed_wxwy (size_t) const
87 {
88   return Offset (0, 0);
89 }
90
91 void
92 Font_metric::derived_mark () const
93 {
94 }
95
96 SCM
97 Font_metric::mark_smob (SCM s)
98 {
99   Font_metric *m = (Font_metric *) SCM_CELL_WORD_1 (s);
100   m->derived_mark ();
101   return m->description_;
102 }
103
104 int
105 Font_metric::print_smob (SCM s, SCM port, scm_print_state *)
106 {
107   Font_metric *m = Font_metric::unsmob (s);
108   scm_puts ("#<", port);
109   scm_puts (m->class_name (), port);
110   scm_puts (" ", port);
111   scm_write (m->description_, port);
112   scm_puts (">", port);
113   return 1;
114 }
115
116 const char Font_metric::type_p_name_[] = "ly:font-metric?";
117
118 SCM
119 Font_metric::font_file_name () const
120 {
121   return scm_car (description_);
122 }
123
124 string
125 Font_metric::font_name () const
126 {
127   string s ("unknown");
128   return s;
129 }
130
131 size_t
132 Font_metric::index_to_charcode (size_t i) const
133 {
134   return i;
135 }
136
137 Offset
138 Font_metric::attachment_point (const string&) const
139 {
140   return Offset (0, 0);
141 }
142
143 SCM
144 Font_metric::sub_fonts () const
145 {
146   return SCM_EOL;
147 }
148
149 Stencil
150 Font_metric::text_stencil (Output_def *state,
151                            const string&, bool) const
152 {
153   (void) state;
154
155   programming_error ("Cannot get a text stencil from this font");
156   return Stencil (Box (), SCM_EOL);
157 }