]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/all-font-metrics.cc
release: 1.3.6
[lilypond.git] / lily / all-font-metrics.cc
index 0ecfbf4420de88d419e88b1e20a4ddc31f462970..eddad21ed05589c5e8efccf885787ca41a85ba6a 100644 (file)
@@ -1,10 +1,21 @@
+/*   
+  all-font-metrics.cc --  implement All_font_metrics
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  
+ */
 
 #include "main.hh"
-#include "all-fonts.hh"
+#include "all-font-metrics.hh"
 #include "debug.hh"
 #include "warn.hh"
 #include "afm.hh"
 #include "tfm.hh"
+#include "dictionary-iter.hh"
+#include "lily-guile.hh"
+#include "tfm-reader.hh"
 
 const char * default_font_sz_ = "cmr10";
 
@@ -26,6 +37,9 @@ All_font_metrics::find_afm (String name)
       *mlog << "[" << path;
       Adobe_font_metric
        * afm_p = new Adobe_font_metric (read_afm_file (path));
+
+      afm_p->name_str_ = name;
+      
       *mlog << "]" << flush ;
 
       afm_p_dict_[name] = afm_p;
@@ -33,6 +47,22 @@ All_font_metrics::find_afm (String name)
   return afm_p_dict_[name];  
 }
 
+Scaled_font_metric * 
+All_font_metrics::find_scaled (String nm, int m)
+{
+  Scaled_font_metric * s=0;
+  String index =  nm + "@" + to_str (m);
+  if (!scaled_p_dict_.elem_b (index))
+    {
+      Font_metric *f = find_font (nm);
+      s = new Scaled_font_metric (f, m);
+      scaled_p_dict_[index] = s;
+      return s;  
+    }
+  else
+    return scaled_p_dict_[index];
+}
+
 Tex_font_metric *
 All_font_metrics::find_tfm (String name)
 {
@@ -42,10 +72,11 @@ All_font_metrics::find_tfm (String name)
       path = search_path_.find (path);
       if (path.empty_b ())
        return 0;
-      
+
       *mlog << "[" << path;
-      Tex_font_metric  * tfm_p = new Tex_font_metric;
-      tfm_p->read_file (path);
+      Tex_font_metric  * tfm_p = Tex_font_metric_reader::read_file (path);
+      tfm_p->name_str_ = name;
+
       *mlog << "]" << flush ;
 
       tfm_p_dict_[name] = tfm_p;
@@ -76,3 +107,18 @@ All_font_metrics::find_font (String name)
   error (_f ("(search path: `%s'", search_path_.str ()));
   error (_ ("Giving up"));
 }
+
+SCM
+All_font_metrics::font_descriptions () const
+{
+  SCM l = SCM_EOL;
+  for (Dictionary_iter<Adobe_font_metric*> ai(afm_p_dict_); ai.ok (); ai++)
+    l = gh_cons (ai.val ()->description (), l);
+  for (Dictionary_iter<Tex_font_metric*> ai(tfm_p_dict_); ai.ok (); ai++)
+    l = gh_cons(ai.val ()->description (), l);
+
+  for (Dictionary_iter<Scaled_font_metric*> ai(scaled_p_dict_); ai.ok (); ai++)
+    l = gh_cons (ai.val ()->description (),l);
+  
+  return l;
+}