From a0f4b682135cf77e168a7201adbb4d083a1972d4 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Mon, 30 Oct 2000 00:54:34 +0100 Subject: [PATCH] release: 1.3.100 =========== * Tweaks of .scm font-selection. * Rewrote font management of Score_element and Paper_def. * Introduced outputscale: internally do computation in terms of outputscale. Prepare to deprecate staffspace internally. Rewrote .scm side of font selectioning. 1.3.99.j --- CHANGES | 44 +--- NEWS | 2 + VERSION | 4 +- input/test/noteheadstyle.ly | 44 ++-- lily/afm.cc | 14 +- lily/all-font-metrics.cc | 60 +----- lily/arpeggio.cc | 6 +- lily/bar.cc | 4 +- lily/chord-name-engraver.cc | 2 +- lily/chord-name.cc | 2 +- lily/clef-item.cc | 4 +- lily/crescendo.cc | 2 +- lily/dots.cc | 4 +- lily/font-interface.cc | 45 ++++ lily/font-metric.cc | 29 ++- lily/grace-align-item.cc | 2 +- lily/include/afm.hh | 4 +- lily/include/all-font-metrics.hh | 6 +- lily/include/font-interface.hh | 21 ++ lily/include/font-metric.hh | 18 +- lily/include/paper-def.hh | 5 +- lily/include/score-element.hh | 2 - lily/include/stem.hh | 1 + lily/include/tfm.hh | 2 +- lily/key-item.cc | 6 +- lily/line-of-score.cc | 2 +- lily/local-key-item.cc | 10 +- lily/molecule.cc | 9 +- lily/multi-measure-rest.cc | 6 +- lily/note-head.cc | 6 +- lily/paper-def.cc | 56 ++++- lily/paper-outputter.cc | 10 - lily/paper-score.cc | 7 +- lily/piano-pedal-engraver.cc | 1 - lily/rest.cc | 4 +- lily/rhythmic-head.cc | 5 - lily/scaled-font-metric.cc | 25 +-- lily/score-element.cc | 31 --- lily/script.cc | 6 +- lily/separating-group-spanner.cc | 2 +- lily/slur.cc | 1 - lily/span-bar.cc | 2 +- lily/stem.cc | 6 +- lily/sustain-pedal.cc | 4 +- lily/system-start-delimiter.cc | 18 +- lily/text-item.cc | 31 ++- lily/text-spanner.cc | 2 +- lily/tfm.cc | 5 +- lily/time-signature.cc | 7 +- lily/tuplet-spanner.cc | 2 +- lily/volta-spanner.cc | 6 +- ly/params.ly | 1 + make/out/lilypond.lsm | 8 +- make/out/lilypond.spec | 4 +- mf/feta-din12.mf | 0 mf/feta-din14.mf | 0 mf/feta-din3.mf | 0 mf/feta-din6.mf | 0 mf/feta-nummer12.mf | 0 mf/feta-nummer14.mf | 0 mf/feta-nummer3.mf | 0 mf/feta-nummer6.mf | 0 scm/ascii-script.scm | 190 +++++++++++++++++ scm/element-descriptions.scm | 82 ++++--- scm/font.scm | 43 ++-- scm/lily.scm | 352 +++++++------------------------ scripts/abc2ly.py | 60 +----- tex/lily-ps-defs.tex | 5 +- 68 files changed, 666 insertions(+), 676 deletions(-) create mode 100644 lily/font-interface.cc create mode 100644 lily/include/font-interface.hh delete mode 100644 mf/feta-din12.mf delete mode 100644 mf/feta-din14.mf delete mode 100644 mf/feta-din3.mf delete mode 100644 mf/feta-din6.mf delete mode 100644 mf/feta-nummer12.mf delete mode 100644 mf/feta-nummer14.mf delete mode 100644 mf/feta-nummer3.mf delete mode 100644 mf/feta-nummer6.mf create mode 100644 scm/ascii-script.scm diff --git a/CHANGES b/CHANGES index 9f8dc8ce2c..4f26feaf91 100644 --- a/CHANGES +++ b/CHANGES @@ -1,49 +1,15 @@ ---- ../lilypond-1.3.99.jcn1/CHANGES Wed Oct 25 21:33:46 2000 -++ b/CHANGES Sat Oct 28 15:44:16 2000 -@@ -1,3 +1,16 @@ -1.3.99.jcn2 -=========== - -* Font initialisation and markup translation fixes. - 1.3.99.hwn2 =========== -* tweaks of .scm font-selection. +* Tweaks of .scm font-selection. * Rewrote font management of Score_element and Paper_def. +* Introduced outputscale: internally do computation in terms of +outputscale. Prepare to deprecate staffspace internally. Rewrote +.scm side of font selectioning. - 1.3.99.jcn1 - =========== - --- ../lilypond-1.3.99/CHANGES Wed Oct 25 07:03:07 2000 -++ b/CHANGES Fri Oct 27 20:28:15 2000 -@@ -1,3 +1,25 @@ -1.3.99.lec1 -=========== -* fixes to abc2ly: - - puts text above rather than below the staff. - - interprets %%MIDI nobarlines (this is an esoteric change, but - I need it to use the program at all -- it assumes that - accidentals are not persistent. - - Interprets the -8va tenor g clef. - - Fix to previously claimed fix for setting L: before M: - - Uses current rather than deprecated syntax for \property - Staff.TimeSignature - - Allows a space between key letter and mode. - - Fix to translation table for :|: - - - 1.3.98.jcn2 - =========== - 1.3.99.jcn1 +1.3.99.jcn1 =========== * Made several font size and initialisation fixes. diff --git a/NEWS b/NEWS index de0d3f6cf1..f83626e69a 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,8 @@ internals: LilyPond is smaller, cleaner, more flexible, etc. - Improved robustness: Lily almost never crashes. +* Rewritten font selection, Latex-NFSS like + * Piano pedal support, Arpeggios * MIDI: dynamics, tempo changes diff --git a/VERSION b/VERSION index 6d8d7dab12..b7c53f15f6 100644 --- a/VERSION +++ b/VERSION @@ -1,8 +1,8 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=3 -PATCH_LEVEL=99 -MY_PATCH_LEVEL=jcn3 +PATCH_LEVEL=100 +MY_PATCH_LEVEL= # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/input/test/noteheadstyle.ly b/input/test/noteheadstyle.ly index 70e879a476..0db7a577c9 100644 --- a/input/test/noteheadstyle.ly +++ b/input/test/noteheadstyle.ly @@ -1,43 +1,49 @@ + \score { \notes \relative c{ -c''4 c2 c8 c16 c16 c1 c\breve -\property Voice.noteHeadStyle = #'diamond +% anyone wanna pop? +c''4 c2 c8 c16 c16 c1 c\breve +\property Voice.NoteHead \push #'style = #'diamond c4 c2 c8 c16 c16 c1 c\breve -\property Voice.noteHeadStyle = #'transparent +\property Voice.NoteHead \push #'style = #'transparent c4 c2 c8 c16 c16 c1 c\breve -\property Voice.noteHeadStyle = #'cross +\property Voice.NoteHead \push #'style = #'cross c4 c2 c8 c16 c16 c1 c\breve -\property Voice.noteHeadStyle = #'mensural +\property Voice.NoteHead \push #'style = #'mensural c4 c2 c8 c16 c16 c1 c\breve c\longa -\property Voice.noteHeadStyle = #'harmonic +\property Voice.NoteHead \push #'style = #'harmonic c4 c2 c8 c16 c16 c1 c\breve -\property Voice.noteHeadStyle = #'baroque +\property Voice.NoteHead \push #'style = #'baroque c4 c2 c8 c16 c16 c1 c\breve c\longa + \context Voice < \context Thread = TA - { \property Thread.noteHeadStyle = #'cross - \property Voice.verticalDirection = \up c16} + { + \property Thread.NoteHead \push #'style = #'cross + \property Voice.Stem \push #'direction = #1 + c16 + } \context Thread = TB - { \property Thread.noteHeadStyle = #'default a16 } - + { \property Thread.NoteHead \push #'style = #'default a16 } + \context Thread = TC - { \property Thread.noteHeadStyle = #'mensural d16 } - + { \property Thread.NoteHead \push #'style = #'mensural d16 } + > - + \context Voice <\context Thread = TA { - \property Thread.noteHeadStyle = #'default + \property Thread.NoteHead \push #'style = #'default c4 c4 } \context Thread = TB { - \property Thread.noteHeadStyle = #'mensural + \property Thread.NoteHead \push #'style = #'mensural c'4 \stemDown c } > } \paper { - - } + + +} } -\version "1.3.96"; diff --git a/lily/afm.cc b/lily/afm.cc index 7fcca1bd6a..1efee67213 100644 --- a/lily/afm.cc +++ b/lily/afm.cc @@ -74,7 +74,7 @@ Adobe_font_metric::find_char_metric (String nm, bool warn) const Box -Adobe_font_metric::get_char (int code, Real mag) const +Adobe_font_metric::get_char (int code) const { AFM_CharMetricInfo const * c = find_ascii_metric (code,false); @@ -82,7 +82,6 @@ Adobe_font_metric::get_char (int code, Real mag) const if (c) b = afm_bbox_to_box (c->charBBox); - b.scale (mag); return b; } @@ -96,7 +95,7 @@ read_afm_file (String nm) if (ok) { - error (_f ("Error parsing AFM file: %s", nm.ch_C ())); + error (_("Error parsing AFM file")); exit (2); } fclose (f); @@ -119,8 +118,11 @@ Adobe_font_metric::~Adobe_font_metric () AFM_free (font_inf_); } +/* + return a molecule, without fontification + */ Molecule -Adobe_font_metric::find_by_name (String s, Real mag) const +Adobe_font_metric::find_by_name (String s) const { AFM_CharMetricInfo const *cm = find_char_metric (s, false); @@ -135,8 +137,8 @@ Adobe_font_metric::find_by_name (String s, Real mag) const gh_int2scm (cm->code), SCM_UNDEFINED)); - at= fontify_atom ((Font_metric*)this, at); + // at= fontify_atom ((Font_metric*)this, at); Box b = afm_bbox_to_box (cm->charBBox); - b.scale (mag); + return Molecule (b, at); } diff --git a/lily/all-font-metrics.cc b/lily/all-font-metrics.cc index 795664edf4..2d3f73140e 100644 --- a/lily/all-font-metrics.cc +++ b/lily/all-font-metrics.cc @@ -28,7 +28,6 @@ All_font_metrics::All_font_metrics (String path) { afm_p_dict_ = new Scheme_hash_table; tfm_p_dict_ = new Scheme_hash_table; - scaled_p_dict_ = new Scheme_hash_table; search_path_.parse_path (path); } @@ -37,7 +36,6 @@ All_font_metrics::~All_font_metrics () { scm_unprotect_object (afm_p_dict_->self_scm ()); scm_unprotect_object (tfm_p_dict_->self_scm ()); - scm_unprotect_object (scaled_p_dict_->self_scm ()); } Adobe_font_metric * @@ -45,6 +43,8 @@ All_font_metrics::find_afm (String name) { SCM sname = ly_symbol2scm (name.ch_C ()); + SCM name_str = gh_str02scm (name.ch_C ()); + SCM val; if (!afm_p_dict_->try_retrieve (sname, &val)) @@ -68,7 +68,7 @@ All_font_metrics::find_afm (String name) progress_indication ("[" + path); val = read_afm_file (path); - unsmob_metrics (val)->name_ = sname; + unsmob_metrics (val)->description_ = gh_cons (name_str, gh_double2scm (1.0)); if (verbose_global_b) progress_indication ("]"); @@ -81,30 +81,12 @@ All_font_metrics::find_afm (String name) return dynamic_cast (unsmob_metrics (val)); } -Scaled_font_metric * -All_font_metrics::find_scaled (String nm, Real m) -{ - String index = nm + "@" + to_str (m); - SCM sname = ly_symbol2scm (index.ch_C ()); - - SCM val; - - if (!scaled_p_dict_->try_retrieve (sname, &val)) - { - Font_metric *f = find_font (nm); - val = Scaled_font_metric::make_scaled_font_metric (f, m); - scaled_p_dict_->set (sname, val); - - scm_unprotect_object (val); - } - - return dynamic_cast (unsmob_metrics (val)); -} Tex_font_metric * All_font_metrics::find_tfm (String name) { SCM sname = ly_symbol2scm (name.ch_C ()); + SCM name_str = gh_str02scm (name.ch_C ()); SCM val; if (!tfm_p_dict_->try_retrieve (sname, &val)) @@ -129,7 +111,7 @@ All_font_metrics::find_tfm (String name) if (verbose_global_b) progress_indication ("]"); - unsmob_metrics (val)->name_ = sname; + unsmob_metrics (val)->description_ = gh_cons (name_str, gh_double2scm (1.0)); tfm_p_dict_->set (sname, val); scm_unprotect_object (val); @@ -143,9 +125,7 @@ All_font_metrics::find_tfm (String name) Font_metric * All_font_metrics::find_font (String name) { - Font_metric * f=0; - - f= find_afm (name); + Font_metric * f= find_afm (name); if (f) return f; @@ -178,32 +158,4 @@ All_font_metrics::find_font (String name) return 0; } -SCM -All_font_metrics::font_descriptions () const -{ - SCM l[] = {0,0,0}; - l[0] = afm_p_dict_->to_alist (); - l[1] = tfm_p_dict_->to_alist (); - l[2] = scaled_p_dict_->to_alist (); - - SCM list = SCM_EOL; - for (int i=0; i < 3; i++) - { - for (SCM s = l[i]; gh_pair_p (s); s = gh_cdr (s)) - { - Font_metric * fm = unsmob_metrics (gh_cdar (s)); - - list = gh_cons (fm->description (), list); - } - } - return list; -} - - - -Font_metric* -find_font (String name) -{ - return all_fonts_global_p->find_font (name); -} diff --git a/lily/arpeggio.cc b/lily/arpeggio.cc index aebc96b830..1c2d79d14d 100644 --- a/lily/arpeggio.cc +++ b/lily/arpeggio.cc @@ -8,13 +8,13 @@ #include "molecule.hh" #include "paper-def.hh" -#include "font-metric.hh" #include "arpeggio.hh" #include "score-element.hh" #include "stem.hh" #include "staff-symbol-referencer.hh" #include "staff-symbol.hh" #include "warn.hh" +#include "font-interface.hh" bool Arpeggio::has_interface (Score_element* me) @@ -68,7 +68,7 @@ Arpeggio::brew_molecule (SCM smob) } Molecule mol; - Molecule arpeggio = me->get_default_font ()->find_by_name ("scripts-arpeggio"); + Molecule arpeggio = Font_interface::get_default_font (me)->find_by_name ("scripts-arpeggio"); Real y = heads[LEFT]; while (y < heads[RIGHT]) @@ -93,7 +93,7 @@ Arpeggio::width_callback (SCM smob, SCM axis) Score_element * me = unsmob_element (smob); Axis a = (Axis)gh_scm2int (axis); assert (a == X_AXIS); - Molecule arpeggio = me->get_default_font ()->find_by_name ("scripts-arpeggio"); + Molecule arpeggio = Font_interface::get_default_font (me)->find_by_name ("scripts-arpeggio"); return ly_interval2scm (arpeggio.extent (X_AXIS) * 1.5); } diff --git a/lily/bar.cc b/lily/bar.cc index 3305fd945f..9da7babb50 100644 --- a/lily/bar.cc +++ b/lily/bar.cc @@ -15,7 +15,7 @@ #include "string.hh" #include "molecule.hh" #include "paper-def.hh" -#include "font-metric.hh" +#include "font-interface.hh" #include "debug.hh" #include "all-font-metrics.hh" #include "item.hh" @@ -61,7 +61,7 @@ Bar::compound_barline (Score_element*me, String str, Real h) Molecule thin = simple_barline (me, hair, h); Molecule thick = simple_barline (me, fatline, h); - Molecule colon = me->get_default_font ()->find_by_name ("dots-repeatcolon"); + Molecule colon = Font_interface::get_default_font (me)->find_by_name ("dots-repeatcolon"); Molecule m; diff --git a/lily/chord-name-engraver.cc b/lily/chord-name-engraver.cc index b49f03bce8..8729cb57a2 100644 --- a/lily/chord-name-engraver.cc +++ b/lily/chord-name-engraver.cc @@ -11,7 +11,7 @@ #include "chord.hh" #include "musical-request.hh" #include "paper-def.hh" -#include "font-metric.hh" +#include "font-interface.hh" #include "paper-def.hh" #include "main.hh" #include "dimensions.hh" diff --git a/lily/chord-name.cc b/lily/chord-name.cc index 7f42c25407..2b17c561b3 100644 --- a/lily/chord-name.cc +++ b/lily/chord-name.cc @@ -9,7 +9,7 @@ #include "chord-name.hh" #include "molecule.hh" #include "paper-def.hh" -#include "font-metric.hh" +#include "font-interface.hh" #include "score-element.hh" #include "paper-column.hh" #include "line-of-score.hh" diff --git a/lily/clef-item.cc b/lily/clef-item.cc index 4985ac69b9..a96275bb60 100644 --- a/lily/clef-item.cc +++ b/lily/clef-item.cc @@ -11,7 +11,7 @@ #include "string.hh" #include "molecule.hh" #include "item.hh" -#include "font-metric.hh" +#include "font-interface.hh" /* FIXME: should use symbol for #'style. @@ -76,7 +76,7 @@ Clef::brew_molecule (SCM smob) SCM glyph = sc->get_elt_property ("glyph"); if (gh_string_p (glyph)) { - return sc->get_default_font ()->find_by_name (String (ly_scm2string (glyph))).create_scheme (); + return Font_interface::get_default_font (sc)->find_by_name (String (ly_scm2string (glyph))).create_scheme (); } else { diff --git a/lily/crescendo.cc b/lily/crescendo.cc index 2f7535f6f8..be54a96e62 100644 --- a/lily/crescendo.cc +++ b/lily/crescendo.cc @@ -9,7 +9,7 @@ #include "molecule.hh" #include "crescendo.hh" #include "spanner.hh" -#include "font-metric.hh" +#include "font-interface.hh" #include "dimensions.hh" #include "paper-def.hh" #include "debug.hh" diff --git a/lily/dots.cc b/lily/dots.cc index 4e9dc5659a..28ef9a5526 100644 --- a/lily/dots.cc +++ b/lily/dots.cc @@ -10,7 +10,7 @@ #include "item.hh" #include "molecule.hh" #include "paper-def.hh" -#include "font-metric.hh" +#include "font-interface.hh" #include "lookup.hh" #include "staff-symbol-referencer.hh" #include "directional-element-interface.hh" @@ -54,7 +54,7 @@ Dots::brew_molecule (SCM d) if (gh_number_p (c)) { - Molecule d = sc->get_default_font ()->find_by_name (String ("dots-dot")); + Molecule d = Font_interface::get_default_font (sc)->find_by_name (String ("dots-dot")); Real dw = d.extent (X_AXIS).length (); // d.translate_axis (-dw, X_AXIS); diff --git a/lily/font-interface.cc b/lily/font-interface.cc new file mode 100644 index 0000000000..3255c8bd8f --- /dev/null +++ b/lily/font-interface.cc @@ -0,0 +1,45 @@ +/* + font-interface.cc -- implement Font_interface + + source file of the GNU LilyPond music typesetter + + (c) 2000 Han-Wen Nienhuys + + */ + +#include "all-font-metrics.hh" +#include "font-metric.hh" +#include "font-interface.hh" +#include "score-element.hh" +#include "paper-def.hh" + +/* + todO : split up this func, reuse in text_item? + */ +Font_metric * +Font_interface::get_default_font (Score_element*me) +{ + Font_metric * fm = unsmob_metrics (me->get_elt_property ("font")); + if (fm) + return fm; + + SCM ss = me->paper_l ()->style_sheet_; + + SCM proc = gh_cdr (scm_assoc (ly_symbol2scm ("properties-to-font"), + ss)); + + SCM fonts = gh_cdr (scm_assoc (ly_symbol2scm ("fonts"), ss)); + SCM defaults = gh_cdr (scm_assoc (ly_symbol2scm ("font-defaults"), + ss)); + + assert (gh_procedure_p (proc)); + SCM font_name = gh_call2 (proc, fonts, + gh_list (me->mutable_property_alist_, + me->immutable_property_alist_, + defaults, + SCM_UNDEFINED)); + + fm = me->paper_l ()->find_font (font_name, 1.0); + me->set_elt_property ("font", fm->self_scm ()); + return fm; +} diff --git a/lily/font-metric.cc b/lily/font-metric.cc index 08a27382ce..6eb97a0c01 100644 --- a/lily/font-metric.cc +++ b/lily/font-metric.cc @@ -17,7 +17,7 @@ #include "string.hh" Box -Font_metric::text_dimension (String text, Real mag) const +Font_metric::text_dimension (String text) const { Interval ydims; Real w=0.0; @@ -39,11 +39,11 @@ Font_metric::text_dimension (String text, Real mag) const break; default: - Box b = get_char ((unsigned char)text[i],mag); + Box b = get_char ((unsigned char)text[i]); // Ugh, use the width of 'x' for unknown characters if (b[X_AXIS].length () == 0) - b = get_char ((unsigned char)'x',mag); + b = get_char ((unsigned char)'x'); w += b[X_AXIS].length (); ydims.unite (b[Y_AXIS]); @@ -58,11 +58,11 @@ Font_metric::text_dimension (String text, Real mag) const Box -Scaled_font_metric::text_dimension (String t,Real mag) const +Scaled_font_metric::text_dimension (String t) const { Box b (orig_l_->text_dimension (t)); - b.scale (magnification_f_ * mag); + b.scale (magnification_f_); return b; } @@ -72,7 +72,7 @@ Font_metric::~Font_metric () Font_metric::Font_metric () { - name_ = SCM_EOL; + description_ = SCM_EOL; smobify_self (); } @@ -83,23 +83,17 @@ Font_metric::Font_metric (Font_metric const &) Box -Font_metric::get_char (int, Real )const +Font_metric::get_char (int )const { return Box (Interval(0,0),Interval (0,0)); } -SCM -Font_metric::description () const -{ - return gh_cons (name_, gh_int2scm (0)); -} - SCM Font_metric::mark_smob (SCM s) { Font_metric * m = (Font_metric*) SCM_CELL_WORD_1(s); - return m->name_; + return m->description_; } int @@ -107,7 +101,7 @@ Font_metric::print_smob (SCM s, SCM port, scm_print_state * ) { Font_metric *m = unsmob_metrics (s); scm_puts ("#name_, port); + scm_write (m->description_, port); scm_puts (">", port); return 1; } @@ -119,7 +113,10 @@ IMPLEMENT_DEFAULT_EQUAL_P(Font_metric); IMPLEMENT_TYPE_P (Font_metric, "font-metric?"); Molecule -Font_metric::find_by_name (String, Real mag ) const +Font_metric::find_by_name (String) const { assert (false); } + + + diff --git a/lily/grace-align-item.cc b/lily/grace-align-item.cc index 8d9cbf9ddc..8adf61ba58 100644 --- a/lily/grace-align-item.cc +++ b/lily/grace-align-item.cc @@ -9,7 +9,7 @@ #include "grace-align-item.hh" #include "align-interface.hh" -#include "font-metric.hh" + #include "paper-column.hh" #include "paper-def.hh" diff --git a/lily/include/afm.hh b/lily/include/afm.hh index 7220978207..79d7461f98 100644 --- a/lily/include/afm.hh +++ b/lily/include/afm.hh @@ -22,7 +22,7 @@ struct Adobe_font_metric : Font_metric { AFM_Font_info * font_inf_; - Box get_char (int, Real mag =1.0) const; + virtual Box get_char (int) const; AFM_CharMetricInfo const *find_char_metric (String name, bool warn=true) const; AFM_CharMetricInfo const *find_ascii_metric (int, bool warn=true) const; @@ -34,7 +34,7 @@ protected: Array ascii_to_metric_idx_; Dictionary name_to_metric_dict_; - virtual Molecule find_by_name (String, Real mag = 1.0) const; + virtual Molecule find_by_name (String) const; Adobe_font_metric (AFM_Font_info*); }; diff --git a/lily/include/all-font-metrics.hh b/lily/include/all-font-metrics.hh index ebfd2a2224..cd3eb17fa4 100644 --- a/lily/include/all-font-metrics.hh +++ b/lily/include/all-font-metrics.hh @@ -21,22 +21,18 @@ class All_font_metrics { Scheme_hash_table *afm_p_dict_; Scheme_hash_table *tfm_p_dict_; - Scheme_hash_table *scaled_p_dict_; - File_path search_path_; public: ~All_font_metrics (); Adobe_font_metric *find_afm (String name); Tex_font_metric *find_tfm (String); Font_metric *find_font (String name); - Scaled_font_metric* find_scaled (String , Real); + All_font_metrics (String search_path); SCM font_descriptions () const; }; -Font_metric * find_font (String name); - #endif /* ALL_FONTS_HH */ diff --git a/lily/include/font-interface.hh b/lily/include/font-interface.hh new file mode 100644 index 0000000000..0ce2620c87 --- /dev/null +++ b/lily/include/font-interface.hh @@ -0,0 +1,21 @@ +/* + font-interface.hh -- declare Font_interface + + source file of the GNU LilyPond music typesetter + + (c) 2000 Han-Wen Nienhuys + + */ + +#ifndef FONT_INTERFACE_HH +#define FONT_INTERFACE_HH + +#include "lily-proto.hh" +#include "font-metric.hh" + +struct Font_interface +{ + static Font_metric * get_default_font (Score_element*); +}; + +#endif /* FONT_INTERFACE_HH */ diff --git a/lily/include/font-metric.hh b/lily/include/font-metric.hh index e14ebb4e14..5844d58065 100644 --- a/lily/include/font-metric.hh +++ b/lily/include/font-metric.hh @@ -18,11 +18,11 @@ struct Font_metric { public: - SCM name_; - virtual SCM description () const; - virtual Box get_char (int ascii, Real mag) const; - virtual Box text_dimension (String, Real mag = 1.0) const; - virtual Molecule find_by_name (String, Real mag = 1.0) const; + SCM description_; + + virtual Box get_char (int ascii) const; + virtual Box text_dimension (String) const; + virtual Molecule find_by_name (String) const; DECLARE_SMOBS(Font_metric,); private: @@ -32,11 +32,13 @@ protected: }; +/* + Perhaps junk this, and move iface to paper_def? + */ struct Scaled_font_metric : public Font_metric { - virtual SCM description () const; - virtual Box text_dimension (String, Real) const; - virtual Molecule find_by_name (String, Real) const; + virtual Box text_dimension (String) const; + virtual Molecule find_by_name (String) const; static SCM make_scaled_font_metric (Font_metric*, Real); protected: Font_metric *orig_l_; diff --git a/lily/include/paper-def.hh b/lily/include/paper-def.hh index 11f4ab4224..7c569fd7ad 100644 --- a/lily/include/paper-def.hh +++ b/lily/include/paper-def.hh @@ -50,9 +50,10 @@ class Paper_def : public Music_output_def protected: VIRTUAL_COPY_CONS(Music_output_def); + Protected_scm scaled_fonts_; public: Protected_scm style_sheet_; - + SCM font_descriptions ()const; virtual ~Paper_def (); static int default_count_i_; /* @@ -73,6 +74,8 @@ public: Paper_stream* paper_stream_p () const; String base_output_str () const; + Font_metric * find_font (SCM name, Real mag); + // urg friend int yyparse (void*); }; diff --git a/lily/include/score-element.hh b/lily/include/score-element.hh index 61eb4d13ec..59e4a49e52 100644 --- a/lily/include/score-element.hh +++ b/lily/include/score-element.hh @@ -33,8 +33,6 @@ typedef void (Score_element::*Score_element_method_pointer) (void); */ class Score_element { public: - Font_metric * get_default_font ()const; - SCM immutable_property_alist_; SCM mutable_property_alist_; Score_element *original_l_; diff --git a/lily/include/stem.hh b/lily/include/stem.hh index dfc939ab71..200ce73592 100644 --- a/lily/include/stem.hh +++ b/lily/include/stem.hh @@ -10,6 +10,7 @@ #include "lily-proto.hh" #include "lily-guile.hh" #include "stem-info.hh" +#include "drul-array.hh" class Stem { diff --git a/lily/include/tfm.hh b/lily/include/tfm.hh index 12869dcb60..22e17c87cd 100644 --- a/lily/include/tfm.hh +++ b/lily/include/tfm.hh @@ -150,7 +150,7 @@ class Tex_font_metric : public Font_metric public: static SCM make_tfm (String filename); - Box get_char (int,Real = 1.0) const; + Box get_char (int) const; Tex_font_char_metric const *find_ascii (int ascii, bool warn=true) const; String str () const; diff --git a/lily/key-item.cc b/lily/key-item.cc index 5960c19696..2bc9024dfe 100644 --- a/lily/key-item.cc +++ b/lily/key-item.cc @@ -12,7 +12,7 @@ #include "key-item.hh" #include "molecule.hh" #include "paper-def.hh" -#include "font-metric.hh" +#include "font-interface.hh" #include "staff-symbol-referencer.hh" #include "lookup.hh" @@ -90,7 +90,7 @@ Key_item::brew_molecule (SCM smob) for (SCM s = newas; gh_pair_p (s); s = gh_cdr (s)) { int a = gh_scm2int (gh_cdar (s)); - Molecule m = me->get_default_font ()->find_by_name ("accidentals-" + to_str (a)); + Molecule m = Font_interface::get_default_font (me)->find_by_name ("accidentals-" + to_str (a)); m.translate_axis (calculate_position(me, gh_car (s)) * inter, Y_AXIS); mol.add_at_edge (X_AXIS, LEFT, m, 0); } @@ -122,7 +122,7 @@ Key_item::brew_molecule (SCM smob) if (found == SCM_EOL || gh_cdr (found) != gh_cdar (old)) { - Molecule m =me->get_default_font ()->find_by_name ("accidentals-0"); + Molecule m =Font_interface::get_default_font (me)->find_by_name ("accidentals-0"); m.translate_axis (calculate_position (me, gh_car (old)) * inter, Y_AXIS); mol.add_at_edge (X_AXIS, LEFT, m,0); diff --git a/lily/line-of-score.cc b/lily/line-of-score.cc index 91045bc1f9..df4ba207ea 100644 --- a/lily/line-of-score.cc +++ b/lily/line-of-score.cc @@ -310,7 +310,7 @@ Line_of_score::post_processing (bool last_line) /* font defs; */ - SCM font_names = ly_quote_scm (all_fonts_global_p->font_descriptions ()); + SCM font_names = ly_quote_scm (paper_l()->font_descriptions ()); output_scheme (gh_list (ly_symbol2scm ("define-fonts"), font_names, SCM_UNDEFINED)); diff --git a/lily/local-key-item.cc b/lily/local-key-item.cc index ba372c1ec9..69314d50fd 100644 --- a/lily/local-key-item.cc +++ b/lily/local-key-item.cc @@ -8,7 +8,7 @@ #include "local-key-item.hh" #include "molecule.hh" #include "staff-symbol-referencer.hh" -#include "font-metric.hh" +#include "font-interface.hh" #include "paper-def.hh" #include "musical-request.hh" #include "rhythmic-head.hh" @@ -60,8 +60,8 @@ Local_key_item::add_pitch (Score_element*me, Musical_pitch p, bool cautionary, b Molecule Local_key_item::parenthesize (Score_element*me, Molecule m) { - Molecule open = me->get_default_font ()->find_by_name (String ("accidentals-(")); - Molecule close = me->get_default_font ()->find_by_name (String ("accidentals-)")); + Molecule open = Font_interface::get_default_font (me)->find_by_name (String ("accidentals-(")); + Molecule close = Font_interface::get_default_font (me)->find_by_name (String ("accidentals-)")); m.add_at_edge(X_AXIS, LEFT, Molecule(open), 0); m.add_at_edge(X_AXIS, RIGHT, Molecule(close), 0); @@ -111,12 +111,12 @@ Local_key_item::brew_molecule (SCM smob) Real dy = (gh_number_p (c0) ? gh_scm2int (c0) : 0 + p.notename_i_) * note_distance; - Molecule acc (me->get_default_font ()->find_by_name (String ("accidentals-") + Molecule acc (Font_interface::get_default_font (me)->find_by_name (String ("accidentals-") + to_str (p.accidental_i_))); if (scm_memq (ly_symbol2scm ("natural"), gh_car (s)) != SCM_BOOL_F) { - Molecule prefix = me->get_default_font ()->find_by_name (String ("accidentals-0")); + Molecule prefix = Font_interface::get_default_font (me)->find_by_name (String ("accidentals-0")); acc.add_at_edge(X_AXIS, LEFT, Molecule(prefix), 0); } diff --git a/lily/molecule.cc b/lily/molecule.cc index c0d1b48748..240a8aec72 100644 --- a/lily/molecule.cc +++ b/lily/molecule.cc @@ -9,7 +9,7 @@ #include #include -#include "font-metric.hh" +#include "font-metric.hh" #include "dimensions.hh" #include "interval.hh" #include "string.hh" @@ -125,8 +125,11 @@ Molecule::empty_b () const SCM fontify_atom(Font_metric * met, SCM f) { - return gh_list (ly_symbol2scm ("fontify"), - ly_quote_scm (met->description ()), f, SCM_UNDEFINED); + if (f == SCM_EOL) + return f; + else + return gh_list (ly_symbol2scm ("fontify"), + ly_quote_scm (met->description_), f, SCM_UNDEFINED); } SCM diff --git a/lily/multi-measure-rest.cc b/lily/multi-measure-rest.cc index e8d4565e2e..ceb5657642 100644 --- a/lily/multi-measure-rest.cc +++ b/lily/multi-measure-rest.cc @@ -11,7 +11,7 @@ #include "debug.hh" #include "paper-def.hh" #include "paper-column.hh" // urg -#include "font-metric.hh" +#include "font-interface.hh" #include "rest.hh" #include "molecule.hh" #include "misc.hh" @@ -111,7 +111,7 @@ Multi_measure_rest::brew_molecule (SCM smob) Real pad = s.empty_b () ? 0.0 : gh_scm2double (me->get_elt_property ("padding")) * staff_space; - Molecule r (me->get_default_font ()->find_by_name ("rests-" + to_str (k))); + Molecule r (Font_interface::get_default_font (me)->find_by_name ("rests-" + to_str (k))); if (k == 0) r.translate_axis (staff_space, Y_AXIS); @@ -124,7 +124,7 @@ Multi_measure_rest::brew_molecule (SCM smob) else { String idx = ("rests-") + to_str (-4); - s = me->get_default_font ()->find_by_name (idx); + s = Font_interface::get_default_font (me)->find_by_name (idx); } mol.add_molecule (s); diff --git a/lily/note-head.cc b/lily/note-head.cc index 6930051b6a..3bfe6ad551 100644 --- a/lily/note-head.cc +++ b/lily/note-head.cc @@ -10,7 +10,7 @@ #include "dots.hh" #include "note-head.hh" #include "debug.hh" -#include "font-metric.hh" +#include "font-interface.hh" #include "molecule.hh" #include "musical-request.hh" @@ -23,7 +23,7 @@ Molecule Note_head::ledger_line (Interval xwid, Score_element *me) { Drul_array endings; - endings[LEFT] = me->get_default_font ()->find_by_name ("noteheads-ledgerending"); + endings[LEFT] = Font_interface::get_default_font (me)->find_by_name ("noteheads-ledgerending"); Molecule *e = &endings[LEFT]; endings[RIGHT] = *e; @@ -72,7 +72,7 @@ Note_head::brew_molecule (SCM smob) } // ugh: use gh_call () - Molecule out = me->get_default_font ()->find_by_name (String ("noteheads-") + + Molecule out = Font_interface::get_default_font (me)->find_by_name (String ("noteheads-") + ly_scm2string (scm_eval2 (gh_list (ly_symbol2scm("find-notehead-symbol"), me->get_elt_property ("duration-log"), ly_quote_scm(style), diff --git a/lily/paper-def.cc b/lily/paper-def.cc index ba703db23b..8332b128d1 100644 --- a/lily/paper-def.cc +++ b/lily/paper-def.cc @@ -8,6 +8,7 @@ #include +#include "all-font-metrics.hh" #include "string.hh" #include "misc.hh" #include "paper-def.hh" @@ -21,6 +22,7 @@ Paper_def::Paper_def () { style_sheet_ = SCM_EOL; + scaled_fonts_ = SCM_EOL; } Paper_def::~Paper_def () @@ -30,6 +32,7 @@ Paper_def::~Paper_def () Paper_def::Paper_def (Paper_def const&src) : Music_output_def (src) { + scaled_fonts_ = SCM_EOL; style_sheet_ = src.style_sheet_; } @@ -56,9 +59,15 @@ Paper_def::get_realvar (SCM s) const return 0.0; } + Real sc = 1.0; + SCM ssc; + if (scope_p_->try_retrieve (ly_symbol2scm ("outputscale"), &ssc)) + { + sc = gh_scm2double (ssc); + } if (gh_number_p (val)) { - return gh_scm2double (val); + return gh_scm2double (val) / sc; } else { @@ -127,4 +136,49 @@ Paper_def::base_output_str () const return str; } +/* + todo: use symbols and hashtable idx? +*/ +Font_metric * +Paper_def::find_font (SCM fn, Real m) +{ + SCM key = gh_cons (fn, gh_double2scm (m)); + SCM met = scm_assoc (key, scaled_fonts_); + + if (gh_pair_p (met)) + return unsmob_metrics (gh_cdr (met)); + SCM ssc; + if (scope_p_->try_retrieve (ly_symbol2scm ("outputscale"), &ssc)) + { + m /= gh_scm2double (ssc); + } + + Font_metric* f = all_fonts_global_p->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_unprotect_object (val); + + return dynamic_cast (unsmob_metrics (val)); +} + + +/* + Return alist to translate internally used fonts back to real-world + coordinates. */ +SCM +Paper_def::font_descriptions ()const +{ + + + SCM l = SCM_EOL; + for (SCM s = scaled_fonts_; gh_pair_p (s); s = gh_cdr(s)) + { + SCM desc = gh_caar (s); + SCM mdesc = unsmob_metrics (gh_cdar (s))->description_; + + l = gh_cons (gh_cons (mdesc, desc), l); + } + return l; +} diff --git a/lily/paper-outputter.cc b/lily/paper-outputter.cc index 8ac3a87036..ec2cbab2c5 100644 --- a/lily/paper-outputter.cc +++ b/lily/paper-outputter.cc @@ -200,16 +200,6 @@ Paper_outputter::output_version () -void -Paper_outputter::output_font_def (int i, String str) -{ - SCM scm = gh_list (ly_symbol2scm ("font-def"), - gh_int2scm (i), - ly_str02scm (str.ch_l ()), - SCM_UNDEFINED); - - output_scheme (scm); -} void Paper_outputter::output_Real_def (String k, Real v) diff --git a/lily/paper-score.cc b/lily/paper-score.cc index 5e75428750..2cc6685bf3 100644 --- a/lily/paper-score.cc +++ b/lily/paper-score.cc @@ -97,7 +97,7 @@ Paper_score::process () outputter_l_ = new Paper_outputter (paper_l_->paper_stream_p ()); ; outputter_l_->output_header (); - outputter_l_->output_version(); + outputter_l_->output_version (); if (header_global_p) outputter_l_->output_scope (header_global_p, "mudela"); @@ -111,16 +111,15 @@ Paper_score::process () outputter_l_->output_scope (paper_l_->scope_p_, "mudelapaper"); SCM scm; - if(experimental_features_global_b) + if (experimental_features_global_b) { SCM scm = gh_list (ly_symbol2scm ("experimental-on"), SCM_UNDEFINED); outputter_l_->output_scheme (scm); } scm = gh_list (ly_symbol2scm ("header-end"), SCM_UNDEFINED); outputter_l_->output_scheme (scm); - - line_l_->output_lines (); + line_l_->output_lines (); scm = gh_list (ly_symbol2scm ("end-output"), SCM_UNDEFINED); outputter_l_->output_scheme (scm); diff --git a/lily/piano-pedal-engraver.cc b/lily/piano-pedal-engraver.cc index 8990f345a3..fa21936f81 100644 --- a/lily/piano-pedal-engraver.cc +++ b/lily/piano-pedal-engraver.cc @@ -10,7 +10,6 @@ #include "musical-request.hh" #include "score-element.hh" #include "item.hh" -#include "font-metric.hh" #include "lily-guile.hh" #include "rhythmic-head.hh" #include "stem.hh" diff --git a/lily/rest.cc b/lily/rest.cc index b6df666dfe..da9caf8f4a 100644 --- a/lily/rest.cc +++ b/lily/rest.cc @@ -8,7 +8,7 @@ #include "molecule.hh" #include "paper-def.hh" -#include "font-metric.hh" +#include "font-interface.hh" #include "rest.hh" #include "dots.hh" #include "paper-score.hh" @@ -64,7 +64,7 @@ Rest::brew_molecule (SCM smob) String idx = ("rests-") + to_str (gh_scm2int (balltype)) + (ledger_b ? "o" : "") + style; - return me-> get_default_font ()->find_by_name (idx).create_scheme(); + return Font_interface::get_default_font (me)->find_by_name (idx).create_scheme(); } diff --git a/lily/rhythmic-head.cc b/lily/rhythmic-head.cc index 56861ca32f..8c230f6716 100644 --- a/lily/rhythmic-head.cc +++ b/lily/rhythmic-head.cc @@ -8,12 +8,7 @@ #include "rhythmic-head.hh" #include "debug.hh" -#include "molecule.hh" -#include "paper-def.hh" -#include "font-metric.hh" #include "rest.hh" -#include "dots.hh" -#include "paper-score.hh" #include "stem.hh" #include "staff-symbol-referencer.hh" #include "item.hh" diff --git a/lily/scaled-font-metric.cc b/lily/scaled-font-metric.cc index 3327b2d8b6..27f8c34fc3 100644 --- a/lily/scaled-font-metric.cc +++ b/lily/scaled-font-metric.cc @@ -6,6 +6,10 @@ Scaled_font_metric::Scaled_font_metric (Font_metric* m, Real magn) { magnification_f_ = magn; + SCM desc = m->description_; + + Real total_mag = magn * gh_scm2double (gh_cdr (desc)); + description_ = gh_cons (gh_car (desc), gh_double2scm (total_mag)); orig_l_ = m; } @@ -13,23 +17,16 @@ SCM Scaled_font_metric::make_scaled_font_metric (Font_metric*m, Real s) { Scaled_font_metric *sfm = new Scaled_font_metric (m,s); - sfm->name_ = m->name_; - return sfm->self_scm (); } -SCM -Scaled_font_metric::description () const -{ - SCM od = orig_l_->description (); - // todo: - // gh_set_cdr_x (od, gh_int2scm (magstep_i_)); - return od; -} - - Molecule -Scaled_font_metric::find_by_name (String s, Real mag) const +Scaled_font_metric::find_by_name (String s) const { - return orig_l_->find_by_name (s, magnification_f_ * mag); // ugh. + Molecule m = orig_l_->find_by_name (s); + Box b = m.extent_box (); + b.scale (magnification_f_); + Molecule q(b,fontify_atom ((Font_metric*) this, m.get_expr ())); + + return q ; } diff --git a/lily/score-element.cc b/lily/score-element.cc index 2df18842ec..453b166e04 100644 --- a/lily/score-element.cc +++ b/lily/score-element.cc @@ -10,14 +10,12 @@ #include #include -#include "all-font-metrics.hh" #include "input-smob.hh" #include "libc-extension.hh" #include "group-interface.hh" #include "misc.hh" #include "paper-score.hh" #include "paper-def.hh" -#include "font-metric.hh" #include "molecule.hh" #include "score-element.hh" #include "debug.hh" @@ -875,32 +873,3 @@ Score_element::set_interface (SCM k) ADD_SCM_INIT_FUNC(scoreelt, init_functions); IMPLEMENT_TYPE_P(Score_element, "ly-element?"); - -Font_metric * -Score_element::get_default_font () const -{ - Font_metric * fm = unsmob_metrics (get_elt_property ("font")); - if (fm) - return fm; - - Score_element *me = (Score_element*)this; - SCM ss = me->paper_l ()->style_sheet_; - - SCM proc = gh_cdr (scm_assoc (ly_symbol2scm ("properties-to-font"), - ss)); - - SCM fonts = gh_cdr (scm_assoc (ly_symbol2scm ("fonts"), ss)); - SCM defaults = gh_cdr (scm_assoc (ly_symbol2scm ("font-defaults"), - ss)); - - assert (gh_procedure_p (proc)); - SCM font_name = gh_call2 (proc, fonts, - gh_list (me->mutable_property_alist_, - me->immutable_property_alist_, - defaults, - SCM_UNDEFINED)); - - fm = find_font (ly_scm2string (font_name)); - me->set_elt_property ("font", fm->self_scm ()); - return fm; -} diff --git a/lily/script.cc b/lily/script.cc index 9f03377d55..c49e37cd0c 100644 --- a/lily/script.cc +++ b/lily/script.cc @@ -9,7 +9,7 @@ #include "debug.hh" #include "script.hh" -#include "font-metric.hh" +#include "font-interface.hh" #include "side-position-interface.hh" #include "paper-def.hh" #include "item.hh" @@ -25,12 +25,12 @@ Script::get_molecule(Score_element * me, Direction d) SCM key = gh_car (s); if (key == ly_symbol2scm ("feta")) { - return me->get_default_font ()->find_by_name ("scripts-" + + return Font_interface::get_default_font (me)->find_by_name ("scripts-" + ly_scm2string (index_cell (gh_cdr (s), d))); } else if (key == ly_symbol2scm ("accordion")) { - return Lookup::accordion (gh_cdr (s), me->paper_l()->get_var("staffspace"), me->get_default_font ()); + return Lookup::accordion (gh_cdr (s), me->paper_l()->get_var("staffspace"), Font_interface::get_default_font (me)); } else assert (false); diff --git a/lily/separating-group-spanner.cc b/lily/separating-group-spanner.cc index 6c9c628e99..789a024ce1 100644 --- a/lily/separating-group-spanner.cc +++ b/lily/separating-group-spanner.cc @@ -104,7 +104,7 @@ Separating_group_spanner::add_spacing_unit (Score_element* me ,Item*i) void -Separating_group_spanner::set_interface (Score_element*me) +Separating_group_spanner::set_interface (Score_element*) { } diff --git a/lily/slur.cc b/lily/slur.cc index 4c44b3c1b7..07c7fd6843 100644 --- a/lily/slur.cc +++ b/lily/slur.cc @@ -21,7 +21,6 @@ #include "group-interface.hh" #include "slur.hh" #include "lookup.hh" -#include "font-metric.hh" #include "paper-def.hh" #include "note-column.hh" #include "stem.hh" diff --git a/lily/span-bar.cc b/lily/span-bar.cc index 4ffd7dbfdc..1da4c197af 100644 --- a/lily/span-bar.cc +++ b/lily/span-bar.cc @@ -7,7 +7,7 @@ */ #include "span-bar.hh" -#include "font-metric.hh" +#include "font-interface.hh" #include "dimensions.hh" #include "paper-def.hh" #include "molecule.hh" diff --git a/lily/stem.cc b/lily/stem.cc index 2a85ca2487..eaf2cb5a6f 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -17,7 +17,7 @@ #include "debug.hh" #include "paper-def.hh" #include "rhythmic-head.hh" -#include "font-metric.hh" +#include "font-interface.hh" #include "molecule.hh" #include "paper-column.hh" #include "misc.hh" @@ -414,10 +414,10 @@ Stem::flag (Score_element*me) } char c = (get_direction (me) == UP) ? 'u' : 'd'; - Molecule m = me->get_default_font ()->find_by_name (String ("flags-") + to_str (c) + + Molecule m = Font_interface::get_default_font (me)->find_by_name (String ("flags-") + to_str (c) + to_str (flag_i (me))); if (!style.empty_b ()) - m.add_molecule(me->get_default_font ()->find_by_name (String ("flags-") + to_str (c) + style)); + m.add_molecule(Font_interface::get_default_font (me)->find_by_name (String ("flags-") + to_str (c) + style)); return m; } diff --git a/lily/sustain-pedal.cc b/lily/sustain-pedal.cc index 2e931fb9bb..29df9ec87b 100644 --- a/lily/sustain-pedal.cc +++ b/lily/sustain-pedal.cc @@ -8,7 +8,7 @@ */ #include "score-element.hh" #include "molecule.hh" -#include "font-metric.hh" +#include "font-interface.hh" #include "string.hh" // update comment --hwn @@ -56,7 +56,7 @@ Sustain_pedal::brew_molecule (SCM smob) } else idx += String (&text.byte_C ()[i], 1); - Molecule m = e->get_default_font ()->find_by_name (idx); + Molecule m = Font_interface::get_default_font (e)->find_by_name (idx); if (!m.empty_b ()) mol.add_at_edge (X_AXIS, RIGHT, m, 0); } diff --git a/lily/system-start-delimiter.cc b/lily/system-start-delimiter.cc index cc327778bf..5c345fb3e9 100644 --- a/lily/system-start-delimiter.cc +++ b/lily/system-start-delimiter.cc @@ -12,7 +12,7 @@ #include "system-start-delimiter.hh" #include "paper-def.hh" #include "molecule.hh" -#include "font-metric.hh" +#include "font-interface.hh" #include "all-font-metrics.hh" #include "score-element.hh" #include "lookup.hh" @@ -123,8 +123,7 @@ System_start_delimiter::brew_molecule (SCM smob) Molecule System_start_delimiter::staff_brace (Score_element*me,Real y) { - Real staffht = me->paper_l ()->get_var ("staffheight"); - int staff_size = int (rint (staffht )); + int staff_size = 20; // URG. // URG Real step = 1.0; @@ -133,17 +132,10 @@ System_start_delimiter::staff_brace (Score_element*me,Real y) int idx = int (((maxht - step) ? 0; - SCM l = scm_assoc (ly_str02scm ("brace"), - scm_eval2 (ly_symbol2scm ("cmr-alist"), SCM_EOL)); + Font_metric *fm = Font_interface::get_default_font (me); - String nm = "feta-braces"; - if (l != SCM_BOOL_F) - nm = ly_scm2string (gh_cdr (l)); - nm += to_str (staff_size); - SCM e =gh_list (ly_symbol2scm ("char"), gh_int2scm (idx), SCM_UNDEFINED); - SCM at = (e); - - at = fontify_atom (find_font (nm), at); + SCM at =gh_list (ly_symbol2scm ("char"), gh_int2scm (idx), SCM_UNDEFINED); + at = fontify_atom (fm, at); Box b (Interval (0,0), Interval (-y/2, y/2)); diff --git a/lily/text-item.cc b/lily/text-item.cc index e1085702f9..c26d5509c6 100644 --- a/lily/text-item.cc +++ b/lily/text-item.cc @@ -11,7 +11,7 @@ #include "debug.hh" #include "text-item.hh" #include "paper-def.hh" -#include "font-metric.hh" +#include "font-interface.hh" #include "staff-symbol-referencer.hh" #include "staff-symbol-referencer.hh" #include "main.hh" @@ -105,19 +105,21 @@ Text_item::string2molecule (Score_element *me, SCM text, SCM alist_chain) SCM proc = gh_cdr (scm_assoc (ly_symbol2scm ("properties-to-font"), sheet)); SCM font_name = gh_call2 (proc, fonts, alist_chain); - SCM lookup = ly_assoc_chain (ly_symbol2scm ("lookup"), alist_chain); +#if 0 + SCM lookup = scm_assoc (ly_symbol2scm ("lookup"), properties); Molecule mol; if (gh_pair_p (lookup) && ly_symbol2string (gh_cdr (lookup)) == "name") mol = lookup_character (me, font_name, text); else - mol = lookup_text (me, font_name, text); +#endif + Molecule mol = lookup_text (me, font_name, text); return mol; } Molecule -Text_item::lookup_character (Score_element *me, SCM font_name, SCM char_name) +Text_item::lookup_character (Score_element *, SCM font_name, SCM char_name) { Adobe_font_metric *afm = all_fonts_global_p->find_afm (ly_scm2string (font_name)); @@ -140,11 +142,14 @@ Text_item::lookup_text (Score_element *me, SCM font_name, SCM text) Font_metric* metric = 0; if (gh_number_p (magnification)) { +#if 0 Real realmag = pow (1.2, gh_scm2int (magnification)); metric = all_fonts_global_p->find_scaled (ly_scm2string (font_name), realmag); +#endif + assert (false); } else - metric = all_fonts_global_p->find_font (ly_scm2string (font_name)); + metric = me->paper_l ()->find_font (font_name, 1.0); SCM list = gh_list (ly_symbol2scm ("text"), text, SCM_UNDEFINED); list = fontify_atom (metric, list); @@ -156,26 +161,32 @@ Molecule Text_item::markup_sentence2molecule (Score_element *me, SCM markup_sentence, SCM alist_chain) { + /* + FIXME + */ + return Molecule (); + SCM sheet = me->paper_l ()->style_sheet_; - SCM f = gh_cdr (scm_assoc (ly_symbol2scm ("markup-to-properties"), sheet)); + SCM f = gh_cdr (scm_assoc (ly_symbol2scm ("markup-abbrev-to-properties-alist"), sheet)); + SCM markup = gh_car (markup_sentence); SCM sentence = gh_cdr (markup_sentence); - SCM p = gh_cons (gh_call2 (f, sheet, markup), alist_chain); + SCM p = gh_cons (gh_call1 (f, markup), alist_chain); Axis align = X_AXIS; - SCM a = ly_assoc_chain (ly_symbol2scm ("align"), p); + SCM a = scm_assoc (ly_symbol2scm ("align"), p); if (gh_pair_p (a) && gh_number_p (gh_cdr (a))) align = (Axis)gh_scm2int (gh_cdr (a)); Real staff_space = Staff_symbol_referencer::staff_space (me); Real kern = 0; - SCM k = ly_assoc_chain (ly_symbol2scm ("kern"), p); + SCM k = scm_assoc (ly_symbol2scm ("kern"), p); if (gh_pair_p (k) && gh_number_p (gh_cdr (k))) kern = gh_scm2double (gh_cdr (k)) * staff_space; Real raise = 0; - SCM r = ly_assoc_chain (ly_symbol2scm ("raise"), p); + SCM r = scm_assoc (ly_symbol2scm ("raise"), p); if (gh_pair_p (r) && gh_number_p (gh_cdr (r))) raise = gh_scm2double (gh_cdr (r)) * staff_space; diff --git a/lily/text-spanner.cc b/lily/text-spanner.cc index 42267504b4..c74400fe79 100644 --- a/lily/text-spanner.cc +++ b/lily/text-spanner.cc @@ -10,7 +10,7 @@ #include "text-item.hh" #include "text-spanner.hh" #include "spanner.hh" -#include "font-metric.hh" +#include "font-interface.hh" #include "dimensions.hh" #include "paper-def.hh" #include "debug.hh" diff --git a/lily/tfm.cc b/lily/tfm.cc index cdfb8535dd..2ce125cdbe 100644 --- a/lily/tfm.cc +++ b/lily/tfm.cc @@ -74,10 +74,9 @@ Tex_font_metric::find_ascii (int ascii, bool warn) const } Box -Tex_font_metric::get_char (int a, Real mag) const +Tex_font_metric::get_char (int a) const { Box b = find_ascii (a)->dimensions () ; - b.scale (mag); return b; } @@ -98,7 +97,7 @@ Tex_font_metric::str () const SCM Tex_font_metric::make_tfm (String fn) { - Tex_font_metric * tfm_p = new Tex_font_metric; + Tex_font_metric * tfm_p = new Tex_font_metric; Tex_font_metric_reader reader (fn); tfm_p->info_ = reader.info_; diff --git a/lily/time-signature.cc b/lily/time-signature.cc index 035071ba45..4e3f7e2057 100644 --- a/lily/time-signature.cc +++ b/lily/time-signature.cc @@ -12,7 +12,7 @@ #include "text-item.hh" #include "time-signature.hh" #include "paper-def.hh" -#include "font-metric.hh" +#include "font-interface.hh" MAKE_SCHEME_CALLBACK(Time_signature,brew_molecule,1); @@ -53,12 +53,12 @@ Time_signature::special_time_signature (Score_element*me, String s, int n, int d // First guess: s contains only the signature style String symbolname = "timesig-" + s + to_str (n) + "/" + to_str (d); - Molecule m = me->get_default_font ()->find_by_name (symbolname); + Molecule m = Font_interface::get_default_font (me)->find_by_name (symbolname); if (!m.empty_b()) return m; // Second guess: s contains the full signature name - m = me->get_default_font ()->find_by_name ("timesig-"+s); + m = Font_interface::get_default_font (me)->find_by_name ("timesig-"+s); if (!m.empty_b ()) return m; @@ -71,6 +71,7 @@ Molecule Time_signature::time_signature (Score_element*me,int num, int den) { SCM chain = gh_list (me->mutable_property_alist_, me->immutable_property_alist_, SCM_UNDEFINED); + Molecule n = Text_item::text2molecule (me, ly_str02scm (to_str (num).ch_C ()), chain); diff --git a/lily/tuplet-spanner.cc b/lily/tuplet-spanner.cc index cf4bba50f5..739a179bc2 100644 --- a/lily/tuplet-spanner.cc +++ b/lily/tuplet-spanner.cc @@ -10,7 +10,7 @@ #include "beam.hh" #include "box.hh" #include "debug.hh" -#include "font-metric.hh" +#include "font-interface.hh" #include "molecule.hh" #include "paper-column.hh" #include "paper-def.hh" diff --git a/lily/volta-spanner.cc b/lily/volta-spanner.cc index bb6b6236ad..7dde58677c 100644 --- a/lily/volta-spanner.cc +++ b/lily/volta-spanner.cc @@ -9,7 +9,7 @@ #include "box.hh" #include "debug.hh" -#include "font-metric.hh" +#include "font-interface.hh" #include "molecule.hh" #include "paper-column.hh" #include "paper-def.hh" @@ -23,11 +23,8 @@ void Volta_spanner::set_interface (Score_element*me) { - Side_position::set_axis (me, Y_AXIS); - Directional_element_interface::set (me, UP); } - /* this is too complicated. Yet another version of side-positioning, badly implemented. @@ -36,7 +33,6 @@ Volta_spanner::set_interface (Score_element*me) * Should look for system_start_delim to find left edge of staff. - */ MAKE_SCHEME_CALLBACK(Volta_spanner,brew_molecule,1); diff --git a/ly/params.ly b/ly/params.ly index bda61747a1..553e81041e 100644 --- a/ly/params.ly +++ b/ly/params.ly @@ -9,6 +9,7 @@ paperfile = \papersize + ".ly"; staffspace = \staffheight / 4.0; stafflinethickness = \staffspace / 10.0; +outputscale = \staffheight / 4.0; \translator { \NoteNamesContext } \translator { \ScoreContext } diff --git a/make/out/lilypond.lsm b/make/out/lilypond.lsm index 2993adac9a..d8fdac84c6 100644 --- a/make/out/lilypond.lsm +++ b/make/out/lilypond.lsm @@ -1,15 +1,15 @@ Begin3 Title: LilyPond -Version: 1.3.99 -Entered-date: 25OCT00 +Version: 1.3.100 +Entered-date: 30OCT00 Description: Keywords: music notation typesetting midi fonts engraving Author: hanwen@cs.uu.nl (Han-Wen Nienhuys) janneke@gnu.org (Jan Nieuwenhuizen) Maintained-by: hanwen@stack.nl (Han-Wen Nienhuys) Primary-site: sunsite.unc.edu /pub/Linux/apps/sound/convert - 1000k lilypond-1.3.99.tar.gz + 1000k lilypond-1.3.100.tar.gz Original-site: ftp.cs.uu.nl /pub/GNU/LilyPond/development/ - 1000k lilypond-1.3.99.tar.gz + 1000k lilypond-1.3.100.tar.gz Copying-policy: GPL End diff --git a/make/out/lilypond.spec b/make/out/lilypond.spec index 920db01e65..fed023f61c 100644 --- a/make/out/lilypond.spec +++ b/make/out/lilypond.spec @@ -1,9 +1,9 @@ Name: lilypond -Version: 1.3.99 +Version: 1.3.100 Release: 1 License: GPL Group: Applications/Publishing -Source0: ftp.cs.uu.nl:/pub/GNU/LilyPond/development/lilypond-1.3.99.tar.gz +Source0: ftp.cs.uu.nl:/pub/GNU/LilyPond/development/lilypond-1.3.100.tar.gz Summary: A program for printing sheet music. URL: http://www.cs.uu.nl/~hanwen/lilypond # Icon: lilypond-icon.gif diff --git a/mf/feta-din12.mf b/mf/feta-din12.mf deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/mf/feta-din14.mf b/mf/feta-din14.mf deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/mf/feta-din3.mf b/mf/feta-din3.mf deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/mf/feta-din6.mf b/mf/feta-din6.mf deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/mf/feta-nummer12.mf b/mf/feta-nummer12.mf deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/mf/feta-nummer14.mf b/mf/feta-nummer14.mf deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/mf/feta-nummer3.mf b/mf/feta-nummer3.mf deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/mf/feta-nummer6.mf b/mf/feta-nummer6.mf deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/scm/ascii-script.scm b/scm/ascii-script.scm new file mode 100644 index 0000000000..ea9bc54a30 --- /dev/null +++ b/scm/ascii-script.scm @@ -0,0 +1,190 @@ + +;;;; AsciiScript as +(define (as-scm action-name) + + (define (beam width slope thick) + (string-append + (func "set-line-char" "#") + (func "rline-to" width (* width slope)) + )) + + ; simple flat slurs + (define (bezier-sandwich l thick) + (let ( + (c0 (cadddr l)) + (c1 (cadr l)) + (c3 (caddr l))) + (let* ((x (car c0)) + (dx (- (car c3) x)) + (dy (- (cdr c3) (cdr c0))) + (rc (/ dy dx)) + (c1-dx (- (car c1) x)) + (c1-line-y (+ (cdr c0) (* c1-dx rc))) + (dir (if (< c1-line-y (cdr c1)) 1 -1)) + (y (+ -1 (* dir (max (* dir (cdr c0)) (* dir (cdr c3))))))) + (string-append + (func "rmove-to" x y) + (func "put" (if (< 0 dir) "/" "\\\\")) + (func "rmove-to" 1 (if (< 0 dir) 1 0)) + (func "set-line-char" "_") + (func "h-line" (- dx 1)) + (func "rmove-to" (- dx 1) (if (< 0 dir) -1 0)) + (func "put" (if (< 0 dir) "\\\\" "/")))))) + + (define (bracket arch_angle arch_width arch_height width height arch_thick thick) + (string-append + (func "rmove-to" (+ width 1) (- (/ height -2) 1)) + (func "put" "\\\\") + (func "set-line-char" "|") + (func "rmove-to" 0 1) + (func "v-line" (+ height 1)) + (func "rmove-to" 0 (+ height 1)) + (func "put" "/") + )) + + (define (char i) + (func "char" i)) + + (define (define-origin a b c ) "") + + (define (end-output) + (func "end-output")) + + (define (experimental-on) + "") + + (define (filledbox breapth width depth height) + (let ((dx (+ width breapth)) + (dy (+ depth height))) + (string-append + (func "rmove-to" (* -1 breapth) (* -1 depth)) + (if (< dx dy) + (string-append + (func "set-line-char" + (if (<= dx 1) "|" "#")) + (func "v-line" dy)) + (string-append + (func "set-line-char" + (if (<= dy 1) "-" "=")) + (func "h-line" dx)))))) + + (define (font-load-command name-mag command) + (func "load-font" (car name-mag) (magstep (cdr name-mag)))) + + (define (header creator generate) + (func "header" creator generate)) + + (define (header-end) + (func "header-end")) + + ;; urg: this is good for half of as2text's execution time + (define (xlily-def key val) + (string-append "(define " key " " (arg->string val) ")\n")) + + (define (lily-def key val) + (if + (or (equal? key "mudelapaperlinewidth") + (equal? key "mudelapaperstaffheight")) + (string-append "(define " key " " (arg->string val) ")\n") + "")) + + (define (no-origin) "") + + (define (placebox x y s) + (let ((ey (inexact->exact y))) + (string-append "(move-to " (number->string (inexact->exact x)) " " + (if (= 0.5 (- (abs y) (abs ey))) + (number->string y) + (number->string ey)) + ")\n" s))) + + (define (select-font name-mag-pair) + (let* ((c (assoc name-mag-pair font-name-alist))) + (if (eq? c #f) + (begin + (ly-warn + (string-append + "Programming error: No such font known " + (car name-mag-pair)))) + "") ; issue no command + (func "select-font" (car font-name-symbol))))) + + (define (start-line height) + (func "start-line" height)) + + (define (stop-line) + (func "stop-line")) + + (define (text s) + (func "text" s)) + + (define (tuplet ht gap dx dy thick dir) "") + + (define (volta h w thick vert-start vert-end) + ;; urg + (string-append + (func "set-line-char" "|") + (func "rmove-to" 0 -4) + ;; definition strange-way around + (if (= 0 vert-start) + (func "v-line" h) + "") + (func "rmove-to" 1 h) + (func "set-line-char" "_") + (func "h-line" (- w 1)) + (func "set-line-char" "|") + (if (= 0 vert-end) + (string-append + (func "rmove-to" (- w 1) (* -1 h)) + (func "v-line" (* -1 h))) + ""))) + + (cond ((eq? action-name 'all-definitions) + `(begin + (define beam ,beam) + (define bracket ,bracket) + (define char ,char) + (define define-origin ,define-origin) + ;;(define crescendo ,crescendo) + (define bezier-sandwich ,bezier-sandwich) + ;;(define dashed-slur ,dashed-slur) + ;;(define decrescendo ,decrescendo) + (define end-output ,end-output) + (define experimental-on ,experimental-on) + (define filledbox ,filledbox) + ;;(define font-def ,font-def) + (define font-load-command ,font-load-command) + ;;(define font-switch ,font-switch) + (define header ,header) + (define header-end ,header-end) + (define lily-def ,lily-def) + ;;(define invoke-char ,invoke-char) + ;;(define invoke-dim1 ,invoke-dim1) + (define no-origin ,no-origin) + (define placebox ,placebox) + (define select-font ,select-font) + (define start-line ,start-line) + ;;(define stem ,stem) + (define stop-line ,stop-line) + (define stop-last-line ,stop-line) + (define text ,text) + (define tuplet ,tuplet) + (define volta ,volta) + )) + ((eq? action-name 'tuplet) tuplet) + ;;((eq? action-name 'beam) beam) + ;;((eq? action-name 'bezier-sandwich) bezier-sandwich) + ;;((eq? action-name 'bracket) bracket) + ((eq? action-name 'char) char) + ;;((eq? action-name 'crescendo) crescendo) + ;;((eq? action-name 'dashed-slur) dashed-slur) + ;;((eq? action-name 'decrescendo) decrescendo) + ;;((eq? action-name 'experimental-on) experimental-on) + ((eq? action-name 'filledbox) filledbox) + ((eq? action-name 'select-font) select-font) + ;;((eq? action-name 'volta) volta) + (else (error "unknown tag -- MUSA-SCM " action-name)) + ) + ) + + diff --git a/scm/element-descriptions.scm b/scm/element-descriptions.scm index e6ab913418..8678154715 100644 --- a/scm/element-descriptions.scm +++ b/scm/element-descriptions.scm @@ -38,7 +38,9 @@ (visibility-lambda . ,begin-of-line-visible) (padding . 1.0) (direction . 1) + (markup-to-properties . ,markup-to-properties) (font-family . roman) + (font-relative-size . -1) (meta . ,(element-description "BarNumber" text-interface font-interface break-aligned-interface)) @@ -89,8 +91,8 @@ (molecule-callback . ,Chord_name::brew_molecule) (after-line-breaking-callback . ,Chord_name::after_line_breaking) (chord-name-function . ,default-chord-name-function) - (font-family . roman) - (meta . ,(element-description "ChordNames" font-interface text-interface chord-name-interface)) + (markup-to-properties . ,markup-to-properties) + (meta . ,(element-description "ChordNames" font-interface chord-name-interface)) )) (NoteCollision . ( @@ -131,8 +133,8 @@ (Y-offset-callbacks . (,Side_position::aligned_on_self)) (molecule-callback . ,Text_item::brew_molecule) (script-priority . 100) - (font-series . bold) - (font-family . dynamic) + (font-style . dynamic) + (markup-to-properties . ,markup-to-properties) (self-alignment-Y . 0) (meta . ,(element-description "DynamicText" font-interface text-interface )) )) @@ -156,8 +158,9 @@ (X-offset-callbacks . (,Side_position::centered_on_parent ,Side_position::aligned_on_self)) (padding . 3.0) (self-alignment-X . 0) - (font-family . number) - (font-relative-size . -3) + + (font-style . finger) + (markup-to-properties . ,markup-to-properties) (meta . ,(element-description "Fingering" finger-interface font-interface text-script-interface text-interface side-position-interface)) )) @@ -193,6 +196,7 @@ (molecule-callback . ,Text_item::brew_molecule) (break-align-symbol . Instrument_name) (visibility-lambda . ,begin-of-line-visible) + (markup-to-properties . ,markup-to-properties) (font-family . roman) (meta . ,(element-description "InstrumentName" font-interface text-interface break-aligned-interface)) )) @@ -233,20 +237,23 @@ (self-alignment-X . 0) (non-rhythmic . #t) (word-space . 0.6) + + (markup-to-properties . ,markup-to-properties) (font-family . roman) (font-shape . upright) (font-relative-size . 0) + (meta . ,(element-description "LyricText" lyric-syllable-interface text-interface font-interface )) )) (RehearsalMark . ( - (molecule-callback . ,Text_item::brew_molecule) - (breakable . #t) - (font-family . number) - (font-relative-size . 1) - (visibility-lambda . ,end-of-line-invisible) - (padding . 4.0) - (meta . ,(element-description "RehearsalMark" mark-interface side-position-interface)) + (molecule-callback . ,Text_item::brew_molecule) + (breakable . #t) + (markup-to-properties . ,markup-to-properties) + (font-style . mark) + (visibility-lambda . ,end-of-line-invisible) + (padding . 4.0) + (meta . ,(element-description "RehearsalMark" mark-interface side-position-interface)) )) (MultiMeasureRest . ( @@ -256,8 +263,8 @@ (expand-limit . 10) (padding . 2.0) ; staffspace (minimum-width . 12.5) ; staffspace - (font-family . number) - (font-relative-size . 1) + (markup-to-properties . ,markup-to-properties) + (font-style . mmrest) (meta . ,(element-description "MultiMeasureRest" multi-measure-rest-interface font-interface )) )) @@ -278,6 +285,7 @@ (NoteName . ( (style . default) (molecule-callback . ,Text_item::brew_molecule) + (markup-to-properties . ,markup-to-properties) (meta . ,(element-description "NoteName" note-name-interface font-interface general-element-interface)) @@ -291,6 +299,8 @@ (Y-offset-callbacks . (,Side_position::aligned_side)) (molecule-callback . ,Text_item::brew_molecule) (font-shape . italic) + (markup-to-properties . ,markup-to-properties) + (meta . ,(element-description "OctavateEight" text-interface font-interface )) )) @@ -370,8 +380,9 @@ (molecule-callback . ,Text_item::brew_molecule) (break-align-symbol . Clef_item) (visibility-lambda . ,begin-of-line-visible) + (markup-to-properties . ,markup-to-properties) (font-family . roman) - (meta . ,(element-description "StanzaNumber" break-aligned-interface text-interface font-interface)) +(meta . ,(element-description "StanzaNumber" break-aligned-interface text-interface font-interface)) )) (StaffSymbol . ( @@ -388,6 +399,8 @@ ,Side_position::centered_on_parent)) (no-spacing-rods . #t) (font-shape . italic) + (markup-to-properties . ,markup-to-properties) + (self-alignment-X . 0) (meta . ,(element-description "SostenutoPedal" text-interface font-interface)) )) @@ -433,8 +446,8 @@ (self-alignment-X . 0) (X-offset-callbacks . (,Side_position::aligned_on_self)) (Y-offset-callbacks . - (,Side_position::aligned_side - ,Side_position::centered_on_parent)) + (,Side_position::aligned_side + ,Side_position::centered_on_parent)) (meta . ,(element-description "SustainPedal" sustain-pedal-interface side-position-interface font-interface)) )) @@ -451,22 +464,26 @@ (arch-width . 1.5) (bracket-thick . 0.25) (bracket-width . 2.0) + (font-family . braces) + (font-point-size . 20) (Y-extent-callback . #f) - (meta . ,(element-description "SystemStartDelimiter" system-start-delimiter )) + (meta . ,(element-description "SystemStartDelimiter" system-start-delimiter font-interface)) )) (TextScript . ( (molecule-callback . ,Text_item::brew_molecule) (no-spacing-rods . #t) (padding . 0.5) - (font-family . roman) - (font-shape . italic) - (font-relative-size . 0) + (markup-to-properties . ,markup-to-properties) + (font-family . roman) + (font-shape . italic) + (font-relative-size . 0) (meta . ,(element-description "TextScript" text-script-interface text-interface side-position-interface font-interface )) )) (TextSpanner . ( (molecule-callback . ,Text_spanner::brew_molecule) (font-shape . italic) + (markup-to-properties . ,markup-to-properties) (type . "line") (direction . 1) (meta . ,(element-description "TextSpanner" text-spanner-interface font-interface)) @@ -488,13 +505,13 @@ )) (TimeSignature . ( - (molecule-callback . ,Time_signature::brew_molecule) + (molecule-callback . ,Time_signature::brew_molecule) (break-align-symbol . Time_signature) (visibility-lambda . ,all-visible) (breakable . #t) - (font-family . number) - (font-relative-size . 0) - (meta . ,(element-description "TimeSignature" time-signature-interface font-interface)) + (markup-to-properties . ,markup-to-properties) + (font-style . timesig) + (meta . ,(element-description "TimeSignature" time-signature-interface font-interface)) )) (TupletBracket . ( @@ -503,8 +520,8 @@ (thick . 1.0) (after-line-breaking-callback . ,Tuplet_spanner::after_line_breaking) (molecule-callback . ,Tuplet_spanner::brew_molecule) - (font-shape . italic) - (font-relative-size . -1) + (markup-to-properties . ,markup-to-properties) + (font-style . tuplet) (meta . ,(element-description "TupletBracket" text-interface tuplet-bracket-interface font-interface)) )) @@ -512,6 +529,7 @@ (UnaChordaPedal . ( (molecule-callback . ,Text_item::brew_molecule) (font-shape . italic) + (markup-to-properties . ,markup-to-properties) (no-spacing-rods . #t) (self-alignment-X . 0) (X-offset-callbacks . (,Side_position::aligned_on_self)) @@ -523,10 +541,12 @@ (VoltaBracket . ( (molecule-callback . ,Volta_spanner::brew_molecule) + (direction . 1) - (padding . 5) - (font-family . number) - (font-relative-size . -2) + (padding . 1) + (markup-to-properties . ,markup-to-properties) + (font-style . volta) + (Y-offset-callbacks . (,Side_position::aligned_side)) (thickness . 1.6) ; stafflinethickness (height . 2.0) ; staffspace; (minimum-space . 25) diff --git a/scm/font.scm b/scm/font.scm index d41741cb61..deebd5e4c2 100644 --- a/scm/font.scm +++ b/scm/font.scm @@ -19,7 +19,8 @@ ((eq? name 'font-shape) 2) ((eq? name 'font-family) 3) ((eq? name 'font-name) 4) - ((eq? name 'font-point-size-size) 5) + ((eq? name 'font-point-size) 5) + (else (ly-warning "unknown font field name")) ) )) @@ -163,13 +164,15 @@ (dynamic . ((font-series . bold) (font-family . dynamic) (font-relative-size . 0))) )) (properties-to-font . ,properties-to-font-name) - (markup-to-properties . ,markup-to-properties) - (abbreviation-alist - . - ((rows . ((align . 0))) + + ;; FIXME: this is a not-so-cool idea to use ALIGN + ;; RAISE, LOOKUP, since they are not proper elt-properties, + ;; and might interfere with them. + (markup-abbrev-to-properties-alist + . ((rows . ((align . 0))) (lines . ((align . 1))) (roman . ((font-family . roman))) - (music . ((font-family . music) (font-shape . upright) (font-series . medium))) + (music . ((font-family . music))) (finger . ((font-style . finger))) (bold . ((font-series . bold))) (italic . ((font-shape . italic))) @@ -183,6 +186,17 @@ ) ) + + +(define (font-regexp-to-font-name paper regexp) + (let ((style-sheet (cdr (assoc paper style-sheet-alist)))) + (let loop ((fonts style-sheet)) + (if (string-match regexp (caar fonts)) + (cdar fonts) + (if (pair? (cdr fonts)) + (loop (cdr fonts)) + '()))))) + ;; reduce the font list by successively applying a font-qualifier. (define (qualifiers-to-fontnames qualifiers font-descr-alist) (if (null? qualifiers) @@ -278,18 +292,19 @@ selected) ; return the topmost. )) -(define (markup-to-properties sheet markup) +(define markup-abbrev-to-properties-alist + (append + (map (lambda (x) (cons (car x) (cons 'font-style (car x)))) + style-to-font-alist))) + +(define (markup-to-properties markup) ;;(display "markup: `") - ;;(write markup) + ;;(display markup) ;;(display "'\n") (if (pair? markup) (list markup) - (let ((entry (assoc markup - ;; assoc-chain? - (append (cdr (assoc 'abbreviation-alist sheet)) - (cdr (assoc 'style-alist sheet)))))) - (if entry - (cdr entry) + (let ((entry (assoc markup markup-abbrev-to-properties-alist))) + (if entry (cdr entry) (list (cons markup #t)))))) ; fixme, how's this supposed to work? diff --git a/scm/lily.scm b/scm/lily.scm index 4e34b96bd5..a2834f250e 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -4,13 +4,11 @@ ; ; (c) 1998 Jan Nieuwenhuizen - ; ; This file contains various routines in Scheme that are easier to ; do here than in C++. At present it is an unorganised mess. Sorry. ; - ; We should repartition the entire scm side of lily in a ; more sane way, using namesspaces/modules? @@ -23,6 +21,29 @@ (define (number-pair? x) (and (pair? x) (number? (car x)) (number? (cdr x)))) +(define (object-type obj) + (cond + ((dir? obj) "direction") + ((number-pair? obj) "pair of numbers") + ((ly-input-location? obj) "input location") + ((ly-element? obj) "graphic element") + ((pair? obj) "pair") + ((integer? obj) "integer") + ((list? obj) "list") + ((symbol? obj) "symbol") + ((string? obj) "string") + ((boolean? obj) "boolean") + ((moment? obj) "moment") + ((number? obj) "number") + ((char? obj) "char") + ((input-port? obj) "input port") + ((output-port? obj) "output port") + ((vector? obj) "vector") + ((procedure? obj) "procedure") + (else "unknown type") + )) + + (define (type-name predicate) (cond ((eq? predicate dir?) "direction") @@ -122,35 +143,12 @@ (if (< duration 0) "mensural" ""))) ((default) (number->string duration)) (else - (string-append (number->string duration) (symbol->string style))))) + (string-append (number->string duration) (symbol->string style)))) + ) ;;;;;;;; TeX -;; this is silly, can't we use something like -;; roman-0, roman-1 roman+1 ? -(define cmr-alist - '(("bold" . "cmbx") - ("brace" . "feta-braces") - ("default" . "cmr10") - ("dynamic" . "feta-din") - ("feta" . "feta") - ("feta-1" . "feta") - ("feta-2" . "feta") - ("typewriter" . "cmtt") - ("italic" . "cmti") - ("msam" . "msam") - ("roman" . "cmr") - ("script" . "cmr") - ("large" . "cmbx") - ("Large" . "cmbx") - ("mark" . "feta-nummer") - ("finger" . "feta-nummer") - ("timesig" . "feta-nummer") - ("number" . "feta-nummer") - ("volta" . "feta-nummer")) -) - (define (string-encode-integer i) (cond ((= i 0) "o") @@ -158,46 +156,43 @@ (else (string-append (make-string 1 (integer->char (+ 65 (modulo i 26)))) (string-encode-integer (quotient i 26)) - ) + )) ) ) - ) -(define (magstep i) - (cdr (assoc i '((-4 . 482) - (-3 . 579) - (-2 . 694) - (-1 . 833) - (0 . 1000) - (1 . 1200) - (2 . 1440) - (3 . 1728) - (4 . 2074)) - ) - ) - ) - (define default-script-alist '()) (define font-name-alist '()) -(define (font-command name-mag) - (cons name-mag - (string-append "magfont" - (string-encode-integer (hashq (car name-mag) 1000000)) +(define (tex-encoded-fontswitch name-mag) + (let* ( + (iname-mag (car name-mag)) + (ename-mag (cdr name-mag)) + ) + (cons iname-mag + (cons ename-mag + (string-append "magfont" + (string-encode-integer + (hashq (car ename-mag) 1000000)) "m" - (string-encode-integer (cdr name-mag))) + (string-encode-integer + (inexact->exact (* 1000 (cdr ename-mag)))) - ) - ) -(define (define-fonts names) - (set! font-name-alist (map font-command names)) + ) + ) + ))) + +(define (define-fonts internal-external-name-mag-pairs) + (set! font-name-alist (map tex-encoded-fontswitch + internal-external-name-mag-pairs)) (apply string-append (map (lambda (x) - (font-load-command (car x) (cdr x))) font-name-alist) - )) + (font-load-command (car x) (cdr x))) + (map cdr font-name-alist) -(define (fontify name exp) - (string-append (select-font name) + ))) + +(define (fontify name-mag-pair exp) + (string-append (select-font name-mag-pair) exp) ) @@ -218,18 +213,25 @@ "%\n\\unknown%\n") - (define (select-font font-name-symbol) + (define (select-font name-mag-pair) (let* ( - (c (assoc font-name-symbol font-name-alist)) + (c (assoc name-mag-pair font-name-alist)) ) (if (eq? c #f) (begin + (display "FAILED\n") + (display (object-type (car name-mag-pair))) + (display (object-type (caaar font-name-alist))) + (ly-warn (string-append - "Programming error: No such font known " (car font-name-symbol))) - "") ; issue no command - (string-append "\\" (cdr c))) + "Programming error: No such font known " + (car name-mag-pair) " " + (number->string (cdr name-mag-pair)) + )) + "") ; issue no command + (string-append "\\" (cddr c))) )) @@ -258,9 +260,9 @@ (define (font-load-command name-mag command) (string-append "\\font\\" command "=" - (symbol->string (car name-mag)) + (car name-mag) " scaled " - (number->string (magstep (cdr name-mag))) + (number->string (inexact->exact (* 1000 (cdr name-mag)))) "\n")) (define (embedded-ps s) @@ -299,7 +301,7 @@ (ly-gulp-file "lily.ps") 'pre " %\n" 'post) (ly-gulp-file "lily.ps")) "}" - "\\input lilyponddefs \\turnOnPostScript")) + "\\input lilyponddefs\\newdimen\\outputscale \\outputscale=\\mudelapaperoutputscale pt\\turnOnPostScript")) (define (header creator generate) (string-append @@ -337,7 +339,7 @@ (define (number->dim x) (string-append - (ly-number->string x) " pt ")) + (ly-number->string x) " \\outputscale ")) (define (placebox x y s) (string-append @@ -465,32 +467,24 @@ "lilyfont" (make-string 1 (integer->char (+ 65 i))))) - (define (mag-to-size m) - (number->string (case m - (0 12) - (1 12) - (2 14) ; really: 14.400 - (3 17) ; really: 17.280 - (4 21) ; really: 20.736 - (5 24) ; really: 24.888 - (6 30) ; really: 29.856 - ))) - - - (define (select-font font-name-symbol) + + (define (select-font name-mag-pair) (let* ( - (c (assoc font-name-symbol font-name-alist)) + (c (assoc name-mag-pair font-name-alist)) ) (if (eq? c #f) (begin + (display name-mag-pair) + (display font-name-alist) (ly-warn (string-append - "Programming error: No such font known " (car font-name-symbol))) - "") ; issue no command + "Programming error: No such font known " (car name-mag-pair)) + (number->string (cdr name-mag-pair)) + ) + + "") ; issue no command (string-append " " (cdr c) " ")) - - )) (define (font-load-command name-mag command) @@ -499,7 +493,7 @@ " { /" (symbol->string (car name-mag)) " findfont " - (number->string (magstep (cdr name-mag))) + (number->string (cdr name-mag)) " 1000 div 12 mul scalefont setfont } bind def " "\n")) @@ -701,6 +695,7 @@ ((string? arg) (string-append "\"" arg "\"")) ((symbol? arg) (string-append "\"" (symbol->string arg) "\"")))) +; ugh: naming. (define (func name . args) (string-append "(" name @@ -715,195 +710,6 @@ 1 (if (< x 0) -1 1))) -;;;; AsciiScript as -(define (as-scm action-name) - - (define (beam width slope thick) - (string-append - (func "set-line-char" "#") - (func "rline-to" width (* width slope)) - )) - - ; simple flat slurs - (define (bezier-sandwich l thick) - (let ( - (c0 (cadddr l)) - (c1 (cadr l)) - (c3 (caddr l))) - (let* ((x (car c0)) - (dx (- (car c3) x)) - (dy (- (cdr c3) (cdr c0))) - (rc (/ dy dx)) - (c1-dx (- (car c1) x)) - (c1-line-y (+ (cdr c0) (* c1-dx rc))) - (dir (if (< c1-line-y (cdr c1)) 1 -1)) - (y (+ -1 (* dir (max (* dir (cdr c0)) (* dir (cdr c3))))))) - (string-append - (func "rmove-to" x y) - (func "put" (if (< 0 dir) "/" "\\\\")) - (func "rmove-to" 1 (if (< 0 dir) 1 0)) - (func "set-line-char" "_") - (func "h-line" (- dx 1)) - (func "rmove-to" (- dx 1) (if (< 0 dir) -1 0)) - (func "put" (if (< 0 dir) "\\\\" "/")))))) - - (define (bracket arch_angle arch_width arch_height width height arch_thick thick) - (string-append - (func "rmove-to" (+ width 1) (- (/ height -2) 1)) - (func "put" "\\\\") - (func "set-line-char" "|") - (func "rmove-to" 0 1) - (func "v-line" (+ height 1)) - (func "rmove-to" 0 (+ height 1)) - (func "put" "/") - )) - - (define (char i) - (func "char" i)) - - (define (define-origin a b c ) "") - - (define (end-output) - (func "end-output")) - - (define (experimental-on) - "") - - (define (filledbox breapth width depth height) - (let ((dx (+ width breapth)) - (dy (+ depth height))) - (string-append - (func "rmove-to" (* -1 breapth) (* -1 depth)) - (if (< dx dy) - (string-append - (func "set-line-char" - (if (<= dx 1) "|" "#")) - (func "v-line" dy)) - (string-append - (func "set-line-char" - (if (<= dy 1) "-" "=")) - (func "h-line" dx)))))) - - (define (font-load-command name-mag command) - (func "load-font" (car name-mag) (magstep (cdr name-mag)))) - - (define (header creator generate) - (func "header" creator generate)) - - (define (header-end) - (func "header-end")) - - ;; urg: this is good for half of as2text's execution time - (define (xlily-def key val) - (string-append "(define " key " " (arg->string val) ")\n")) - - (define (lily-def key val) - (if - (or (equal? key "mudelapaperlinewidth") - (equal? key "mudelapaperstaffheight")) - (string-append "(define " key " " (arg->string val) ")\n") - "")) - - (define (no-origin) "") - - (define (placebox x y s) - (let ((ey (inexact->exact y))) - (string-append "(move-to " (number->string (inexact->exact x)) " " - (if (= 0.5 (- (abs y) (abs ey))) - (number->string y) - (number->string ey)) - ")\n" s))) - - (define (select-font font-name-symbol) - (let* ((c (assoc font-name-symbol font-name-alist))) - (if (eq? c #f) - (begin - (ly-warn - (string-append - "Programming error: No such font known " - (car font-name-symbol))) - "") ; issue no command - (func "select-font" (car font-name-symbol))))) - - (define (start-line height) - (func "start-line" height)) - - (define (stop-line) - (func "stop-line")) - - (define (text s) - (func "text" s)) - - (define (tuplet ht gap dx dy thick dir) "") - - (define (volta h w thick vert-start vert-end) - ;; urg - (string-append - (func "set-line-char" "|") - (func "rmove-to" 0 -4) - ;; definition strange-way around - (if (= 0 vert-start) - (func "v-line" h) - "") - (func "rmove-to" 1 h) - (func "set-line-char" "_") - (func "h-line" (- w 1)) - (func "set-line-char" "|") - (if (= 0 vert-end) - (string-append - (func "rmove-to" (- w 1) (* -1 h)) - (func "v-line" (* -1 h))) - ""))) - - (cond ((eq? action-name 'all-definitions) - `(begin - (define beam ,beam) - (define bracket ,bracket) - (define char ,char) - (define define-origin ,define-origin) - ;;(define crescendo ,crescendo) - (define bezier-sandwich ,bezier-sandwich) - ;;(define dashed-slur ,dashed-slur) - ;;(define decrescendo ,decrescendo) - (define end-output ,end-output) - (define experimental-on ,experimental-on) - (define filledbox ,filledbox) - ;;(define font-def ,font-def) - (define font-load-command ,font-load-command) - ;;(define font-switch ,font-switch) - (define header ,header) - (define header-end ,header-end) - (define lily-def ,lily-def) - ;;(define invoke-char ,invoke-char) - ;;(define invoke-dim1 ,invoke-dim1) - (define no-origin ,no-origin) - (define placebox ,placebox) - (define select-font ,select-font) - (define start-line ,start-line) - ;;(define stem ,stem) - (define stop-line ,stop-line) - (define stop-last-line ,stop-line) - (define text ,text) - (define tuplet ,tuplet) - (define volta ,volta) - )) - ((eq? action-name 'tuplet) tuplet) - ;;((eq? action-name 'beam) beam) - ;;((eq? action-name 'bezier-sandwich) bezier-sandwich) - ;;((eq? action-name 'bracket) bracket) - ((eq? action-name 'char) char) - ;;((eq? action-name 'crescendo) crescendo) - ;;((eq? action-name 'dashed-slur) dashed-slur) - ;;((eq? action-name 'decrescendo) decrescendo) - ;;((eq? action-name 'experimental-on) experimental-on) - ((eq? action-name 'filledbox) filledbox) - ((eq? action-name 'select-font) select-font) - ;;((eq? action-name 'volta) volta) - (else (error "unknown tag -- MUSA-SCM " action-name)) - ) - ) - - (define (gulp-file name) (let* ((port (open-file name "r")) (content (let loop ((text "")) diff --git a/scripts/abc2ly.py b/scripts/abc2ly.py index 8a9b50fb9f..dc08ba9395 100644 --- a/scripts/abc2ly.py +++ b/scripts/abc2ly.py @@ -28,9 +28,8 @@ # Enhancements (Laura Conrad) # -# Barring now preserved between ABC and lilypond -# the default placement for text in abc is above the staff. - +# Beaming now preserved between ABC and lilypond +# # Limitations # # Multiple tunes in single file not supported @@ -76,7 +75,6 @@ lyric_idx = -1 part_names = 0 default_len = 8 length_specified = 0 -nobarlines = 0 global_key = [0] * 7 # UGH names = ["One", "Two", "Three"] DIGITS='0123456789' @@ -95,10 +93,6 @@ def check_clef(s): else: state.base_octave = 0 voices_append("\\clef treble;\n") - elif re.match('^-8va', s): - s = s[4:] - state.base_octave = -1 - voices_append("\\clef \"G_8\";\n") elif re.match('^alto', s): s = s[4:] state.base_octave = -1 @@ -213,7 +207,6 @@ def dump_score (outf): def set_default_length (s): - global length_specified m = re.search ('1/([0-9]+)', s) if m: __main__.default_len = string.atoi ( m.group (1)) @@ -496,7 +489,6 @@ def slyrics_append(a): def try_parse_header_line (ln, state): - global length_specified m = re.match ('^([A-Za-z]): *(.*)$', ln) if m: @@ -513,18 +505,15 @@ def try_parse_header_line (ln, state): if a == 'C': if not state.common_time: state.common_time = 1 -# voices_append ("\\property Staff.timeSignatureStyle=\"C\"\n") - voices_append ("\\property Staff.TimeSignature \push #\'style = #\"C\"\n") + voices_append ("\\property Staff.timeSignatureStyle=\"C\"\n") a = '4/4' if a == 'C|': if not state.common_time: state.common_time = 1 - voices_append ("\\property Staff.TimeSignature \push #\'style = #\"C\"\n") + voices_append ("\\property Staff.timeSignatureStyle=\"C\"\n") a = '2/2' if not length_specified: set_default_len_from_time_sig (a) - else: - length_specified = 0 voices_append ('\\time %s;' % a) state.next_bar = '' if g == 'K': # KEY @@ -532,19 +521,11 @@ def try_parse_header_line (ln, state): if a: m = re.match ('^([^ \t]*) *(.*)$', a) # seperate clef info if m: - # there may or may not be a space - # between the key letter and the mode - if key_lookup.has_key(m.group(2)[0:3]): - key_info = m.group(1) + m.group(2)[0:3] - clef_info = m.group(2)[4:] - else: - key_info = m.group(1) - clef_info = m.group(2) - __main__.global_key = compute_key (key_info)# ugh. - voices_append ('\\key %s;' % lily_key(key_info)) - check_clef(clef_info) + __main__.global_key =compute_key (m.group(1))# ugh. + voices_append ('\\key %s;' % lily_key(m.group(1))) + check_clef(m.group(2)) else: - __main__.global_key = compute_key (a)# ugh. + __main__.global_key =compute_key (a)# ugh. voices_append ('\\key %s \\major;' % lily_key(a)) if g == 'O': # Origin header ['origin'] = a @@ -586,8 +567,7 @@ def try_parse_header_line (ln, state): def pitch_to_mudela_name (name, acc, bar_acc, key): s = '' if acc == UNDEF: - if not nobarlines: - acc = bar_acc + acc = bar_acc if acc == UNDEF: acc = key if acc == -1: @@ -886,7 +866,7 @@ def try_parse_guitar_chord (str, state): if str: str = str[1:] gc = re.sub('#', '\\#', gc) # escape '#'s - state.next_articulation = ("^\"%s\"" % gc) + state.next_articulation + state.next_articulation = ("-\"%s\"" % gc) + state.next_articulation return str def try_parse_escape (str): @@ -913,7 +893,7 @@ bar_dict = { '[|' : '||', ':|' : ':|', '|:' : '|:', -'::' : ':|:', +'::' : '::', '|1' : '|', '|2' : '|', ':|2' : ':|', @@ -1017,23 +997,6 @@ def try_parse_grace_delims (str, state): return str -def try_parse_comment (str): - global nobarlines - #debugging -# sys.stderr.write("str: %s \n" % str) - - # for now, just do %%MIDI nobarlines - if (str[0] == '%'): - #debugging -# sys.stderr.write("we have %%\n") - if str[0:5] == '%MIDI': - #debugging -# sys.stderr.write ("we have %%MIDI\n") - if (string.find(str,'nobarlines') > 0): - #debugging -# sys.stderr.write ("we have nobarlines\n") - nobarlines = 1 - return str happy_count = 100 def parse_file (fn): @@ -1055,7 +1018,6 @@ def parse_file (fn): m = re.match ('^([^%]*)%(.*)$',ln) # add comments to current voice if m: if m.group(2): - try_parse_comment(m.group(2)) voices_append ('%% %s\n' % m.group(2)) ln = m.group (1) diff --git a/tex/lily-ps-defs.tex b/tex/lily-ps-defs.tex index ca33b2543d..45a0db23e1 100644 --- a/tex/lily-ps-defs.tex +++ b/tex/lily-ps-defs.tex @@ -7,12 +7,13 @@ % header info (macros/defs, etc) should go into a \special{! ... }, % note the ! sign. See dvips.info for details. % - +\def\lilySpace{ } \def\turnOnPostScript{% % This sets CTM so that you get to the currentpoint % by executing a 0 0 moveto \def\embeddedps##1{% - \special{ps: @beginspecial @setspecial ##1 @endspecial} + \special{ps: @beginspecial @setspecial + \mudelapaperoutputscale\lilySpace\mudelapaperoutputscale\lilySpace scale ##1 @endspecial}% } } -- 2.39.5