]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/all-font-metrics.cc
patch::: 1.3.126.jcn3
[lilypond.git] / lily / all-font-metrics.cc
index 2d3f73140e22fcb4c46138f457a0395bf8dbcb1e..0c22c59b6cbf3cbaca20862770053c7e40ff3e9c 100644 (file)
 #include "scm-hash.hh"
 #include "kpath.hh"
 
-
-
-
-
 const char * default_font_sz_ = "cmr10";
 
 All_font_metrics::All_font_metrics (String path)
@@ -43,7 +39,7 @@ All_font_metrics::find_afm (String name)
 {
   SCM sname = ly_symbol2scm (name.ch_C ());
 
-  SCM name_str = gh_str02scm (name.ch_C ());
+  SCM name_str = ly_str02scm (name.ch_C ());
 
   SCM val;
   
@@ -67,7 +63,8 @@ All_font_metrics::find_afm (String name)
       if (verbose_global_b)
        progress_indication ("[" + path);
       val = read_afm_file (path);
-
+      unsmob_metrics (val)->path_ = path;
+      
       unsmob_metrics (val)->description_ = gh_cons (name_str, gh_double2scm (1.0));
 
       if (verbose_global_b)
@@ -75,7 +72,25 @@ All_font_metrics::find_afm (String name)
 
       afm_p_dict_->set (sname,val);
 
-      scm_unprotect_object (val);      
+      scm_unprotect_object (val);
+
+
+      Adobe_font_metric *afm
+       = dynamic_cast<Adobe_font_metric*> (unsmob_metrics (val) );
+      Tex_font_metric * tfm = find_tfm (name);
+
+      if (tfm->info_.checksum != afm->checksum_)
+       {
+         String s = _f ("checksum mismatch for font file:\n`%s'", path.ch_C ());
+         s += " " + _f ("does not match: `%s'", tfm->path_.ch_C()); // FIXME
+         s += "\n";
+         s += " TFM: " + to_str ((int) tfm->info_.checksum);
+         s += " AFM: " + to_str ((int) afm->checksum_);
+         s += "\n";
+         s += _(" Rebuild all .afm files, and remove all .pk and .tfm files.  Rerun with -V to show font paths.");
+
+         error (s);
+       }
     }
   
   return dynamic_cast<Adobe_font_metric*> (unsmob_metrics (val));
@@ -86,7 +101,7 @@ Tex_font_metric *
 All_font_metrics::find_tfm (String name)
 {
   SCM sname = ly_symbol2scm (name.ch_C ());
-  SCM name_str = gh_str02scm (name.ch_C ());
+  SCM name_str = ly_str02scm (name.ch_C ());
 
   SCM val;
   if (!tfm_p_dict_->try_retrieve (sname, &val))
@@ -105,18 +120,21 @@ All_font_metrics::find_tfm (String name)
       if (path.empty_b())
        return 0;
 
+      
       if (verbose_global_b)
        progress_indication ("[" + path);
       val = Tex_font_metric::make_tfm (path);
+
       if (verbose_global_b)
        progress_indication ("]");
 
+      unsmob_metrics (val)->path_ = path;
       unsmob_metrics (val)->description_ = gh_cons (name_str, gh_double2scm (1.0));
       tfm_p_dict_->set (sname, val);
 
       scm_unprotect_object (val);
     }
-    
+
   return
     dynamic_cast<Tex_font_metric*> (unsmob_metrics (val));
 }