]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/tfm.cc
*** empty log message ***
[lilypond.git] / lily / tfm.cc
index 9d385184e5be8e5593c2b3bfa1cd45f9cb5459a5..571df4319c76f66dc077daa4695647c5f20c3cfb 100644 (file)
@@ -9,10 +9,10 @@
  */
 
 #include "tfm.hh"
+
 #include "tfm-reader.hh"
 #include "string-convert.hh"
 #include "warn.hh"
-#include "warn.hh"
 #include "dimensions.hh"
 
 static Tex_font_char_metric dummy_static_char_metric;
@@ -50,26 +50,17 @@ Tex_font_char_metric::dimensions () const
                        (d >? height_)*point_constant));
 }
 
-#define APPEND_CHAR_METRIC_ELT(k) \
-    outstr += ::to_string (#k) + " "  + ::to_string (k ## _)  + "; "
-
-String
-Tex_font_char_metric::to_string () const
+Tex_font_metric::Tex_font_metric ()
 {
-  String outstr;
-
-  APPEND_CHAR_METRIC_ELT (exists);
-  APPEND_CHAR_METRIC_ELT (code);
-  APPEND_CHAR_METRIC_ELT (width);
-  APPEND_CHAR_METRIC_ELT (height);
-  APPEND_CHAR_METRIC_ELT (depth);
-  APPEND_CHAR_METRIC_ELT (italic_correction);
-  
-  return outstr + "\n";
+  encoding_table_ = SCM_EOL;
 }
 
-Tex_font_metric::Tex_font_metric ()
+
+
+void
+Tex_font_metric::derived_mark () const
 {
+  scm_gc_mark (encoding_table_);
 }
 
 Tex_font_char_metric const *
@@ -100,26 +91,21 @@ Tex_font_metric::get_ascii_char (int a) const
   return b;
 }
 
-String
-Tex_font_metric::to_string () const
-{
-  String outstr;
-  for (int i=0; i < char_metrics_.size (); i++)
-    outstr += char_metrics_[i].to_string ();
-  return outstr;
-}
-
 SCM
-Tex_font_metric::make_tfm (String filename)
+Tex_font_metric::make_tfm (String file_name)
 {
   Tex_font_metric *tfm = new Tex_font_metric;
-  Tex_font_metric_reader reader (filename);
+  Tex_font_metric_reader reader (file_name);
 
   tfm->info_ = reader.info_;
   tfm->header_ = reader.header_;
   tfm->char_metrics_ = reader.char_metrics_;
   tfm->ascii_to_metric_idx_ = reader.ascii_to_metric_idx_;
 
+  tfm->encoding_table_
+    = scm_call_1 (ly_scheme_function ("get-coding-table"),
+                 scm_makfrom0str (tfm->coding_scheme ().to_str0 ()));
+
   return tfm->self_scm ();
 }
 
@@ -132,5 +118,25 @@ Tex_font_metric::design_size () const
 String
 Tex_font_metric::coding_scheme () const
 {
-  return info_.coding_scheme;
+  String scm = info_.coding_scheme;
+
+  for(int i = 0; i < scm.length (); i++)
+    if (scm[i] == ' ')
+      scm[i] = '-';
+
+  return scm;
+}
+
+int
+Tex_font_metric::name_to_index (String s) const
+{
+  SCM sym = ly_symbol2scm (s.to_str0 ());
+
+  SCM idx = scm_hash_ref (encoding_table_, sym, SCM_BOOL_F);
+  if (ly_c_char_p (idx))
+    {
+      return (unsigned char) ly_scm2char (idx);
+    }
+  else
+    return -1;  
 }