+2002-09-01 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+ * input/test/tab-staff.ly: removed.
+
+ * lily/paper-def.cc (find_font): load virtual font for a list of
+ font names.
+
+ * scm/font.scm (paper20-style-sheet-alist): equate ancient and
+ music font-families.
+
+ * lily/virtual-font-metric.cc (get_char_molecule): new function
+
+ * lily/system-start-delimiter.cc (staff_brace): use virtual fonts
+ for the list of braces
+
+ * lily/font-metric.cc (get_char_molecule): new function.
+
2002-08-31 Han-Wen Nienhuys <hanwen@cs.uu.nl>
* lily/virtual-font-metric.cc: new file
@lilypondfile{feta16list.ly}
+
+@lilypondfile{parmesan16list.ly}
+
@lilypond[fragment,singleline,verbatim]
\property Voice.NoteHead \set #'style = #'mensural
- \property Voice.NoteHead \set #'font-family = #'ancient
a'\longa
@end lilypond
@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
+++ /dev/null
-\version "1.5.68"
-
-
-
-%{
-
-Kludge for half-assed tab notation (you need to fill the numbers
-yourself.)
-
-%}
-
-bla = \notes \relative c' { <c4 e g> <c4. e g> <c8 f a> <c4 f a> <c1 e g> }
-
-\score { \notes
-<
- \context Voice = BLA \bla
- \context TabStaff \context Thread \bla
->
-
-\paper {
- \translator {
- \StaffContext
- \name TabStaff
- StaffSymbol \override #'line-count = #6
- \remove "Clef_engraver"
- \remove "Time_signature_engraver"
- \consists "Pitch_squash_engraver"
- NoteHead \override #'transparent = ##t
- Stem \override #'transparent = ##t
- NoteHead \override #'staff-position = #-6
- Dots \override #'transparent = ##t
- squashedPosition = #-4
- Stem \override #'length = #12
-}
-\translator {
-\ScoreContext
-\accepts TabStaff
-}
-}
-}
}
+
Font_metric *
All_font_metrics::find_font (String name)
{
{
Font_metric * m = (Font_metric*) SCM_CELL_WORD_1 (s);
- do_derived_mark();
+ m->derived_mark();
return m->description_;
}
}
+
+
+
+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);
+}
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,);
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);
{
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:
}
SCM
-fontify_atom (Font_metric * met, SCM f)
+fontify_atom (Font_metric const * met, SCM f)
{
if (f == SCM_EOL)
return f;
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'",
(c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
+
#include <math.h>
+#include "virtual-font-metric.hh"
#include "all-font-metrics.hh"
#include "string.hh"
#include "misc.hh"
/*
todo: use symbols and hashtable idx?
+
+
*/
Font_metric *
Paper_def::find_font (SCM fn, Real m)
if (gh_pair_p (met))
return unsmob_metrics (ly_cdr (met));
- SCM ssc;
- if (variable_tab_->try_retrieve (ly_symbol2scm ("outputscale"), &ssc))
+ /*
+ Hmm. We're chaining font - metrics. Should consider wether to merge
+ virtual-font and scaled_font.
+ */
+ Font_metric* f=0;
+ if (gh_list_p (fn))
{
- m /= gh_scm2double (ssc);
+ f = new Virtual_font_metric (fn, m, this);
+ }
+ else
+ {
+ SCM ssc;
+ if (variable_tab_->try_retrieve (ly_symbol2scm ("outputscale"), &ssc))
+ {
+ m /= gh_scm2double (ssc);
+ }
+
+ f = all_fonts_global->find_font (ly_scm2string (fn));
+ SCM val = Scaled_font_metric::make_scaled_font_metric (f, m);
+ scaled_fonts_ = scm_acons (key, val, scaled_fonts_);
+ f = unsmob_metrics (val);
+ scm_gc_unprotect_object (val);
}
-
- Font_metric* f = all_fonts_global->find_font (ly_scm2string (fn));
- SCM val = Scaled_font_metric::make_scaled_font_metric (f, m);
- scaled_fonts_ = scm_acons (key, val, scaled_fonts_);
-
- scm_gc_unprotect_object (val);
- return dynamic_cast<Scaled_font_metric*> (unsmob_metrics (val));
+ return f;
}
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):
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
{
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;
}
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());
}
#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);
}
}
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;
+}
+
)
(define paper-style-sheet-alist
- '(
- ((8 * * braces 8) . "feta-braces8")
- ((7 * * braces 7) . "feta-braces7")
- ((6 * * braces 6) . "feta-braces6")
- ((5 * * braces 5) . "feta-braces5")
- ((4 * * braces 4) . "feta-braces4")
- ((3 * * braces 3) . "feta-braces3")
- ((2 * * braces 2) . "feta-braces2")
- ((1 * * braces 1) . "feta-braces1")
- ((0 * * braces 0) . "feta-braces0")
- ))
+ `(
+ ((* * * braces *) . ("feta-braces0"
+ "feta-braces1"
+ "feta-braces2"
+ "feta-braces3"
+ "feta-braces4"
+ "feta-braces5"
+ "feta-braces6"
+ "feta-braces7"
+ "feta-braces8") )))
;; FIXME: what about this comment?:
+
+;; font-lookup seems a little inefficient -- walking this entire list
+;; for a single font.
+;;
;; should really have name/pt size at the front of the list.
;; (also tried to vary the order of this list, with little effect)
;;
((-4 * * dynamic 7) . "feta-din7")
((-5 * * dynamic 6) . "feta-din6")
- ((2 * * music 26) . "feta26")
- ((1 * * music 23) . "feta23")
- ((0 * * music 20) . "feta20")
- ((-1 * * music 16) . "feta16")
- ((-2 * * music 13) . "feta13")
- ((-3 * * music 11) . "feta11")
- ((-4 * * music 11) . "feta11")
-
- ((2 * * ancient 26) . "parmesan26")
- ((1 * * ancient 23) . "parmesan23")
- ((0 * * ancient 20) . "parmesan20")
- ((-1 * * ancient 16) . "parmesan16")
- ((-2 * * ancient 13) . "parmesan13")
- ((-3 * * ancient 11) . "parmesan11")
- ((-4 * * ancient 11) . "parmesan11")
+ ((2 * * music 26) . ("feta26" "parmesan26"))
+ ((1 * * music 23) . ("feta23" "parmesan23"))
+ ((0 * * music 20) . ("feta20" "parmesan20"))
+ ((-1 * * music 16) . ("feta16" "parmesan16"))
+ ((-2 * * music 13) . ("feta13" "parmesan13"))
+ ((-3 * * music 11) . ("feta11" "parmesan11"))
+ ((-4 * * music 11) . ("feta11" "parmesan11"))
+
+ ((2 * * ancient 26) . ("feta26" "parmesan26"))
+ ((1 * * ancient 23) . ("feta23" "parmesan23"))
+ ((0 * * ancient 20) . ("feta20" "parmesan20"))
+ ((-1 * * ancient 16) . ("feta16" "parmesan16"))
+ ((-2 * * ancient 13) . ("feta13" "parmesan13"))
+ ((-3 * * ancient 11) . ("feta11" "parmesan11"))
+ ((-4 * * ancient 11) . ("feta11" "parmesan11"))
((0 * * math 10) . "msam10")
((-1 * * math 10) . "msam10")
;;
(define (change-relative-size font-desc decrement)
"return a FONT-DESCR with relative size decremented by DECREMENT"
- (cons (- (car font-desc) decrement) (cdr font-desc))
+
+ (if (number? (car font-desc))
+ (cons (- (car font-desc) decrement) (cdr font-desc))
+ font-desc)
)
(define (change-rhs-size font-desc from to )
(regexp-substitute/global #f from (cdr font-desc) 'pre to 'post))
)
-
;;
(define (map-alist-keys func list)
))
)
-(set! font-list-alist
+;;
+;; make a kludged up paper-19 style sheet. Broken by virtual fonts.
+;;
+(if #f
+ (set! font-list-alist
(cons
(cons
'paper19
(map (lambda (x) (change-rhs-size x "20" "19"))
paper20-style-sheet-alist))
- font-list-alist))
+ font-list-alist)))
(define (make-style-sheet sym)
`((fonts . ,(append paper-style-sheet-alist
;; 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)
;; brevis, longa and maxima from the neo-mensural font and all
;; other note heads from the default font. -- jr
(if (< duration 0)
- (cons (string-append (number->string duration) "neo_mensural") "ancient")
+ (cons (string-append (number->string duration) "neo_mensural") "music")
(cons (number->string duration) "music")))
((mensural)
(cons (string-append (number->string duration) (symbol->string style))
- "ancient"))
+ "music"))
((neo_mensural)
(cons (string-append (number->string duration) (symbol->string style))
- "ancient"))
+ "music"))
((default)
;; The default font in mf/feta-bolletjes.mf defines a brevis, but
;; neither a longa nor a maxima. Hence let us, for the moment,
;; should look exactly like the brevis of the default font, but
;; with a stem exactly like that of the quarter note. -- jr
(if (< duration -1)
- (cons (string-append (number->string duration) "neo_mensural") "ancient")
+ (cons (string-append (number->string duration) "neo_mensural") "music")
(cons (number->string duration) "music")))
(else
(if (string-match "vaticana*|hufnagel*|medicaea*" (symbol->string style))
- (cons (symbol->string style) "ancient")
+ (cons (symbol->string style) "music")
(cons (string-append (number->string (max 0 duration))
(symbol->string style))
"music")))))