]> git.donarmstrong.com Git - lilypond.git/commitdiff
patch::: 1.3.153.uu1
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 9 May 2001 13:43:26 +0000 (15:43 +0200)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 9 May 2001 13:43:26 +0000 (15:43 +0200)
1.3.153.jcn1
============

* Cleaned-up braces font selection code.

13 files changed:
CHANGES
VERSION
lily/include/scaled-font-metric.hh
lily/scaled-font-metric.cc
lily/system-start-delimiter.cc
lily/tfm.cc
mf/feta-beugel.mf
mf/feta-braces7.mf [new file with mode: 0644]
mf/feta-braces8.mf [new file with mode: 0644]
scm/clef.scm
scm/font.scm
scm/grob-description.scm
scm/grob-property-description.scm

diff --git a/CHANGES b/CHANGES
index 970fe5495fd962a404b4145f27a91815f0c2eacb..b537d7bd4c1eec0e2fb9d7b6159a66cd40b30b41 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+1.3.153.jcn1
+============
+
+* Cleaned-up braces font selection code.
+
 1.3.153
 =======
 
diff --git a/VERSION b/VERSION
index 7a42bb0e2e21c9231a95fe1be0ec44af8cd66d50..5a9e99b04d754ca83ee2c66650266731a8359744 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=3
 PATCH_LEVEL=153
-MY_PATCH_LEVEL=
+MY_PATCH_LEVEL=uu1
 
 # use the above to send patches: MY_PATCH_LEVEL is always empty for a
 # released version.
index 0535df0fc2768560845071096b7d13e570935345..4f7ca65fbc1cb56f3bbdce926c0be09545f7c8cf 100644 (file)
@@ -20,7 +20,7 @@ struct Scaled_font_metric : public Font_metric
   virtual Box text_dimension (String) const;
   virtual Molecule find_by_name (String) const;
   static SCM make_scaled_font_metric (Font_metric*, Real);
-
+  virtual int count () const;
 protected:
   virtual   Box get_char (int)const;
   Font_metric *orig_l_;
index c815c086cc9c0f1539046d4ef1d28527bc7f3dfc..7077965c8f46c59a75c2232e63225c093cba3cb5 100644 (file)
@@ -56,3 +56,9 @@ Scaled_font_metric::text_dimension (String t) const
   b.scale (magnification_f_);
   return b;
 }
+
+int
+Scaled_font_metric::count () const
+{
+  return orig_l_->count ();
+}
index 355eab3218e5b985cb9c179d0a8be3f36e1fcfb9..b756d16a46eae68638da6b48fee7fde7e346aa4d 100644 (file)
@@ -140,69 +140,47 @@ System_start_delimiter::brew_molecule (SCM smob)
 Molecule
 System_start_delimiter::staff_brace (Grob*me, Real y)
 {
-  Font_metric *fm = Font_interface::get_default_font (me);
-  SCM font_defaults = gh_cdr (scm_assoc (ly_symbol2scm ("font-defaults"),
-                                        me->paper_l ()->style_sheet_));
+  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 alist = gh_list (gh_cons (ly_symbol2scm ("font-family"),
+                                       ly_symbol2scm ("braces")),
+                              gh_cons (ly_symbol2scm ("font-relative-size"),
+                                       gh_int2scm (i)),
+                              SCM_UNDEFINED);
+         fm = Font_interface::get_font (me, gh_list (alist, SCM_UNDEFINED));
+         /* Hmm, if lookup fails, we get cmr10 anyway */
+         if (ly_scm2string (gh_car (fm->description_)) == "cmr10")
+           break;
+       }
+      else
+       break;
+    }
 
-  Box b;
-#if 0
-  b = fm->get_char (0);
-  int count = fm->count () >? 2;
-#else 
-  int count = 255;
-#endif     
   int lo = 0;
-  int hi = count;
-  int relative_size = 0;
+
+  int hi = (fm->count () - 1) >? 2;
+  Box b;
 
   /* do a binary search for each Y, not very efficient, but passable?  */
   do
-  {
-    int cmp = (lo + hi) / 2;
-    b = fm->get_char (cmp);
-    if (b[Y_AXIS].empty_b () || b[Y_AXIS].length () > y)
-      hi = cmp;
-    else
-      lo = cmp;
-
-    if (lo == count - 1 && b[Y_AXIS].length () < y && relative_size < 10)
-      {
-       /*
-         ugh: 7
-         We have four fonts: feta-braces0-3.mf
-         
-         In the style-sheet, all paper relative sizes need to start
-         looking at the feta-braces0 font.
-         
-         The smallest paper size, feta11 or -3, has to make 5 steps
-         to get to feta26 or +2.  Only after that, from +3 to +8 are
-         the real bigger sizes, so worst case we need 11 steps to get
-         to the font we need. */
-       fm = Font_interface::get_font
-         (me,
-          gh_list (gh_list (gh_cons (ly_symbol2scm ("font-relative-size"),
-                                     gh_int2scm (++relative_size)),
-                            SCM_UNDEFINED),
-                   me->mutable_property_alist_,
-                   me->immutable_property_alist_,
-                   font_defaults,
-                   SCM_UNDEFINED));
-#if 0
-       b = fm->get_char (0);
-       count = fm->count () >? 2;
-#else
-       count = 255;
-#endif     
-       lo = 0;
-       hi = count;
-      }
-  }
+    {
+      int cmp = (lo + hi) / 2;
+      b = fm->get_char (cmp);
+      if (b[Y_AXIS].empty_b () || b[Y_AXIS].length () > y)
+       hi = cmp;
+      else
+       lo = cmp;
+    }
   while (hi - lo > 1);
-
-  // uRGURGU, why doesn't the height calculation work out??
-  SCM weird = me->get_grob_property ("weird");
-  if (gh_number_p (weird))
-    lo += gh_scm2int (weird);
+      
   SCM at = gh_list (ly_symbol2scm ("char"), gh_int2scm (lo), SCM_UNDEFINED);
   at = fontify_atom (fm, at);
   
index 0a3e7362b5dc9d52ac7655c6c928cef79b17de5b..6a8afd6e5626dea5528cad592c350378abb49d9c 100644 (file)
@@ -79,10 +79,19 @@ Tex_font_metric::find_ascii (int ascii, bool warn) const
   return &dummy_static_char_metric;  
 }
 
+
+/*
+  UGH: glyphs need not be consecutive in TFM.
+ */
 int
 Tex_font_metric::count () const
 {
-  return ascii_to_metric_idx_.size ();
+  for (int i = ascii_to_metric_idx_.size (); i--;)
+    {
+      if (ascii_to_metric_idx_[i] != -1)
+       return i + 1;
+    }
+  return 0;
 }
 
 Box
index fad6035df3efcf9b62fe07ca317929c064a567fe..24a7168156e20e16f31f9861148b994d03911813 100644 (file)
@@ -11,7 +11,8 @@ save code;
 code := 0;
 
 
-def draw_brace (expr height_sharp, width_sharp, slt_sharp) = 
+def draw_brace (expr height_sharp, width_sharp, slt_sharp) =
+
        save pendir, height, width, thin, thick, slt;
        save penangle;
        height# := height_sharp;
@@ -46,11 +47,20 @@ def draw_brace (expr height_sharp, width_sharp, slt_sharp) =
 endchar;
 enddef;
 
-l := 0.05pt#;
+
+
+% l is the increment.
+l := 0.2pt#;
 y := 10pt#;
 
+
+
 for i := 0 step 1 until font_count:
-  for j := 0 step 1 until 255:
+
+  %% We can't store more than 64 (65?) height dimensions in a TFM
+  %% file, so we make small files.
+
+  for j := 0 step 1 until 65:
     % message "l: "&decimal l;
     % note: define_pixels (x) multiplies x by hppp,
     % must never get bigger than infinity
diff --git a/mf/feta-braces7.mf b/mf/feta-braces7.mf
new file mode 100644 (file)
index 0000000..0cae71d
--- /dev/null
@@ -0,0 +1,11 @@
+% 
+% feta-braces6.mf --  next 256 braces
+% 
+% source file of the Feta (Font-En-Tja) music font
+% 
+% (c) 1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+% 
+
+font_count := 7;
+input feta-beugel;
+end.
diff --git a/mf/feta-braces8.mf b/mf/feta-braces8.mf
new file mode 100644 (file)
index 0000000..a1071c5
--- /dev/null
@@ -0,0 +1,11 @@
+% 
+% feta-braces6.mf --  next 256 braces
+% 
+% source file of the Feta (Font-En-Tja) music font
+% 
+% (c) 1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+% 
+
+font_count := 8;
+input feta-beugel;
+end.
index f9625ff1d56dc970c96738b87da695b1414f2f4f..1d780f27c677f8773712874df61420033ed1a048 100644 (file)
           )
          ((symbol . clefOctavation)
                 (iterator-ctor . ,Property_iterator::constructor)
-                (value . ,oct)
+                (value . ,(- oct))
               )
          )
        (begin
index 9c7fb284611361b538190b2e55eafb52f9e08082..68da4ee2515535c1bf6af334ecb91a6400770983 100644 (file)
        font-descr-alist)
       )
 
-;; should really have name/pt size at the front of the list.
+(define paper-style-sheet-alist
+  '(
+    ((8 * * braces feta-braces 8) . "feta-braces8")
+    ((7 * * braces feta-braces 7) . "feta-braces7")
+    ((6 * * braces feta-braces 6) . "feta-braces6")
+    ((5 * * braces feta-braces 5) . "feta-braces5")
+    ((4 * * braces feta-braces 4) . "feta-braces4")
+    ((3 * * braces feta-braces 3) . "feta-braces3")
+    ((2 * * braces feta-braces 2) . "feta-braces2")
+    ((1 * * braces feta-braces 1) . "feta-braces1")
+    ((0 * * braces feta-braces 0) . "feta-braces0")
+    ))
+
+;; FIXME: what about this comment?:
+;;   should really have name/pt size at the front of the list.
+;;   (also tried to vary the order of this list, with little effect)
 ;;
-;; (also tried to vary the order of this list, with little effect)
+;; (font-relative-size font-series font-shape font-family font-name
+;; font-design-size)
 (define paper20-style-sheet-alist
   '(
-    ;; why are font-names strings, not symbols?
+    ;; why are font file names strings, not symbols?
     ((3 medium upright number feta-nummer 13) . "feta-nummer13")
     ((2 medium upright number feta-nummer 13) . "feta-nummer13")
     ((1 medium upright number feta-nummer 11) . "feta-nummer11")
     ((-2 medium caps roman cmcsc 7) . "cmcsc7")
     ((-3 medium caps roman cmcsc 7) . "cmcsc7")
 
-    ;; smallest needs 11 steps: -3 to +8, so
-    ;; biggest also needs 11 available steps: +2 to + 13
-    ((13 * * braces feta-braces 6) . "feta-braces6")
-    ((12 * * braces feta-braces 6) . "feta-braces6")
-    ((11 * * braces feta-braces 6) . "feta-braces6")
-    ((10 * * braces feta-braces 6) . "feta-braces6")
-    ((9 * * braces feta-braces 6) . "feta-braces6")
-    ((8 * * braces feta-braces 6) . "feta-braces6")
-    ((7 * * braces feta-braces 5) . "feta-braces5")
-    ((6 * * braces feta-braces 4) . "feta-braces4")
-    ((5 * * braces feta-braces 3) . "feta-braces3")
-    ((4 * * braces feta-braces 2) . "feta-braces2")
-    ((3 * * braces feta-braces 1) . "feta-braces1")
-    ((2 * * braces feta-braces 0) . "feta-braces0")
-    ((1 * * braces feta-braces 0) . "feta-braces0")
-    ((0 * * braces feta-braces 0) . "feta-braces0")
-    ((-1 * * braces feta-braces 0) . "feta-braces0")
-    ((-2 * * braces feta-braces 0) . "feta-braces0")
-    ((-3 * * braces feta-braces 0) . "feta-braces0")
-
     ((3 * * dynamic feta-din 19) . "feta-din19")
     ((2 * * dynamic feta-din 19) . "feta-din19")
     ((1 * * dynamic feta-din 17) . "feta-din17")
 
 
 (define (make-style-sheet sym)
-  `((fonts . ,(cdr (assoc sym font-list-alist)))
+  `((fonts . ,(append paper-style-sheet-alist
+                     (cdr (assoc sym font-list-alist))))
     (font-defaults
      . ((font-family . music)
        (font-relative-size . 0)
index 9bcd05a78854c402c7ac84832c0c774d12d3816a..b26ece9a3bf2c9a69657d5a0b47f24822be36390 100644 (file)
 
        ;; TODO: should split in 3
        (SystemStartDelimiter . (
-                ;; (weird . 0)
                (molecule-callback . ,System_start_delimiter::brew_molecule)
                (after-line-breaking-callback . ,System_start_delimiter::after_line_breaking)
                ;; really 4.0, but 5 to be on safe side.
index 7ff894701ebb18ef1669af22392fce8b2ad1b755..ef4cec6bebb0481e33752813afa373bf28a357c7 100644 (file)
@@ -358,7 +358,6 @@ Like @code{tuplet-bracket-visibility}, but for the number.")
 function of type (beam multiplicity dy staff-line-thickness) -> real.  Default value: default-beam-y-quants, also available: beam-traditional-y-quants.
 .")
 (grob-property-description 'visibility-lambda procedure? "a function that takes the break direction and returns a  cons of booleans containing (TRANSPARENT . EMPTY).")
-(grob-property-description 'weird number? "urg?")
 (grob-property-description 'when moment? "when does this column happen?.")
 (grob-property-description 'word-space number? "elongate left by this much (FIXME: cumbersome semantics).")
 (grob-property-description 'x-gap number? "horizontal gap between notehead and tie.")