2002-08-31 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ * lily/virtual-font-metric.cc: new file
+
+ * lily/include/virtual-font-metric.hh (class Virtual_font_metric):
+ new file
+
* scripts/lilypond-book.py: use old re's for python 2.2 as well
* debian/control: Debian patches by Anthony Fok
virtual Box get_char (int ascii) const;
virtual Box text_dimension (String) const;
virtual Molecule find_by_name (String) const;
-
DECLARE_SMOBS (Font_metric,);
private:
Font_metric (Font_metric const&); // no copy.
protected:
+ virtual void derived_mark();
+
Font_metric ();
};
--- /dev/null
+
+/*
+virtual-font-metric.hh -- declare Virtual_font_metric
+
+source file of the GNU LilyPond music typesetter
+
+(c) 2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+ */
+
+#ifndef VIRTUAL_FONT_METRIC_HH
+#define VIRTUAL_FONT_METRIC_HH
+
+#include "font-metric.hh"
+
+class Virtual_font_metric : public Font_metric
+{
+ SCM font_list_;
+public:
+ Virtual_font_metric (SCM namelist);
+
+ virtual int count () const;
+ virtual Box get_char (int ascii) const;
+ virtual Molecule find_by_name (String) const;
+
+protected:
+ virtual void derived_mark();
+};
+
+
+#endif /* VIRTUAL_FONT_METRIC_HH */
+
--- /dev/null
+/*
+ virtual-font-metric.cc -- implement Virtual_font_metric
+
+source file of the GNU LilyPond music typesetter
+
+(c) 2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+ */
+
+#include "virtual-font-metric.hh"
+#include "all-font-metrics.hh"
+#include "main.hh"
+#include "molecule.hh"
+
+
+Virtual_font_metric::Virtual_font_metric (SCM name_list)
+ :
+ Font_metric(),
+ font_list_ (SCM_EOL)
+{
+ SCM *tail = &font_list_;
+ for (SCM s = name_list; gh_pair_p (s); s = gh_cdr (s))
+ {
+ SCM nm = gh_car (s);
+
+ Font_metric *fm = all_fonts_global->find_font (ly_scm2string (nm));
+ *tail = scm_cons (fm->self_scm(), *tail);
+ tail = SCM_CDRLOC (*tail);
+ }
+}
+
+void
+Virtual_font_metric::derived_mark()
+{
+ scm_gc_mark (font_list_);
+
+}
+
+int
+Virtual_font_metric::count () const
+{
+ int k = 0;
+ for (SCM s = font_list_; gh_pair_p (s); s = gh_cdr (s))
+ {
+ k+= unsmob_metrics (gh_car (s))->count ();
+ }
+
+ return k;
+}
+
+Molecule
+Virtual_font_metric::find_by_name (String glyph) const
+{
+ Molecule m;
+ for (SCM s = font_list_; m.empty_b () && gh_pair_p (s); s = gh_cdr (s))
+ {
+ m = unsmob_metrics (gh_car (s))->find_by_name (glyph);
+ }
+
+ return m;
+}
+
+
+
+Box
+Virtual_font_metric::get_char (int code) const
+{
+ int last_k = 0;
+ for (SCM s = font_list_; gh_pair_p (s); s = gh_cdr (s))
+ {
+ Font_metric* fm = unsmob_metrics (gh_car (s));
+ int k = last_k + fm->count ();
+ if (last_k <= code && code < k)
+ {
+ return fm->get_char (code - last_k);
+ }
+ last_k = k;
+ }
+
+
+ return Box();
+}
+