]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/paper-def.cc
* scm/output-ps.scm (output-scopes): use ly:paper-lookup for font
[lilypond.git] / lily / paper-def.cc
index a784bfab15c72945522f9d061be1032a235fd52d..0e7ab2254e62c056b5add19021359e24eb291aee 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 
@@ -41,8 +41,6 @@ Paper_def::Paper_def (Paper_def const&src)
 {
 }
 
-
-
 Real
 Paper_def::get_realvar (SCM s) const
 {
@@ -85,7 +83,7 @@ Paper_def::get_paper_outputter (String outname)  const
 
 
 /*
-  todo: use symbols and hashtable idx?
+  Todo: use symbols and hashtable idx?
 */
 Font_metric *
 Paper_def::find_font (SCM fn, Real m)
@@ -103,7 +101,10 @@ Paper_def::find_font (SCM fn, Real m)
   Font_metric*  f=0;
   if (gh_list_p (fn))
     {
-      f = new Virtual_font_metric (fn, m, this);
+      f = new Virtual_font_metric (fn, m, this); // TODO: GC protection.
+      
+      scaled_fonts_ = scm_acons (key, f->self_scm (), scaled_fonts_);
+      scm_gc_unprotect_object (f->self_scm ());
     }
   else
     {
@@ -114,8 +115,9 @@ Paper_def::find_font (SCM fn, Real m)
       f = all_fonts_global->find_font (ly_scm2string (fn));
       SCM val = Scaled_font_metric::make_scaled_font_metric (f, m);
       scaled_fonts_ = scm_acons (key, val, scaled_fonts_);
-      f = unsmob_metrics (val);
       scm_gc_unprotect_object (val);
+      
+      f = unsmob_metrics (val);
     }
 
   return f;
@@ -132,6 +134,9 @@ Paper_def::font_descriptions ()const
   for (SCM s = scaled_fonts_; gh_pair_p (s); s = ly_cdr (s))
     {
       SCM desc = ly_caar (s);
+      if (!gh_string_p (gh_car (desc)))
+       continue ;
+
       SCM mdesc = unsmob_metrics (ly_cdar (s))->description_;
 
       l = gh_cons (gh_cons (mdesc, desc), l);