]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/all-font-metrics.cc
* scripts/musicxml2ly.py (convert): add \version
[lilypond.git] / lily / all-font-metrics.cc
index 9ccc1f78ed6087ba1d15ab53c236e3e90010f25b..440e16ca66fc55002a11d3dfa2e2967ce89cd13a 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1999--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
 #include "all-font-metrics.hh"
@@ -43,12 +43,12 @@ All_font_metrics::All_font_metrics (String path)
 
 All_font_metrics::~All_font_metrics ()
 {
-  scm_gc_unprotect_object (afm_dict_->self_scm ());
-  scm_gc_unprotect_object (tfm_dict_->self_scm ());
-  scm_gc_unprotect_object (otf_dict_->self_scm ());
+  afm_dict_->unprotect ();
+  tfm_dict_->unprotect ();
+  otf_dict_->unprotect ();
 
 #if HAVE_PANGO_FT2
-  scm_gc_unprotect_object (pango_dict_->self_scm ());
+  pango_dict_->unprotect ();
   g_object_unref (pango_ft2_fontmap_);
 #endif
 }
@@ -62,7 +62,8 @@ All_font_metrics::All_font_metrics (All_font_metrics const &)
 Pango_font *
 All_font_metrics::find_pango_font (PangoFontDescription *description,
                                   Real magnification,
-                                  Real output_scale)
+                                  Real output_scale
+                                  )
 {
   pango_font_description_set_size (description,
                                   gint (magnification *
@@ -74,21 +75,23 @@ All_font_metrics::find_pango_font (PangoFontDescription *description,
   SCM val;
   if (!pango_dict_->try_retrieve (key, &val))
     {
-      progress_indication ("[" + String (pango_fn));
-      
+      if (be_verbose_global)
+       progress_indication ("[" + String (pango_fn));
+
       Pango_font *pf = new Pango_font (pango_ft2_fontmap_,
-                                      RIGHT,
                                       description,
-                                      output_scale);
+                                      output_scale
+                                      );
+      
       val = pf->self_scm ();
       pango_dict_->set (key, val);
-      scm_gc_unprotect_object (val);
+      pf->unprotect ();
 
       if (be_verbose_global)
        progress_indication ("]");
 
       pf->description_ = scm_cons (SCM_BOOL_F,
-                                  scm_make_real (1.0));
+                                  scm_from_double (1.0));
     }
   g_free (pango_fn);
   return dynamic_cast<Pango_font *> (unsmob_metrics (val));
@@ -104,10 +107,17 @@ kpathsea_find_file (String name, String ext)
   if (path.length () > 0)
     return path;
 
-  SCM kpath = ly_lily_module_constant ("ly:kpathsea-find-file");
-  if (ly_c_procedure_p (kpath))
+  static SCM proc;
+  if (!proc)
+    {
+      SCM module = scm_c_resolve_module ("scm kpathsea");
+      proc = scm_c_module_lookup (module, "ly:kpathsea-find-file");
+      proc = scm_variable_ref (proc);
+    }
+
+  if (ly_is_procedure (proc))
     {
-      SCM kp_result = scm_call_1 (kpath, scm_makfrom0str (name.to_str0 ()));
+      SCM kp_result = scm_call_1 (proc, scm_makfrom0str (name.to_str0 ()));
       if (scm_is_string (kp_result))
        return ly_scm2string (kp_result);
     }
@@ -151,13 +161,13 @@ All_font_metrics::find_afm (String name)
       unsmob_metrics (val)->file_name_ = file_name;
 
       unsmob_metrics (val)->description_ = scm_cons (name_string,
-                                                    scm_make_real (1.0));
+                                                    scm_from_double (1.0));
 
       if (be_verbose_global)
        progress_indication ("]");
 
       afm_dict_->set (sname, val);
-      scm_gc_unprotect_object (val);
+      unsmob_metrics (val)->unprotect ();
 
       Adobe_font_metric *afm
        = dynamic_cast<Adobe_font_metric *> (unsmob_metrics (val));
@@ -221,9 +231,9 @@ All_font_metrics::find_otf (String name)
 
       unsmob_metrics (val)->file_name_ = file_name;
       unsmob_metrics (val)->description_ = scm_cons (name_string,
-                                                    scm_make_real (1.0));
+                                                    scm_from_double (1.0));
       otf_dict_->set (sname, val);
-      scm_gc_unprotect_object (val);
+      unsmob_metrics (val)->unprotect ();
     }
 
   return dynamic_cast<Open_type_font *> (unsmob_metrics (val));
@@ -263,9 +273,9 @@ All_font_metrics::find_tfm (String name)
 
       unsmob_metrics (val)->file_name_ = file_name;
       unsmob_metrics (val)->description_ = scm_cons (name_string,
-                                                    scm_make_real (1.0));
+                                                    scm_from_double (1.0));
       tfm_dict_->set (sname, val);
-      scm_gc_unprotect_object (val);
+      unsmob_metrics (val)->unprotect ();
     }
 
   return dynamic_cast<Tex_font_metric *> (unsmob_metrics (val));