From 973530e95ba4840a85efbfb3ddf6112d136a78c5 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Wed, 9 May 2001 15:43:26 +0200 Subject: [PATCH] patch::: 1.3.153.uu1 1.3.153.jcn1 ============ * Cleaned-up braces font selection code. --- CHANGES | 5 ++ VERSION | 2 +- lily/include/scaled-font-metric.hh | 2 +- lily/scaled-font-metric.cc | 6 ++ lily/system-start-delimiter.cc | 92 ++++++++++++------------------ lily/tfm.cc | 11 +++- mf/feta-beugel.mf | 16 +++++- mf/feta-braces7.mf | 11 ++++ mf/feta-braces8.mf | 11 ++++ scm/clef.scm | 2 +- scm/font.scm | 45 +++++++-------- scm/grob-description.scm | 1 - scm/grob-property-description.scm | 1 - 13 files changed, 115 insertions(+), 90 deletions(-) create mode 100644 mf/feta-braces7.mf create mode 100644 mf/feta-braces8.mf diff --git a/CHANGES b/CHANGES index 970fe5495f..b537d7bd4c 100644 --- 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 7a42bb0e2e..5a9e99b04d 100644 --- 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. diff --git a/lily/include/scaled-font-metric.hh b/lily/include/scaled-font-metric.hh index 0535df0fc2..4f7ca65fbc 100644 --- a/lily/include/scaled-font-metric.hh +++ b/lily/include/scaled-font-metric.hh @@ -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_; diff --git a/lily/scaled-font-metric.cc b/lily/scaled-font-metric.cc index c815c086cc..7077965c8f 100644 --- a/lily/scaled-font-metric.cc +++ b/lily/scaled-font-metric.cc @@ -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 (); +} diff --git a/lily/system-start-delimiter.cc b/lily/system-start-delimiter.cc index 355eab3218..b756d16a46 100644 --- a/lily/system-start-delimiter.cc +++ b/lily/system-start-delimiter.cc @@ -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); diff --git a/lily/tfm.cc b/lily/tfm.cc index 0a3e7362b5..6a8afd6e56 100644 --- a/lily/tfm.cc +++ b/lily/tfm.cc @@ -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 diff --git a/mf/feta-beugel.mf b/mf/feta-beugel.mf index fad6035df3..24a7168156 100644 --- a/mf/feta-beugel.mf +++ b/mf/feta-beugel.mf @@ -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 index 0000000000..0cae71d6bd --- /dev/null +++ b/mf/feta-braces7.mf @@ -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 +% + +font_count := 7; +input feta-beugel; +end. diff --git a/mf/feta-braces8.mf b/mf/feta-braces8.mf new file mode 100644 index 0000000000..a1071c5ffc --- /dev/null +++ b/mf/feta-braces8.mf @@ -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 +% + +font_count := 8; +input feta-beugel; +end. diff --git a/scm/clef.scm b/scm/clef.scm index f9625ff1d5..1d780f27c6 100644 --- a/scm/clef.scm +++ b/scm/clef.scm @@ -112,7 +112,7 @@ ) ((symbol . clefOctavation) (iterator-ctor . ,Property_iterator::constructor) - (value . ,oct) + (value . ,(- oct)) ) ) (begin diff --git a/scm/font.scm b/scm/font.scm index 9c7fb28461..68da4ee251 100644 --- a/scm/font.scm +++ b/scm/font.scm @@ -36,12 +36,28 @@ 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") @@ -102,26 +118,6 @@ ((-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") @@ -191,7 +187,8 @@ (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) diff --git a/scm/grob-description.scm b/scm/grob-description.scm index 9bcd05a788..b26ece9a3b 100644 --- a/scm/grob-description.scm +++ b/scm/grob-description.scm @@ -618,7 +618,6 @@ ;; 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. diff --git a/scm/grob-property-description.scm b/scm/grob-property-description.scm index 7ff894701e..ef4cec6beb 100644 --- a/scm/grob-property-description.scm +++ b/scm/grob-property-description.scm @@ -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.") -- 2.39.5