]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/all-font-metrics.cc
release: 1.3.37
[lilypond.git] / lily / all-font-metrics.cc
index 89608e47680fd02d5c11f6cabbb509acb3119c4e..5a3975fa9a709e5138509e6013f43363dfe69995 100644 (file)
@@ -3,7 +3,7 @@
   
   source file of the GNU LilyPond music typesetter
   
-  (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1999--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
   
  */
 
@@ -33,19 +33,16 @@ All_font_metrics::find_afm (String name)
       path = search_path_.find (path);
       if (path.empty_b ())
        return 0;
-      
-      *mlog << "[" << path;
+      progress_indication ("[" + path);
       Adobe_font_metric * afm_p = read_afm_file (path);
 
-      afm_p->name_str_ = name;
-      
-      *mlog << "]" << flush ;
+      afm_p->name_ = ly_symbol2scm (name.ch_C ());
+      progress_indication ("]");
 
-      afm_p_dict_[sname] = afm_p->self_scm_;
-      scm_unprotect_object (afm_p->self_scm_);
+      afm_p_dict_.set (sname,afm_p->self_scm_);
     }
   
-  return dynamic_cast<Adobe_font_metric*> (unsmob_metrics (afm_p_dict_[sname]));
+  return dynamic_cast<Adobe_font_metric*> (unsmob_metrics (afm_p_dict_.get (sname)));
 }
 
 Scaled_font_metric * 
@@ -60,12 +57,11 @@ All_font_metrics::find_scaled (String nm, int m)
     {
       Font_metric *f = find_font (nm);
       s = new Scaled_font_metric (f, m);
-      scaled_p_dict_[sname] = s->self_scm_;
+      scaled_p_dict_.set (sname, s->self_scm_);
       fm =  s;
-      scm_unprotect_object (s->self_scm_);
     }
   else
-    fm = unsmob_metrics (scaled_p_dict_[sname]);
+    fm = unsmob_metrics (scaled_p_dict_.get (sname));
 
   return dynamic_cast<Scaled_font_metric*> (fm);
 }
@@ -80,19 +76,16 @@ All_font_metrics::find_tfm (String name)
       path = search_path_.find (path);
       if (path.empty_b ())
        return 0;
-
-      *mlog << "[" << path;
+      progress_indication ("[" + path);
       Tex_font_metric  * tfm_p = Tex_font_metric_reader::read_file (path);
-      tfm_p->name_str_ = name;
-
-      *mlog << "]" << flush ;
+      tfm_p->name_ = ly_symbol2scm (name.ch_C( ));
+      progress_indication ("]");
 
-      tfm_p_dict_[sname] = tfm_p->self_scm_;
-      scm_unprotect_object (tfm_p->self_scm_);      
+      tfm_p_dict_.set (sname, tfm_p->self_scm_);
     }
     
   return
-    dynamic_cast<Tex_font_metric*> (unsmob_metrics (tfm_p_dict_[sname]));
+    dynamic_cast<Tex_font_metric*> (unsmob_metrics (tfm_p_dict_.get(sname)));
 }
 
 
@@ -108,14 +101,24 @@ All_font_metrics::find_font (String name)
   if (f)
     return f;
 
-  warning (_f ("Can't find font: `%s'", name.ch_C ()));
+  warning (_f ("can't find font: `%s'", name.ch_C ()));
   warning (_ ("Loading default font"));
   
-  f =  find_tfm (default_font_sz_);
+  String def_name = default_font_sz_;
+  SCM l = ly_eval_str ("(style-to-cmr \"default\")");
+  if (l != SCM_BOOL_F)
+    def_name = ly_scm2string (gh_cdr (l));
+
+  f =  find_tfm (def_name);
+  if (f)
+    return f;
+
+  f= find_afm (def_name);
   if (f)
     return f;
-  error (_f ("Can't find default font: `%s'", default_font_sz_));
-  error (_f ("(search path: `%s'", search_path_.str ()));
+
+  error (_f ("can't find default font: `%s'", def_name.ch_C ()));
+  error (_f ("(search path: `%s')", search_path_.str ()));
   error (_ ("Giving up"));
 
   return 0;
@@ -143,14 +146,10 @@ All_font_metrics::font_descriptions () const
   return list;
 }
 
-Font_metric *
-unsmob_metrics( SCM s)
+
+
+Font_metric*
+find_font (String name)
 {
-  if (SMOB_IS_TYPE_B(Font_metric, s))
-    return SMOB_TO_TYPE(Font_metric, s);
-  else
-    return 0;
+  return   all_fonts_global_p->find_font (name);
 }
-
-#include "ly-smobs.icc"
-IMPLEMENT_SMOBS(Font_metric);