]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/performance.cc (output): remap modulo 16.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 6 Apr 2004 16:17:13 +0000 (16:17 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 6 Apr 2004 16:17:13 +0000 (16:17 +0000)
* lily/text-item.cc (interpret_markup): whoops, variable
shadowing fixed.

18 files changed:
ChangeLog
lily/afm.cc
lily/font-metric.cc
lily/include/afm.hh
lily/include/font-metric.hh
lily/include/scaled-font-metric.hh
lily/include/tfm.hh
lily/kpath.cc
lily/paper-def.cc
lily/performance.cc
lily/scaled-font-metric.cc
lily/text-item.cc
lily/tfm.cc
ly/declarations-init.ly
scm/encoding.scm
scm/font.scm
scm/output-ps.scm
scm/output-tex.scm

index d3622cf17499e6a295621e553360af49a17a94a6..294b2d3c261feaad99685f1a2eed6b47aa99c99c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2004-04-06  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
+       * lily/performance.cc (output): remap modulo 16.
+
        * lily/text-item.cc (interpret_markup): whoops, variable
        shadowing fixed.
 
@@ -7,6 +9,7 @@
 
        * lily/piano-pedal-performer.cc (try_music): Compare symbols to
        symbols, not symbols to strings.
+       
        * lily/piano-pedal-engraver.cc (try_music): Compare symbols to
        symbols, not symbols to strings.
 
index 2a84e60360b70b579a29459a39a9dea145054aa1..ce93f58345944c8bf23df73222c87aadcbe23c32 100644 (file)
@@ -98,6 +98,12 @@ Adobe_font_metric::get_ascii_char (int code) const
   return b;
 }
 
+int
+Adobe_font_metric::index_to_ascii (int code) const
+{
+  return font_info_->cmi[code].code;
+}
+
 Box
 Adobe_font_metric::get_indexed_char (int code) const
 {
@@ -161,31 +167,6 @@ Adobe_font_metric::get_indexed_wxwy (int k) const
   return 1/1000.0 PT * Offset (mi->wx, mi->wy); 
 }
 
-/*
-  return a stencil, without fontification 
- */
-Stencil
-Adobe_font_metric::find_by_name (String s) const
-{
-  AFM_CharMetricInfo const *cm = find_char_metric (s);
-
-  if (!cm)
-    {
-      /* FIXME: Why don't we return empty? */
-      Stencil m;
-      m.set_empty (false);
-      return m;
-    }
-
-  SCM at = (scm_list_2 (ly_symbol2scm ("char"), scm_int2num (cm->code)));
-
-#if 0
-  at = fontify_atom ((Font_metric*) this, at);
-#endif  
-  Box b = afm_bbox_to_box (cm->charBBox);
-  return Stencil (b, at);
-}
-
 Real
 Adobe_font_metric::design_size () const
 {
index 2527069190ea16adf330c45ab96cc8277bf92dce..1042844c060cbdcf11ae672e7d0a0f88f5425d9b 100644 (file)
@@ -31,8 +31,24 @@ Font_metric::coding_scheme () const
   return "FontSpecific";
 }
 
-
-
+Stencil
+Font_metric::find_by_name (String s) const
+{
+  int idx = name_to_index (s);
+  Box b;
+  
+  SCM expr = SCM_EOL;
+  if (idx >= 0)
+    {
+      expr = scm_list_3 (ly_symbol2scm ("char"),
+                        self_scm (),
+                        gh_int2scm (index_to_ascii (idx)));
+      b = get_indexed_char (idx);
+    }
+  
+  Stencil q (b, expr);
+  return q;
+}
 
 Font_metric::Font_metric ()
 {
@@ -111,12 +127,6 @@ IMPLEMENT_SMOBS (Font_metric);
 IMPLEMENT_DEFAULT_EQUAL_P (Font_metric);
 IMPLEMENT_TYPE_P (Font_metric, "ly:font-metric?");
 
-Stencil
-Font_metric::find_by_name (String) const
-{
-  Stencil m;
-  return m;
-}
 
 LY_DEFINE (ly_find_glyph_by_name, "ly:find-glyph-by-name",
           2, 0, 0,
@@ -199,6 +209,14 @@ LY_DEFINE (ly_font_design_size,"ly:font-design-size", 1 , 0, 0,
   return gh_double2scm (fm->design_size ());
 }
 
+
+
+int
+Font_metric::index_to_ascii (int i) const
+{
+  return i;
+}
+
 Stencil
 Font_metric::get_ascii_char_stencil (int code) const
 {
index 64a7d3ea71539e53181d31fe8e739510822844c3..ebf8b6afb6bc61bbad048b6dcd2d5285a13c51b5 100644 (file)
@@ -30,24 +30,22 @@ public:
 
   virtual int name_to_index (String) const;
   virtual int count () const;
+  virtual int index_to_ascii (int) const;
   virtual Box get_ascii_char (int) const;
   virtual Box get_indexed_char (int) const;
   virtual Offset get_indexed_wxwy (int) const;
   virtual String coding_scheme () const;
-  
-  AFM_CharMetricInfo const *find_char_metric (String name) const;
-  AFM_CharMetricInfo const *find_ascii_metric (int) const;  
-
-  String to_string () const;
   static SCM make_afm (AFM_Font_info*, unsigned, Real);
   virtual Real design_size () const;
 
 protected:
+  AFM_CharMetricInfo const *find_char_metric (String name) const;
+  AFM_CharMetricInfo const *find_ascii_metric (int) const;  
+
   Array<int> ascii_to_metric_idx_;
   std::map<String,int> name_to_metric_dict_;
 
   Adobe_font_metric (AFM_Font_info*);
-  virtual Stencil find_by_name (String) const;
 };
 
 SCM read_afm_file (String);
index d3574bbc35010d548c1cc110584f58b9715ffb3e..769a16095a83b252fa7d53924c9d21510985ab0d 100644 (file)
@@ -27,12 +27,12 @@ public:
   virtual Box get_indexed_char (int index) const;
   virtual Box get_ascii_char (int ascii) const;
   virtual int name_to_index (String) const;
+  virtual int index_to_ascii (int) const;
   virtual Real design_size () const;
   virtual Stencil find_by_name (String) const;
   virtual Stencil get_indexed_char_stencil (int k) const;
   virtual Stencil get_ascii_char_stencil (int k) const;
   virtual String coding_scheme () const;
-  //static int get_encoded_index (Font_metric *m, String input_coding, int code);
   
   DECLARE_SMOBS (Font_metric,);
 
index 5a738c01adfba69bb52223eaacc5d9376abb6356..687da0196dbe90c6ec82bc1fca73f5d7d50c4e81 100644 (file)
@@ -19,24 +19,30 @@ public:
   Box text_dimension (String);
   
   
-  virtual Stencil find_by_name (String) const;
-  static SCM make_scaled_font_metric (Font_metric*, Real);
+  static SCM make_scaled_font_metric (SCM, Font_metric*, Real);
   virtual int count () const;
   virtual Offset get_indexed_wxwy (int) const;
   virtual int name_to_index (String) const;
   virtual String coding_scheme () const;
 
+  /*should be protected?
+   */
+  SCM coding_vector_;
+  SCM coding_table_;
+  SCM coding_permutation_;
+  
 protected:
   virtual Real design_size () const;
   virtual void derived_mark (); 
-  virtual Box get_indexed_char (int)const;
+  virtual Box get_indexed_char (int) const;
+  virtual int index_to_ascii (int) const;
   virtual Box get_ascii_char (int) const;
   Font_metric *orig_;
   Real magnification_;
   String coding_scheme_;
-  SCM coding_vector_;
+
   
-  Modified_font_metric (Font_metric*, Real);
+  Modified_font_metric (String, Font_metric*, Real);
   Box tex_kludge (String) const;
 };
 
index b8a7818b407790208f11f1cd59c6a66fbe34c4b3..0ce204a0cf1e41917a04fdb298fdbc72bd1cc20c 100644 (file)
@@ -138,7 +138,6 @@ struct Tex_font_char_metric
   Array<Tfm_kern> kerns_;
   Array<Tfm_ligature> ligatures_;
 
-  String to_string () const;
   Tex_font_char_metric ();
 
   Box dimensions () const; 
@@ -154,17 +153,18 @@ public:
   virtual Box get_ascii_char (int) const;
   virtual Real design_size () const;
   virtual String coding_scheme () const;
+  virtual void derived_mark () const;
+  virtual int name_to_index (String) const;
   
-  Tex_font_char_metric const *find_ascii (int ascii, bool warn=true) const;
-
-  String to_string () const;
   
   Tfm_info info_;
   Tfm_header header_;
   Array<Tex_font_char_metric> char_metrics_;
   Array<int> ascii_to_metric_idx_;
-
+  SCM encoding_table_;
+  
 private:
+  Tex_font_char_metric const *find_ascii (int ascii, bool warn=true) const;
   Tex_font_metric ();
 };
 
index d00a08571d7e0bd38f8020fe4d3a1b38220a6dbd..444e5bef6bbd7dd92a8554e9d923f89a9f6a8bc3 100644 (file)
@@ -76,8 +76,8 @@ kpathsea_find_tfm (char const * name)
     warning (_f ("kpathsea can not find TFM file: `%s'", name));
   else
     return name_ptr;
-  
 #endif
+
   return "";
 }
 
@@ -154,40 +154,6 @@ void
 initialize_kpathsea (char *av0)
 {
 #if KPATHSEA && HAVE_KPATHSEA_KPATHSEA_H
-  /*
-    We take two pronged approach to tfms:
-
-    * the lilypond tfms (feta*.tfm) are found through our own routines.
-
-    * the TeX tfms are found through vanilla kpathsea.
-
-    (* other TFMs are not found, i.e. don't use them. )
-
-    PRO:
-    - TFM and AFM checksums always match in Lily.
-
-    - less hassle, no kpathsea spaghetti
-
-    CON:
-
-    - feta PK files are often recreated, locally
-    Solution: cache PK files locally?
-
-    - need env. vars to make sure that TeX finds the TFMs
-
-    - Outdated PK (TFM?) font files are not automatically removed,
-    since VERSION is not part of the standard location.
-
-
-    ALTERNATIVE
-
-    we have tried to come up with schemes that leave this kind of work
-    to kpathsea with objective of fixing the CONs, but miserably
-    failed. TeX installations and kpathsea itself form a buggy,
-    inconsistent, and unorderly mess.
-    
-  */
 
   /*
    initialize kpathsea
index 8fba6dc691404e069fe6f69c216f85cd04d41dd1..d1c513ebc7fa25aedf9426fae0f691a41e729057 100644 (file)
@@ -150,10 +150,11 @@ Paper_def::find_scaled_font (Font_metric *f, Real m)
   else
     {
       SCM scale_var = ly_module_lookup (scope_, ly_symbol2scm ("outputscale"));
+      SCM coding_var = ly_module_lookup (scope_, ly_symbol2scm ("inputcoding"));
 
       m /= gh_scm2double (scm_variable_ref (scale_var));
-
-      val = Modified_font_metric::make_scaled_font_metric (f, m);
+      val = Modified_font_metric::make_scaled_font_metric (scm_variable_ref (coding_var),
+                                                          f, m);
     }
 
   sizes = scm_acons (gh_double2scm (m), val, sizes);
index 270bc87d10b580e1f5f189229891153def62f32f..3c9e700f0484f880f1feb2c21d920226cb920eb2 100644 (file)
@@ -60,7 +60,7 @@ Performance::output (Midi_stream& midi_stream)
        MIDI players tend to ignore instrument settings on
        channel 10, the percussion channel by default.
        */
-      if (channel == 9)
+      if (channel % 16 == 9)
         channel++;
 
 
@@ -70,9 +70,9 @@ Performance::output (Midi_stream& midi_stream)
        */
       if (s->channel_ < 0)
        {
-         s->channel_ = channel <? 15;
+         s->channel_ = channel % 16;
          if (channel > 15)
-           warning ("MIDI channel wrapped around. Mapping to channel 15.");
+           warning ("MIDI channel wrapped around. Remapping modulo 16.");
        }
       
       s->output (midi_stream, channel++);
index 863e589034fd5194b72692bdb29e750dbbb5f2d2..4562a5f5102d7254ad3492ce2b11952f62fd6f7b 100644 (file)
 #include "string.hh"
 #include "stencil.hh"
 
-Modified_font_metric::Modified_font_metric (Font_metric* m, Real magn)
+Modified_font_metric::Modified_font_metric (String coding, Font_metric* m, Real magn)
 {
-  coding_vector_ =  SCM_EOL;
+  coding_vector_ = SCM_EOL;
+  coding_permutation_ = SCM_EOL;
+  coding_table_ = SCM_EOL;
+  
+  coding_scheme_ = coding;
   magnification_ = magn;
   SCM desc = m->description_;
 
@@ -28,11 +32,11 @@ Modified_font_metric::Modified_font_metric (Font_metric* m, Real magn)
 }
 
 SCM
-Modified_font_metric::make_scaled_font_metric (Font_metric *m, Real s)
+Modified_font_metric::make_scaled_font_metric (SCM coding, Font_metric *m, Real s)
 {
-  Modified_font_metric *sfm = new Modified_font_metric (m, s);
-
-  sfm->coding_scheme_ = "TeX";
+  String scheme = ly_scm2string (coding);
+  
+  Modified_font_metric *sfm = new Modified_font_metric (scheme, m, s);
   
   return sfm->self_scm ();
 }
@@ -43,15 +47,6 @@ Modified_font_metric::design_size () const
   return orig_->design_size ();
 }
 
-Stencil
-Modified_font_metric::find_by_name (String s) const
-{
-  Stencil m = orig_->find_by_name (s);
-  Box b = m.extent_box ();
-  b.scale (magnification_);
-  Stencil q (b,fontify_atom ((Font_metric*) this, m.get_expr ()));
-  return q;
-}
 
 Box 
 Modified_font_metric::get_indexed_char (int i) const
@@ -69,7 +64,6 @@ Modified_font_metric::get_ascii_char (int i) const
   return b;  
 }
 
-
 int
 Modified_font_metric::count () const
 {
@@ -84,11 +78,17 @@ Modified_font_metric::get_indexed_wxwy (int k) const
 }
 
 int
-Modified_font_metric::name_to_index (String s)const
+Modified_font_metric::name_to_index (String s) const
 {
   return orig_->name_to_index (s);
 }
 
+int
+Modified_font_metric::index_to_ascii (int k) const
+{
+  return orig_->index_to_ascii (k);
+}
+
 String
 Modified_font_metric::coding_scheme () const
 {
@@ -99,9 +99,10 @@ void
 Modified_font_metric::derived_mark ()
 {
   scm_gc_mark (coding_vector_);
+  scm_gc_mark (coding_table_);
+  scm_gc_mark (coding_permutation_);
 }
 
-
 Box
 Modified_font_metric::tex_kludge (String text) const
 {
@@ -113,11 +114,10 @@ Modified_font_metric::tex_kludge (String text) const
   */  
   for (int i = 0; i < text.length (); i++) 
     {
-      
       switch (text[i]) 
        {
        case '\\':
-  // accent marks use width of base letter
+         // accent marks use width of base letter
          if (i +1 < text.length ())
           {
             if (text[i+1]=='\'' || text[i+1]=='`' || text[i+1]=='"' ||
@@ -136,6 +136,7 @@ Modified_font_metric::tex_kludge (String text) const
          for (i++; (i < text.length ()) && !isspace (text[i]) 
                 && text[i]!='{' && text[i]!='}'; i++)
            ;
+         
          // ugh.
          i--; // Compensate for the increment in the outer loop!
          break;
@@ -197,6 +198,13 @@ Modified_font_metric::text_dimension (String text)
              programming_error ("get-coding-vector  should return vector");
              coding_vector_ = scm_c_make_vector (256, ly_symbol2scm (".notdef"));
            }
+
+         coding_table_ = scm_call_1 (ly_scheme_function ("get-coding-table"),
+                                     scm_makfrom0str (orig_->coding_scheme ().to_str0 ()));
+         
+         coding_permutation_  = scm_call_2 (ly_scheme_function ("make-encoding-permutation"),
+                                            coding_vector_,
+                                            coding_table_);
        }
          
       Interval ydims;
@@ -231,3 +239,17 @@ Modified_font_metric::text_dimension (String text)
   b.scale (magnification_);
   return b;
 }
+
+
+LY_DEFINE (ly_font_enccoding, "ly:font-encoding", 1 , 0, 0,
+         (SCM font),
+          "Given the Modified_font_metric @var{font}, return a "
+          "list containing (input-coding, output-coding, permutation).")
+{
+  Modified_font_metric * fm = dynamic_cast<Modified_font_metric *> ( unsmob_metrics (font));
+  SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "Modified_font_metric");
+  
+  return scm_list_3 (fm->coding_vector_,
+                    fm->coding_table_,
+                    fm->coding_permutation_);
+}
index 759384541724730450c3b70203b7f3af861052a9..c4b2eb522c067f5c52221e4899607740341403c4 100644 (file)
@@ -26,12 +26,13 @@ Text_item::interpret_markup (SCM paper, SCM props, SCM markup)
       
       Paper_def *pap = unsmob_paper (paper);
       Font_metric *fm = select_font (pap, props);
-      SCM lst = scm_list_n (ly_symbol2scm ("text"), markup, SCM_UNDEFINED);
-      
+      SCM lst = SCM_EOL;      
       Box b;
       if (Modified_font_metric* mf = dynamic_cast<Modified_font_metric*> (fm))
        {
-         lst = fontify_atom (mf, lst);
+         lst = scm_list_3 (ly_symbol2scm ("text"),
+                           mf->self_scm (),
+                           markup);
        
          b = mf->text_dimension (str);
        }
index 9d385184e5be8e5593c2b3bfa1cd45f9cb5459a5..276b62236ae1afe0645508bd2d7f9a3459c7144c 100644 (file)
@@ -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,15 +91,6 @@ 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)
 {
@@ -120,6 +102,11 @@ Tex_font_metric::make_tfm (String filename)
   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->info_.coding_scheme.to_str0 ()));
+
   return tfm->self_scm ();
 }
 
@@ -134,3 +121,17 @@ Tex_font_metric::coding_scheme () const
 {
   return info_.coding_scheme;
 }
+
+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 (scm_integer_p (idx) == SCM_BOOL_T)
+    {
+      return gh_scm2int (idx);
+    }
+  else
+    return -1;  
+}
index 39504deda5c12317defb81f3e488894ada5c1efc..c9ac536cc03e9d3a9f88170b6b2b96ae684bb905 100644 (file)
@@ -52,9 +52,11 @@ melismaEnd = #(make-span-event 'ManualMelismaEvent STOP)
     pt = #(/  in 72.27)
     cm = #(* 10 mm)
 
+    inputcoding = #"TeX"
     raggedright = ##f
     raggedlast = ##f 
     packed = ##f
+    
     #(define $is-paper #t)
     
     #(define font-defaults
index 9856776fdeb3b6ee780d920edf306722042bd5eb..c48931a02a961ba1635be530b6220d4564e9748d 100644 (file)
@@ -40,16 +40,16 @@ vector of symbols."
                (vector-ref permutation (char->integer chr)))
              str))
 
-(define-public (encoding-permutation input-encoding
-                                    output-encoding)
+(define-public (make-encoding-permutation input-encoding
+                                         output-encoding)
 
   "Contruct a permutation by applying output-encoding after input-encoding "
   (list->vector
    (map
-    (lambda (chr)
+    (lambda (byte)
       (let*
          ((new-char (hash-ref output-encoding
-                              (vector-ref input-encoding (char->integer chr)) #f)))
+                              (vector-ref input-encoding byte) #f)))
 
        ;; substitute space for unknown characters.
        (if (char? new-char)
@@ -92,7 +92,7 @@ vector of symbols."
         ("latin1" . "cork.enc")
         
         ;; LilyPond.
-        ("feta braces" . "feta-braces0.enc")
+        ("feta braces" . "feta-braces-a.enc")
         ("feta number" . "feta-nummer10.enc")
         ("feta music" . "feta20.enc")
         ("parmesan music" . "parmesan20.enc"))
@@ -101,10 +101,10 @@ vector of symbols."
 (define (get-coding coding-name)
   (force (assoc-get coding-name coding-alist )))
 
-(define (get-coding-vector coding-name)
+(define-public (get-coding-vector coding-name)
   (car (get-coding coding-name)))
 
-(define (get-coding-table coding-name)
+(define-public (get-coding-table coding-name)
   (cadr (get-coding coding-name)))
 
 
index b61352c34ca2902dce3dffb4ea460ee4dd252811..e13bbd74a52c2a402b540b03d3cea62264816ef2 100644 (file)
@@ -65,7 +65,6 @@
     (display "} } \n"))
 
 
-
 (define default-qualifier-order
   '(font-encoding font-family font-shape font-series))
 
 (define (lookup-font node alist-chain)
   (g-lookup-font node alist-chain))
 
-
-
 ;
 ; Each size family is a vector of fonts, loaded with a delay.
 ; The vector should be sorted according to ascending design size.
index cb4836f146c106778c2a76279c13da42b7f72008..f784997a40b84dc5a936870cbd6045d524c94b9b 100644 (file)
     (list arch_angle arch_width arch_height height arch_thick thick))
    " draw_bracket"))
 
-(define (char i)
+(define (char font i)
   (string-append 
+    (font-command font) " setfont " 
    "(\\" (ly:inexact->string i 8) ") show" ))
 
 (define (comment s)
   (string-append (ly:numbers->string (list breapth width depth height))
                 " draw_box"))
 
-(define (fontify font exp)
-  (string-append (font-command font) " setfont " exp))
-
 (define (header creator time-stamp page-count-)
   (set! page-count page-count-)
   (set! page-number 0)
    (ly:numbers->string (list h w thick))
    " draw_symmetric_x_triangle"))
 
-(define (text s)
+(define (text font s)
+  
 ;;  (string-append "(" (escape-parentheses s) ") show "))
-  (string-append "(" (ps-encoding s) ") show"))
+  (string-append
+
+   (font-command font) " setfont " 
+   "(" (ps-encoding s) ") show"))
 
 (define (unknown) 
   "\n unknown\n")
index c30d9a4ab2e67cbb316781e4c7b0fd2c9b842017..0a81c82ea54bd18905dfcef1fe1e033e0c4485cc 100644 (file)
@@ -11,7 +11,6 @@
   #:re-export (quote)
   #:export (define-fonts
             font-command
-            fontify
             unknown
             output-paper-def
             output-scopes
@@ -49,7 +48,7 @@
             start-page
             stop-page
             )
-)
+  )
 
 (use-modules (ice-9 regex)
             (ice-9 string-fun)
@@ -62,6 +61,7 @@
 ;;;;;;;; DOCUMENT ME!
 ;;;;;;;;
 
+
 (define (font-command font)
   (string-append
    "magfont"
@@ -75,9 +75,6 @@
   (apply string-append
         (map (lambda (x) (font-load-command paper x)) font-list)))
 
-(define (fontify font exp)
-  (string-append "\\" (font-command font) exp))
-
 (define (unknown) 
   "%\n\\unknown\n")
 
 (define (dashed-slur thick dash l)
   (embedded-ps (list 'dashed-slur thick dash `(quote ,l))))
 
-(define (char i)
-  (string-append "\\char" (ly:inexact->string i 10) " "))
+(define (char font i)
+  (string-append "\\" (font-command font)
+                "\\char" (ly:inexact->string i 10) " "))
 
 (define (dashed-line thick on off dx dy)
   (embedded-ps (list 'dashed-line  thick on off dx dy)))
    "\\def\\lilypondtagline{Engraved by LilyPond (version "
    (lilypond-version)")}\n"))
 
-(define (invoke-char s i)
-  (string-append 
-   "\n\\" s "{" (ly:inexact->string i 10) "}" ))
-
 ;; FIXME: explain ploblem: need to do something to make this really safe.  
 (define (output-tex-string s)
   (if safe-mode?
 (define (round-filled-box x y width height blotdiam)
   (embedded-ps (list 'round-filled-box  x y width height blotdiam)))
 
-(define (text s)
-  (string-append "\\hbox{" (output-tex-string s) "}"))
+(define (text font s)
+  (let*
+      ((perm (caddr (ly:font-encoding font))))
+  (display (ly:font-encoding font))
+  (string-append "\\hbox{\\" (font-command font) "{}"
+                (output-tex-string
+                 (if (vector? perm)
+                     (reencode-string perm s)
+                     s))
+                 "}")))
 
 (define (tuplet ht gapx dx dy thick dir)
   (embedded-ps (list 'tuplet  ht gapx dx dy thick dir)))
       (string-append "\\special{src:" ;;; \\string ? 
                     (point-and-click line col file)
                     "}" )
-      "")
-  )
+      ""))
 
 ;; no-origin not yet supported by Xdvi
 (define (no-origin) "")