]> git.donarmstrong.com Git - lilypond.git/blob - lily/font-metric.cc
Run grand-replace (issue 3765)
[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 #include "ly-smobs.icc"
33
34 Real
35 Font_metric::design_size () const
36 {
37   return 1.0 * point_constant;
38 }
39
40 Stencil
41 Font_metric::find_by_name (string s) const
42 {
43   replace_all (&s, '-', 'M');
44   int idx = name_to_index (s);
45   Box b;
46
47   SCM expr = SCM_EOL;
48   if (idx >= 0)
49     {
50       expr = scm_list_3 (ly_symbol2scm ("named-glyph"),
51                          self_scm (),
52                          ly_string2scm (s));
53       b = get_indexed_char_dimensions (idx);
54     }
55
56   Stencil q (b, expr);
57   return q;
58 }
59
60 Font_metric::Font_metric ()
61 {
62   description_ = SCM_EOL;
63   self_scm_ = SCM_EOL;
64   smobify_self ();
65 }
66
67 Font_metric::Font_metric (Font_metric const &)
68 {
69 }
70
71 Font_metric::~Font_metric ()
72 {
73 }
74
75 size_t
76 Font_metric::count () const
77 {
78   return 0;
79 }
80
81 Box
82 Font_metric::get_indexed_char_dimensions (size_t) const
83 {
84   return Box (Interval (0, 0), Interval (0, 0));
85 }
86
87 Offset
88 Font_metric::get_indexed_wxwy (size_t) const
89 {
90   return Offset (0, 0);
91 }
92
93 void
94 Font_metric::derived_mark () const
95 {
96 }
97
98 SCM
99 Font_metric::mark_smob (SCM s)
100 {
101   Font_metric *m = (Font_metric *) SCM_CELL_WORD_1 (s);
102   m->derived_mark ();
103   return m->description_;
104 }
105
106 int
107 Font_metric::print_smob (SCM s, SCM port, scm_print_state *)
108 {
109   Font_metric *m = unsmob_metrics (s);
110   scm_puts ("#<", port);
111   scm_puts (m->class_name (), port);
112   scm_puts (" ", port);
113   scm_write (m->description_, port);
114   scm_puts (">", port);
115   return 1;
116 }
117
118 IMPLEMENT_SMOBS (Font_metric);
119 IMPLEMENT_DEFAULT_EQUAL_P (Font_metric);
120 IMPLEMENT_TYPE_P (Font_metric, "ly:font-metric?");
121
122 SCM
123 Font_metric::font_file_name () const
124 {
125   return scm_car (description_);
126 }
127
128 string
129 Font_metric::font_name () const
130 {
131   string s ("unknown");
132   return s;
133 }
134
135 size_t
136 Font_metric::index_to_charcode (size_t i) const
137 {
138   return i;
139 }
140
141 Offset
142 Font_metric::attachment_point (const string&) const
143 {
144   return Offset (0, 0);
145 }
146
147 SCM
148 Font_metric::sub_fonts () const
149 {
150   return SCM_EOL;
151 }
152
153 Stencil
154 Font_metric::text_stencil (Output_def *state,
155                            const string&, bool) const
156 {
157   (void) state;
158
159   programming_error ("Cannot get a text stencil from this font");
160   return Stencil (Box (), SCM_EOL);
161 }