Fixes Issue 1504, allowing feather beam line breaking.
[lilypond/patrick.git] / lily / font-metric.cc
blob458528dd2e4dce9a6994a6975c2f0a86ae570ebf
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1999--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
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.
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.
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/>.
20 #include "font-metric.hh"
22 #include <cmath>
23 #include <cctype>
24 using namespace std;
26 #include "dimensions.hh"
27 #include "modified-font-metric.hh"
28 #include "open-type-font.hh"
29 #include "stencil.hh"
30 #include "warn.hh"
32 #include "ly-smobs.icc"
34 Real
35 Font_metric::design_size () const
37 return 1.0 * point_constant;
40 Stencil
41 Font_metric::find_by_name (string s) const
43 replace_all (&s, '-', 'M');
44 int idx = name_to_index (s);
45 Box b;
47 SCM expr = SCM_EOL;
48 if (idx >= 0)
50 expr = scm_list_3 (ly_symbol2scm ("named-glyph"),
51 self_scm (),
52 ly_string2scm (s));
53 b = get_indexed_char_dimensions (idx);
56 Stencil q (b, expr);
57 return q;
60 Font_metric::Font_metric ()
62 description_ = SCM_EOL;
63 self_scm_ = SCM_EOL;
64 smobify_self ();
67 Font_metric::Font_metric (Font_metric const &)
71 Font_metric::~Font_metric ()
75 size_t
76 Font_metric::count () const
78 return 0;
81 Box
82 Font_metric::get_indexed_char_dimensions (size_t) const
84 return Box (Interval (0, 0), Interval (0, 0));
87 size_t
88 Font_metric::name_to_index (string) const
90 return (size_t)-1;
93 Offset
94 Font_metric::get_indexed_wxwy (size_t) const
96 return Offset (0, 0);
99 void
100 Font_metric::derived_mark () const
105 Font_metric::mark_smob (SCM s)
107 Font_metric *m = (Font_metric *) SCM_CELL_WORD_1 (s);
108 m->derived_mark ();
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 (m->class_name (), port);
118 scm_puts (" ", port);
119 scm_write (m->description_, port);
120 scm_puts (">", port);
121 return 1;
124 IMPLEMENT_SMOBS (Font_metric);
125 IMPLEMENT_DEFAULT_EQUAL_P (Font_metric);
126 IMPLEMENT_TYPE_P (Font_metric, "ly:font-metric?");
129 Font_metric::font_file_name () const
131 return scm_car (description_);
134 string
135 Font_metric::font_name () const
137 string s ("unknown");
138 return s;
141 size_t
142 Font_metric::index_to_charcode (size_t i) const
144 return i;
147 Offset
148 Font_metric::attachment_point (string) const
150 return Offset (0, 0);
154 Font_metric::sub_fonts () const
156 return SCM_EOL;
159 Stencil
160 Font_metric::text_stencil (Output_def *state,
161 string, bool) const
163 (void) state;
165 programming_error ("Cannot get a text stencil from this font");
166 return Stencil (Box (), SCM_EOL);