]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scm/output-tex.scm: remove fontify; text and char take a font
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 6 Apr 2004 21:55:58 +0000 (21:55 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 6 Apr 2004 21:55:58 +0000 (21:55 +0000)
argument.

* lily/tfm.cc (name_to_index): new function, use encoding_table_.

* lily/scaled-font-metric.cc (text_dimension): init
coding_{permutation,table}_ too
(LY_DEFINE): ly:font-encoding, new function return

ChangeLog
lily/scaled-font-metric.cc
lily/stencil.cc
lily/tfm.cc
scm/output-ps.scm
scm/output-tex.scm

index 294b2d3c261feaad99685f1a2eed6b47aa99c99c..45e66a739e7a248332e07e48694d312bb7ce0af1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2004-04-06  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
+       * scm/output-tex.scm: remove fontify; text and char take a font
+       argument.
+
+       * lily/tfm.cc (name_to_index): new function, use encoding_table_.
+
+       * lily/scaled-font-metric.cc (text_dimension): init
+       coding_{permutation,table}_ too 
+       (LY_DEFINE): ly:font-encoding, new function return
+
+       * lily/paper-def.cc (find_scaled_font): take input coding from
+       inputcoding paper var.
+
        * lily/performance.cc (output): remap modulo 16.
 
        * lily/text-item.cc (interpret_markup): whoops, variable
index 4562a5f5102d7254ad3492ce2b11952f62fd6f7b..3e6f2caa6f32f2a18ddb15de219356fab3a7c141 100644 (file)
@@ -185,6 +185,10 @@ Modified_font_metric::text_dimension (String text)
          w += b[X_AXIS].length ();
          ydims.unite (b[Y_AXIS]); 
        }
+      if (ydims.is_empty ())
+       ydims = Interval (0, 0);
+
+      b = Box(Interval(0,w), ydims);
     }
   else
     {
@@ -217,21 +221,28 @@ Modified_font_metric::text_dimension (String text)
 
          Box char_box;
 
-         if (!gh_symbol_p (sym))
+         if (!gh_symbol_p (sym) && !gh_string_p (sym))
            continue;
-         
-         int idx = orig_->name_to_index (SCM_SYMBOL_CHARS(sym));
 
+         char const * chars = gh_symbol_p (sym)
+           ? SCM_SYMBOL_CHARS(sym) : SCM_STRING_CHARS(sym); 
+           
+         
+         int idx = orig_->name_to_index (chars);
          if (idx >= 0)
            {
              char_box = orig_->get_indexed_char (idx);
            }
+         
          if (!char_box[X_AXIS].is_empty ())
            w += char_box[X_AXIS][RIGHT]; // length ?
 
          ydims.unite (char_box[Y_AXIS]);
        }
 
+      if (ydims.is_empty ())
+       ydims = Interval (0, 0);
+
          
       b = Box (Interval (0, w), ydims);
     }
@@ -246,9 +257,10 @@ LY_DEFINE (ly_font_enccoding, "ly:font-encoding", 1 , 0, 0,
           "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");
+  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 fade2d75ea0d55a86cd2c35677e3fa71dc586d1e..a01e13a9aad87c8f672914abf158ed5a1733a1a3 100644 (file)
@@ -115,7 +115,9 @@ Stencil
 Stencil::moved_to_edge (Axis a, Direction d, Stencil const &s, Real padding,
                        Real minimum) const
 {
-  Real my_extent= is_empty () ? 0.0 : dim_[a][d];
+  Interval my_extent=  dim_[a];
+
+
   Interval i (s.extent (a));
   Real his_extent;
   if (i.is_empty ())
@@ -126,7 +128,8 @@ Stencil::moved_to_edge (Axis a, Direction d, Stencil const &s, Real padding,
   else
     his_extent = i[-d];
 
-  Real offset = (my_extent -  his_extent) + d * padding;
+  Real offset = (my_extent.  is_empty () ? 0.0 : my_extent[d] - his_extent)
+    + d * padding;
 
   Stencil toadd (s);
   toadd.translate_axis (offset,a);
@@ -142,7 +145,7 @@ Stencil::moved_to_edge (Axis a, Direction d, Stencil const &s, Real padding,
 /*  See scheme Function.  */
 void
 Stencil::add_at_edge (Axis a, Direction d, Stencil const &s, Real padding,
-                      Real minimum)
+                     Real minimum)
 {
   add_stencil (moved_to_edge (a,d,s,padding, minimum));
 }
index 276b62236ae1afe0645508bd2d7f9a3459c7144c..2e0bf25167beca30e08c7dd8822b6c5993c5648e 100644 (file)
@@ -125,12 +125,12 @@ Tex_font_metric::coding_scheme () const
 int
 Tex_font_metric::name_to_index (String s) const
 {
-  SCM sym = ly_symbol2scm (s.to_str0 ());
+  SCM sym = scm_makfrom0str (s.to_str0 ());
 
   SCM idx = scm_hash_ref (encoding_table_, sym, SCM_BOOL_F);
-  if (scm_integer_p (idx) == SCM_BOOL_T)
+  if (gh_char_p (idx))
     {
-      return gh_scm2int (idx);
+      return (unsigned char) gh_scm2char (idx);
     }
   else
     return -1;  
index f784997a40b84dc5a936870cbd6045d524c94b9b..628700cfabe120fc60fec6711c64552411bfce0a 100644 (file)
     (inexact->exact (round (* 1000 (ly:font-magnification font)))))))
 
 (define (define-fonts paper font-list)
-
-  (define (fontname->designsize fontname)
-    (let ((i (string-index fontname char-numeric?)))
-      (string->number (substring fontname i))))
-  
   (define (define-font command fontname scaling)
     (string-append
      "/" command " { /" fontname " findfont "
index 0a81c82ea54bd18905dfcef1fe1e033e0c4485cc..a65863f383e8f9fa5e4a6c6ea35170aed46bf7a7 100644 (file)
 (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)