]> git.donarmstrong.com Git - lilypond.git/commitdiff
* input/test/tab-staff.ly: removed.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 1 Sep 2002 13:52:43 +0000 (13:52 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 1 Sep 2002 13:52:43 +0000 (13:52 +0000)
* lily/paper-def.cc (find_font): load virtual font for a list of
font names.

* scm/font.scm (paper20-style-sheet-alist): equate ancient and
music font-families.

* lily/virtual-font-metric.cc (get_char_molecule): new function

* lily/system-start-delimiter.cc (staff_brace): use virtual fonts
for the list of braces

* lily/font-metric.cc (get_char_molecule): new function.

18 files changed:
ChangeLog
Documentation/user/appendices.itely
Documentation/user/refman.itely
input/test/tab-staff.ly [deleted file]
lily/all-font-metrics.cc
lily/font-metric.cc
lily/include/font-metric.hh
lily/include/molecule.hh
lily/include/virtual-font-metric.hh
lily/molecule.cc
lily/note-head.cc
lily/paper-def.cc
lily/stem.cc
lily/system-start-delimiter.cc
lily/virtual-font-metric.cc
scm/font.scm
scm/lily.scm
scm/output-lib.scm

index 1abda0c5e06929327ee22a3b0fce1740b6f632d3..d3108b27956886f49b5d123bacbb44723f0efe51 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2002-09-01  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
+
+       * input/test/tab-staff.ly: removed.
+       
+       * lily/paper-def.cc (find_font): load virtual font for a list of
+       font names.
+
+       * scm/font.scm (paper20-style-sheet-alist): equate ancient and
+       music font-families.
+
+       * lily/virtual-font-metric.cc (get_char_molecule): new function
+
+       * lily/system-start-delimiter.cc (staff_brace): use virtual fonts
+       for the list of braces
+
+       * lily/font-metric.cc (get_char_molecule): new function.
+
 2002-08-31  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
 
        * lily/virtual-font-metric.cc: new file
index f09c9738e1bc2806fe0ee046c235147e2184b1c7..444219144d64d14c36abff7f5a29ddec334c1fb4 100644 (file)
@@ -210,3 +210,6 @@ accessed directly using text markup such as
 
 @lilypondfile{feta16list.ly}
 
+
+@lilypondfile{parmesan16list.ly}
+
index 8b6cd7a8d2fd860e9464526aade31240376f4117..e0acc8c5589bbbf0df28650f58ad37969d763db2 100644 (file)
@@ -3615,7 +3615,6 @@ NoteHead grob to @code{mensural}. There is also a note head style
 
 @lilypond[fragment,singleline,verbatim]
  \property Voice.NoteHead \set #'style = #'mensural
- \property Voice.NoteHead \set #'font-family = #'ancient
  a'\longa
 @end lilypond
 
@@ -3682,8 +3681,8 @@ block:
 @subsection Ancient clefs
 
 LilyPond supports a variety of clefs, many of them ancient. These can
-be selected from the @code{ancient} font family, by setting
-@code{Staff.clefGlyph}) to one of the following values
+be selected by setting @code{Staff.clefGlyph}) to one of the following
+values
 
 @table @code
 @item clefs-C
diff --git a/input/test/tab-staff.ly b/input/test/tab-staff.ly
deleted file mode 100644 (file)
index e51beac..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-\version "1.5.68"
-
-
-
-%{
-
-Kludge for half-assed tab notation (you need to fill the numbers
-yourself.)
-
-%}
-
-bla =  \notes \relative c' { <c4 e g>  <c4. e g> <c8 f a> <c4 f a> <c1 e g> } 
-
-\score { \notes
-<
-  \context Voice = BLA \bla
-  \context TabStaff \context Thread \bla
->
-
-\paper {
- \translator {
-  \StaffContext
-  \name TabStaff
-  StaffSymbol \override #'line-count = #6
-  \remove "Clef_engraver"
-  \remove "Time_signature_engraver"
-  \consists "Pitch_squash_engraver"
-   NoteHead \override #'transparent = ##t
-   Stem \override #'transparent = ##t
-   NoteHead \override #'staff-position = #-6
-   Dots \override #'transparent = ##t
-   squashedPosition = #-4
-   Stem \override #'length = #12
-}
-\translator {
-\ScoreContext
-\accepts TabStaff
-}
-}
-}
index fad161affbdd51bc9ab33cf6882adcd04bd4cb56..a00877a75b1b2fe01a1b74bf00462aae52647ed6 100644 (file)
@@ -153,6 +153,7 @@ All_font_metrics::find_tfm (String name)
 }
 
 
+
 Font_metric *
 All_font_metrics::find_font (String name)
 {
index 4a5d1f7550414bcb4313999a19008595eefab55f..5608420982e8fd548f38f1742fa4aefc058ccfed 100644 (file)
@@ -116,7 +116,7 @@ Font_metric::mark_smob (SCM s)
 {
   Font_metric * m = (Font_metric*) SCM_CELL_WORD_1 (s);
 
-  do_derived_mark();
+  m->derived_mark();
   return m->description_;
 }
 
@@ -174,3 +174,16 @@ number-pairs.")
 }
 
 
+
+
+  
+Molecule
+Font_metric::get_char_molecule (int code)  const
+{
+  Molecule  m ;
+  SCM at = scm_list_n (ly_symbol2scm ("char"), gh_int2scm (code),
+                      SCM_UNDEFINED);
+  at = fontify_atom (this, at);
+  Box b = get_char (code);
+  return Molecule (b, at);
+}
index 99e89cff6b1dd1f1f4883a1f99025bc312a1bb63..9e202831676c900af1ae7dab863e5801fcc5a03e 100644 (file)
@@ -24,6 +24,7 @@ public:
   
   virtual int count () const;
   virtual Box get_char (int ascii) const;
+  virtual Molecule get_char_molecule (int ascii) const;
   virtual Box text_dimension (String)  const;
   virtual Molecule find_by_name (String) const;
   DECLARE_SMOBS (Font_metric,);
index fd4833d71fe3b7c65d172f91bdd72ecde9007cfb..a1b887066f840c23c0d782e9324bdebc887a0436 100644 (file)
@@ -89,7 +89,7 @@ public:
 
 
 DECLARE_UNSMOB(Molecule,molecule);
-SCM fontify_atom (Font_metric*, SCM atom);
+SCM fontify_atom (Font_metric const*, SCM atom);
 
 Molecule create_molecule (SCM brew_molecule);
 
index c65116fea9bea4ab365ed181ffe156c3c46aa61f..65bf6bdd134826047b12bfd32de8e30b72e70650 100644 (file)
@@ -17,10 +17,12 @@ class Virtual_font_metric : public Font_metric
 {
   SCM font_list_;
 public:
-  Virtual_font_metric (SCM namelist);
+  Virtual_font_metric (SCM namelist, Real, Paper_def*);
 
   virtual int count () const;
   virtual Box get_char (int ascii) const;
+  virtual Molecule get_char_molecule (int ascii) const;
+  
   virtual Molecule find_by_name (String) const;
 
 protected:
index 1a5efa8c76abbf0347f7c794051e376a484d88c3..15cc8f2f07c37e5d281144eed8fa14b2226b77c0 100644 (file)
@@ -262,7 +262,7 @@ dumped in the output file.")
 }
 
 SCM
-fontify_atom (Font_metric * met, SCM f)
+fontify_atom (Font_metric const * met, SCM f)
 {
   if (f == SCM_EOL)
     return f;
index 377425ce89a0d0f9ff49c94e0744e3eee0751d27..662121ad66907997e5e60ea32ffc6920a25f8089 100644 (file)
@@ -127,8 +127,8 @@ internal_brew_molecule (Grob *me,  bool ledger_take_space)
   String font_family = ly_scm2string (scm_font_family);
 
   me->set_grob_property("font-family", ly_symbol2scm (font_family.to_str0 ()));
-  Molecule out =
-    Font_interface::get_default_font (me)->find_by_name (font_char);
+  Font_metric * fm = Font_interface::get_default_font (me);
+  Molecule out = fm->find_by_name (font_char);
   if (out.empty_b())
     {
       me->warning (_f ("Symbol `%s' not found in family `%s'",
index e00444cf5d6ae51224368376e917b53ae6c7f187..f6bf6ec19bd404f485e5b6200aed8ed5981942b8 100644 (file)
@@ -6,8 +6,10 @@
   (c)  1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
+
 #include <math.h>
 
+#include "virtual-font-metric.hh"
 #include "all-font-metrics.hh"
 #include "string.hh"
 #include "misc.hh"
@@ -133,6 +135,8 @@ Paper_def::get_paper_outputter ()
 
 /*
   todo: use symbols and hashtable idx?
+
+
 */
 Font_metric *
 Paper_def::find_font (SCM fn, Real m)
@@ -143,19 +147,31 @@ Paper_def::find_font (SCM fn, Real m)
   if (gh_pair_p (met))
     return unsmob_metrics (ly_cdr (met));
 
-  SCM ssc;
-  if (variable_tab_->try_retrieve (ly_symbol2scm ("outputscale"), &ssc))
+  /*
+    Hmm. We're chaining font - metrics. Should consider wether to merge
+    virtual-font and scaled_font.
+   */
+  Font_metric*  f=0;
+  if (gh_list_p (fn))
     {
-      m /= gh_scm2double (ssc);
+      f = new Virtual_font_metric (fn, m, this);
+    }
+  else
+    {
+      SCM ssc;
+      if (variable_tab_->try_retrieve (ly_symbol2scm ("outputscale"), &ssc))
+       {
+         m /= gh_scm2double (ssc);
+       }
+
+      f = all_fonts_global->find_font (ly_scm2string (fn));
+      SCM val = Scaled_font_metric::make_scaled_font_metric (f, m);
+      scaled_fonts_ = scm_acons (key, val, scaled_fonts_);
+      f = unsmob_metrics (val);
+      scm_gc_unprotect_object (val);
     }
-  
-  Font_metric*  f = all_fonts_global->find_font (ly_scm2string (fn));
-  SCM val = Scaled_font_metric::make_scaled_font_metric (f, m);
-  scaled_fonts_ = scm_acons (key, val, scaled_fonts_);
-
-  scm_gc_unprotect_object (val);
 
-  return dynamic_cast<Scaled_font_metric*> (unsmob_metrics (val));
+  return f;
 }
 
 
index fa3401e2a923348ff7b9dd8b2861b3d8302be108..a7bd85ea37cff510a9feeb785ab5a169512eaabf 100644 (file)
@@ -823,11 +823,7 @@ Stem::calc_stem_info (Grob *me)
                    me->get_grob_property ("beamed-minimum-free-lengths")))
     * staff_space;
   
-  int my_beam_count = Stem::beam_multiplicity (me).length () + 1;
-#if 0
-  Real height_of_my_beams = beam_thickness
-    + (my_beam_count - 1) * beam_translation;
-#else
+
   /* UGH
      It seems that also for ideal minimum length, we must use
      the maximum beam count (for this direction):
@@ -837,7 +833,6 @@ Stem::calc_stem_info (Grob *me)
      must be horizontal. */
   Real height_of_my_beams = beam_thickness
     + (beam_count - 1) * beam_translation;
-#endif
 
   Real ideal_minimum_length = ideal_minimum_free
     + height_of_my_beams
index 38f0dc7100ab9ad6533478b97479a9dc247d243e..a301c88972107f2f43094dfc4eb6bdafe255812c 100644 (file)
@@ -127,27 +127,17 @@ System_start_delimiter::staff_brace (Grob*me, Real y)
 {
   Font_metric *fm = 0;
   
-  for (int i = 0; ; i++)
-    {
-      if (!fm || y > fm->get_char (fm->count ()-1)[Y_AXIS].length ())
-       {
-         /* We go through the style sheet to lookup the font file
-            name.  This is better than using find_font directly,
-            esp. because that triggers mktextfm for non-existent
-            fonts. */
-         SCM br = ly_symbol2scm ("braces");
-         SCM fam = gh_cons (ly_symbol2scm ("font-family"), br);
-         SCM sz = gh_cons (ly_symbol2scm ("font-relative-size"), gh_int2scm (i));
-
-         SCM alist = scm_list_n (fam, sz, SCM_UNDEFINED);
-         fm = Font_interface::get_font (me, scm_list_n (alist, SCM_UNDEFINED));
-         /* Hmm, if lookup fails, we get cmr10 anyway */
-         if (ly_scm2string (ly_car (fm->description_)) == "cmr10")
-           break;
-       }
-      else
-       break;
-    }
+  /* We go through the style sheet to lookup the font file
+     name.  This is better than using find_font directly,
+     esp. because that triggers mktextfm for non-existent
+     fonts. */
+  SCM br = ly_symbol2scm ("braces");
+  SCM fam = gh_cons (ly_symbol2scm ("font-family"), br);
+  SCM sz = gh_cons (ly_symbol2scm ("font-relative-size"), ly_symbol2scm ("*"));
+  
+  SCM alist = scm_list_n (fam, sz, SCM_UNDEFINED);
+  fm = Font_interface::get_font (me, scm_list_n (alist, SCM_UNDEFINED));
+  
 
   int lo = 0;
 
@@ -166,13 +156,11 @@ System_start_delimiter::staff_brace (Grob*me, Real y)
     }
   while (hi - lo > 1);
       
-  SCM at = scm_list_n (ly_symbol2scm ("char"), gh_int2scm (lo), SCM_UNDEFINED);
-  at = fontify_atom (fm, at);
-  
-  b = fm->get_char (lo);
+  Molecule m (fm->get_char_molecule (lo));
+  b=m.extent_box();
   b[X_AXIS] = Interval (0,0);
 
-  return Molecule (b, at);
+  return Molecule (b, m.get_expr());
 }
   
 
index c0db6afd23b5383284372d39f7e1dd203b6a65d1..78e8806e4bdb42fb65077038b9d76d7031b3e9cf 100644 (file)
@@ -11,20 +11,23 @@ source file of the GNU LilyPond music typesetter
 #include "all-font-metrics.hh"
 #include "main.hh"
 #include "molecule.hh"
+#include "paper-def.hh"
 
 
-Virtual_font_metric::Virtual_font_metric (SCM name_list)
-  :
-  Font_metric(),
-    font_list_ (SCM_EOL)
+/*
+  passing DEF is ughish. Should move into paperdef?
+  */
+Virtual_font_metric::Virtual_font_metric (SCM name_list, 
+                                         Real mag,Paper_def*def)
 {
+  font_list_ = SCM_EOL;
   SCM *tail = &font_list_;
   for (SCM s = name_list; gh_pair_p (s); s = gh_cdr (s))
     {
       SCM nm = gh_car (s);
 
-      Font_metric *fm = all_fonts_global->find_font (ly_scm2string (nm));
-      *tail =  scm_cons (fm->self_scm(), *tail);
+      Font_metric *fm = def->find_font (nm, mag);
+      *tail =  scm_cons (fm->self_scm(),SCM_EOL);
       tail = SCM_CDRLOC (*tail);
     }
 }
@@ -81,3 +84,24 @@ Virtual_font_metric::get_char (int code)  const
   return Box();
 }
   
+  
+Molecule
+Virtual_font_metric::get_char_molecule (int code)  const
+{
+  Molecule  m ;  
+  int last_k = 0;
+  for (SCM s = font_list_; gh_pair_p (s); s = gh_cdr (s))
+    {
+      Font_metric* fm = unsmob_metrics (gh_car (s));
+      int k = last_k + fm->count ();
+      if (last_k <= code && code < k)
+       {
+         m = fm->get_char_molecule (code - last_k);
+         break; 
+       }
+      last_k = k;
+    }
+
+  return m;
+}
+  
index f72a401b67884b8c46c480b4c372d55a73b79f5f..116382de82236e6911b92f0703dc103016561222 100644 (file)
       )
 
 (define paper-style-sheet-alist
-  '(
-    ((8 * * braces 8) . "feta-braces8")
-    ((7 * * braces 7) . "feta-braces7")
-    ((6 * * braces 6) . "feta-braces6")
-    ((5 * * braces 5) . "feta-braces5")
-    ((4 * * braces 4) . "feta-braces4")
-    ((3 * * braces 3) . "feta-braces3")
-    ((2 * * braces 2) . "feta-braces2")
-    ((1 * * braces 1) . "feta-braces1")
-    ((0 * * braces 0) . "feta-braces0")
-    ))
+  `(
+    ((* * * braces *) . ("feta-braces0"
+                        "feta-braces1"
+                        "feta-braces2"
+                        "feta-braces3"
+                        "feta-braces4"
+                        "feta-braces5"
+                        "feta-braces6"
+                        "feta-braces7"
+                        "feta-braces8") )))
 
 ;; FIXME: what about this comment?:
+
+;; font-lookup seems a  little inefficient -- walking this entire list
+;; for a single font.
+;;
 ;;   should really have name/pt size at the front of the list.
 ;;   (also tried to vary the order of this list, with little effect)
 ;;
     ((-4 * * dynamic 7) . "feta-din7")
     ((-5 * * dynamic 6) . "feta-din6")
 
-    ((2 * * music 26) . "feta26")
-    ((1 * * music 23) . "feta23")
-    ((0 * * music 20) . "feta20")
-    ((-1 * * music 16) . "feta16")
-    ((-2 * * music 13) . "feta13")
-    ((-3 * * music 11) . "feta11")
-    ((-4 * * music 11) . "feta11")
-
-    ((2 * * ancient 26) . "parmesan26")
-    ((1 * * ancient 23) . "parmesan23")
-    ((0 * * ancient 20) . "parmesan20")
-    ((-1 * * ancient 16) . "parmesan16")
-    ((-2 * * ancient 13) . "parmesan13")
-    ((-3 * * ancient 11) . "parmesan11")
-    ((-4 * * ancient 11) . "parmesan11")
+    ((2 * * music 26) . ("feta26" "parmesan26"))
+    ((1 * * music 23) . ("feta23" "parmesan23"))
+    ((0 * * music 20) . ("feta20" "parmesan20"))
+    ((-1 * * music 16) . ("feta16" "parmesan16"))
+    ((-2 * * music 13) . ("feta13" "parmesan13"))
+    ((-3 * * music 11) . ("feta11" "parmesan11"))
+    ((-4 * * music 11) . ("feta11" "parmesan11"))
+    
+    ((2 * * ancient 26) . ("feta26" "parmesan26"))
+    ((1 * * ancient 23) . ("feta23" "parmesan23"))
+    ((0 * * ancient 20) . ("feta20" "parmesan20"))
+    ((-1 * * ancient 16) . ("feta16" "parmesan16"))
+    ((-2 * * ancient 13) . ("feta13" "parmesan13"))
+    ((-3 * * ancient 11) . ("feta11" "parmesan11"))
+    ((-4 * * ancient 11) . ("feta11" "parmesan11"))
 
     ((0 * * math 10) . "msam10")
     ((-1 * * math 10) . "msam10")
 ;; 
 (define (change-relative-size font-desc decrement)
   "return a FONT-DESCR with relative size decremented by DECREMENT"
-  (cons (- (car font-desc) decrement) (cdr font-desc))
+
+  (if (number? (car font-desc))
+      (cons (- (car font-desc) decrement) (cdr font-desc))
+      font-desc)
   )
 
 (define (change-rhs-size font-desc from to )
        (regexp-substitute/global #f from (cdr font-desc) 'pre to 'post))
 
   )
-
   
 ;; 
 (define (map-alist-keys func list)
                    ))
   )
 
-(set! font-list-alist
+;;
+;; make a kludged up paper-19 style sheet. Broken by virtual fonts.
+;;
+(if #f
+    (set! font-list-alist
       (cons
        (cons
        'paper19
        (map (lambda (x) (change-rhs-size x "20" "19"))
             paper20-style-sheet-alist))
-       font-list-alist))
+       font-list-alist)))
 
 (define (make-style-sheet sym)
   `((fonts . ,(append paper-style-sheet-alist
index 6771baa6c40bb07332ccb936e5058b8fac8afa36..9b03a36349581c787a3d5793ef555db7989ed2e8 100644 (file)
@@ -18,9 +18,9 @@
 
 ;; debugging evaluator is slower.
 
-;(debug-enable 'debug)
-;(debug-enable 'backtrace)
-;(read-enable 'positions)
+(debug-enable 'debug)
+(debug-enable 'backtrace)
+(read-enable 'positions)
 
 
 (define point-and-click #f)
index 8eb01fe45e8807b03fa23ddd67b5daf32977aef0..3d167bb6fca98069d810703739664227221490df 100644 (file)
     ;; brevis, longa and maxima from the neo-mensural font and all
     ;; other note heads from the default font.  -- jr
     (if (< duration 0)
-       (cons (string-append (number->string duration) "neo_mensural") "ancient")
+       (cons (string-append (number->string duration) "neo_mensural") "music")
        (cons (number->string duration) "music")))
    ((mensural)
     (cons (string-append (number->string duration) (symbol->string style))
-     "ancient"))
+     "music"))
    ((neo_mensural)
     (cons (string-append (number->string duration) (symbol->string style))
-     "ancient"))
+     "music"))
    ((default)
     ;; The default font in mf/feta-bolletjes.mf defines a brevis, but
     ;; neither a longa nor a maxima.  Hence let us, for the moment,
     ;; should look exactly like the brevis of the default font, but
     ;; with a stem exactly like that of the quarter note. -- jr
     (if (< duration -1)
-       (cons (string-append (number->string duration) "neo_mensural") "ancient")
+       (cons (string-append (number->string duration) "neo_mensural") "music")
        (cons (number->string duration) "music")))
    (else
     (if (string-match "vaticana*|hufnagel*|medicaea*" (symbol->string style))
-       (cons (symbol->string style) "ancient")
+       (cons (symbol->string style) "music")
        (cons (string-append (number->string (max 0 duration))
                             (symbol->string style))
              "music")))))