2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1999--2009 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/>.
22 #include "modified-font-metric.hh"
23 #include "pango-font.hh"
27 #include "program-option.hh"
29 Modified_font_metric::Modified_font_metric (Font_metric
*fm
,
32 magnification_
= magnification
;
34 SCM desc
= fm
->description_
;
36 Real total_mag
= magnification
* scm_to_double (scm_cdr (desc
));
39 description_
= scm_cons (scm_car (desc
), scm_from_double (total_mag
));
44 Modified_font_metric::make_scaled_font_metric (Font_metric
*fm
, Real scaling
)
46 Modified_font_metric
*sfm
= new Modified_font_metric (fm
, scaling
);
47 return sfm
->self_scm ();
51 Modified_font_metric::design_size () const
53 return orig_
->design_size ();
57 Modified_font_metric::get_indexed_char (vsize i
) const
59 Box b
= orig_
->get_indexed_char (i
);
60 b
.scale (magnification_
);
65 Modified_font_metric::get_ascii_char (vsize i
) const
67 Box b
= orig_
->get_ascii_char (i
);
68 b
.scale (magnification_
);
73 Modified_font_metric::count () const
75 return orig_
->count ();
79 Modified_font_metric::attachment_point (string s
) const
81 Offset o
= orig_
->attachment_point (s
);
82 return o
* magnification_
;
86 Modified_font_metric::get_indexed_wxwy (vsize k
) const
88 Offset o
= orig_
->get_indexed_wxwy (k
);
89 return o
* magnification_
;
93 Modified_font_metric::name_to_index (string s
) const
95 return orig_
->name_to_index (s
);
99 Modified_font_metric::index_to_charcode (vsize i
) const
101 return orig_
->index_to_charcode (i
);
105 Modified_font_metric::index_to_ascii (vsize k
) const
107 return orig_
->index_to_ascii (k
);
111 Modified_font_metric::derived_mark () const
116 Modified_font_metric::text_stencil (string text
, bool feta
) const
119 if (Pango_font
*pf
= dynamic_cast<Pango_font
*> (orig_
))
121 Stencil stc
= pf
->text_stencil (text
, feta
);
123 Box b
= stc
.extent_box ();
125 b
.scale (magnification_
);
126 Stencil
scaled (b
, stc
.expr ());
130 return Font_metric::text_stencil (text
, feta
);
134 Modified_font_metric::text_dimension (string text
) const
140 for (ssize i
= 0; i
< text
.length (); i
++)
142 Box b
= get_ascii_char ((unsigned char)text
[i
]);
144 w
+= b
[X_AXIS
].length ();
145 ydims
.unite (b
[Y_AXIS
]);
147 if (ydims
.is_empty ())
148 ydims
= Interval (0, 0);
150 b
= Box (Interval (0, w
), ydims
);
155 Modified_font_metric::original_font () const
161 Modified_font_metric::sub_fonts () const
163 return orig_
->sub_fonts ();
167 Modified_font_metric::font_name () const
169 return original_font ()->font_name ();