2 virtual-font-metric.cc -- implement Virtual_font_metric
4 source file of the GNU LilyPond music typesetter
6 (c) 2002--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 #include "virtual-font-metric.hh"
12 #include "all-font-metrics.hh"
13 #include "molecule.hh"
14 #include "paper-def.hh"
18 passing DEF is ughish. Should move into paperdef?
20 Virtual_font_metric::Virtual_font_metric (SCM name_list,
21 Real mag,Paper_def*def)
24 SCM *tail = &font_list_;
25 for (SCM s = name_list; gh_pair_p (s); s = gh_cdr (s))
29 Font_metric *fm = def->find_font (nm, mag);
30 *tail = scm_cons (fm->self_scm(),SCM_EOL);
31 tail = SCM_CDRLOC (*tail);
36 Virtual_font_metric::derived_mark()const
38 scm_gc_mark (font_list_);
42 Virtual_font_metric::count () const
45 for (SCM s = font_list_; gh_pair_p (s); s = gh_cdr (s))
47 k+= unsmob_metrics (gh_car (s))->count ();
54 Virtual_font_metric::find_by_name (String glyph) const
57 for (SCM s = font_list_; m.is_empty () && gh_pair_p (s); s = gh_cdr (s))
59 m = unsmob_metrics (gh_car (s))->find_by_name (glyph);
68 Virtual_font_metric::get_ascii_char (int) const
70 programming_error ("Virtual font metric cannot be indexed by ASCII.");
75 Virtual_font_metric::get_ascii_char_molecule (int ) const
77 programming_error ("Virtual font metric cannot be indexed by ASCII.");
83 Virtual_font_metric::get_indexed_wxwy (int code) const
86 for (SCM s = font_list_; gh_pair_p (s); s = gh_cdr (s))
88 Font_metric* fm = unsmob_metrics (gh_car (s));
89 if (code < total + fm->count ())
91 return fm->get_indexed_wxwy (code - total);
93 total += fm->count ();
101 Virtual_font_metric::get_indexed_char (int code) const
104 for (SCM s = font_list_; gh_pair_p (s); s = gh_cdr (s))
106 Font_metric* fm = unsmob_metrics (gh_car (s));
107 if (code < total + fm->count ())
109 return fm->get_indexed_char (code - total);
111 total += fm->count ();
120 Virtual_font_metric::name_to_index (String glyph) const
124 for (SCM s = font_list_; m.is_empty () && gh_pair_p (s); s = gh_cdr (s))
126 Font_metric *m =unsmob_metrics (gh_car (s));
127 int k = m->name_to_index (glyph);
131 total += m->count ();
139 Virtual_font_metric::get_indexed_char_molecule (int code) const
144 for (SCM s = font_list_; gh_pair_p (s); s = gh_cdr (s))
146 Font_metric* fm = unsmob_metrics (gh_car (s));
147 if (code < total + fm->count())
149 m = fm->get_indexed_char_molecule (code - total); // ugh.
152 total += fm->count ();