From a22bde704f74bbf1d75e08de6ab5d22e8d8f5fec Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sun, 1 Sep 2002 13:52:43 +0000 Subject: [PATCH] * 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. --- ChangeLog | 17 +++++++ Documentation/user/appendices.itely | 3 ++ Documentation/user/refman.itely | 5 +-- input/test/tab-staff.ly | 40 ----------------- lily/all-font-metrics.cc | 1 + lily/font-metric.cc | 15 ++++++- lily/include/font-metric.hh | 1 + lily/include/molecule.hh | 2 +- lily/include/virtual-font-metric.hh | 4 +- lily/molecule.cc | 2 +- lily/note-head.cc | 4 +- lily/paper-def.cc | 36 ++++++++++----- lily/stem.cc | 7 +-- lily/system-start-delimiter.cc | 40 ++++++----------- lily/virtual-font-metric.cc | 36 ++++++++++++--- scm/font.scm | 69 ++++++++++++++++------------- scm/lily.scm | 6 +-- scm/output-lib.scm | 10 ++--- 18 files changed, 163 insertions(+), 135 deletions(-) delete mode 100644 input/test/tab-staff.ly diff --git a/ChangeLog b/ChangeLog index 1abda0c5e0..d3108b2795 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2002-09-01 Han-Wen Nienhuys + + * 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 * lily/virtual-font-metric.cc: new file diff --git a/Documentation/user/appendices.itely b/Documentation/user/appendices.itely index f09c9738e1..444219144d 100644 --- a/Documentation/user/appendices.itely +++ b/Documentation/user/appendices.itely @@ -210,3 +210,6 @@ accessed directly using text markup such as @lilypondfile{feta16list.ly} + +@lilypondfile{parmesan16list.ly} + diff --git a/Documentation/user/refman.itely b/Documentation/user/refman.itely index 8b6cd7a8d2..e0acc8c558 100644 --- a/Documentation/user/refman.itely +++ b/Documentation/user/refman.itely @@ -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 index e51beac322..0000000000 --- a/input/test/tab-staff.ly +++ /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' { } - -\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 -} -} -} diff --git a/lily/all-font-metrics.cc b/lily/all-font-metrics.cc index fad161affb..a00877a75b 100644 --- a/lily/all-font-metrics.cc +++ b/lily/all-font-metrics.cc @@ -153,6 +153,7 @@ All_font_metrics::find_tfm (String name) } + Font_metric * All_font_metrics::find_font (String name) { diff --git a/lily/font-metric.cc b/lily/font-metric.cc index 4a5d1f7550..5608420982 100644 --- a/lily/font-metric.cc +++ b/lily/font-metric.cc @@ -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); +} diff --git a/lily/include/font-metric.hh b/lily/include/font-metric.hh index 99e89cff6b..9e20283167 100644 --- a/lily/include/font-metric.hh +++ b/lily/include/font-metric.hh @@ -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,); diff --git a/lily/include/molecule.hh b/lily/include/molecule.hh index fd4833d71f..a1b887066f 100644 --- a/lily/include/molecule.hh +++ b/lily/include/molecule.hh @@ -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); diff --git a/lily/include/virtual-font-metric.hh b/lily/include/virtual-font-metric.hh index c65116fea9..65bf6bdd13 100644 --- a/lily/include/virtual-font-metric.hh +++ b/lily/include/virtual-font-metric.hh @@ -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: diff --git a/lily/molecule.cc b/lily/molecule.cc index 1a5efa8c76..15cc8f2f07 100644 --- a/lily/molecule.cc +++ b/lily/molecule.cc @@ -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; diff --git a/lily/note-head.cc b/lily/note-head.cc index 377425ce89..662121ad66 100644 --- a/lily/note-head.cc +++ b/lily/note-head.cc @@ -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'", diff --git a/lily/paper-def.cc b/lily/paper-def.cc index e00444cf5d..f6bf6ec19b 100644 --- a/lily/paper-def.cc +++ b/lily/paper-def.cc @@ -6,8 +6,10 @@ (c) 1997--2002 Han-Wen Nienhuys */ + #include +#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 (unsmob_metrics (val)); + return f; } diff --git a/lily/stem.cc b/lily/stem.cc index fa3401e2a9..a7bd85ea37 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -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 diff --git a/lily/system-start-delimiter.cc b/lily/system-start-delimiter.cc index 38f0dc7100..a301c88972 100644 --- a/lily/system-start-delimiter.cc +++ b/lily/system-start-delimiter.cc @@ -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()); } diff --git a/lily/virtual-font-metric.cc b/lily/virtual-font-metric.cc index c0db6afd23..78e8806e4b 100644 --- a/lily/virtual-font-metric.cc +++ b/lily/virtual-font-metric.cc @@ -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; +} + diff --git a/scm/font.scm b/scm/font.scm index f72a401b67..116382de82 100644 --- a/scm/font.scm +++ b/scm/font.scm @@ -40,19 +40,22 @@ ) (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) ;; @@ -136,21 +139,21 @@ ((-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") @@ -161,7 +164,10 @@ ;; (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 ) @@ -169,7 +175,6 @@ (regexp-substitute/global #f from (cdr font-desc) 'pre to 'post)) ) - ;; (define (map-alist-keys func list) @@ -207,13 +212,17 @@ )) ) -(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 diff --git a/scm/lily.scm b/scm/lily.scm index 6771baa6c4..9b03a36349 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -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) diff --git a/scm/output-lib.scm b/scm/output-lib.scm index 8eb01fe45e..3d167bb6fc 100644 --- a/scm/output-lib.scm +++ b/scm/output-lib.scm @@ -135,14 +135,14 @@ ;; 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, @@ -151,11 +151,11 @@ ;; 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"))))) -- 2.39.5