+2002-11-23 Jan Nieuwenhuizen <janneke@gnu.org>
+
+ * scripts/ly2dvi.py: Add paper sizes.
+
+ * lily/timing-engraver.cc:
+ * lily/time-signature.cc:
+ * lily/span-bar.cc:
+ * lily/grob-scheme.cc: Code formatting fixes.
+
+ * scm/sodipodi.scm:
+ * scm/sketch.scm:
+ * buildscripts/mf-to-table.py:
+ * buildscripts/make-font-dir.py: Font testing.
+
2002-11-23 Heikki Junes <hjunes@cc.hut.fi>
* lilypond-mode.el (LilyPond-autocompletion): deletes end-of-word,
if len (split) >= 4:
# Assume
# Adobe FontName = X11 foundry-family-weight-style
- self.foundry, self.family = split[:2]
+ if 1:
+ self.foundry, self.family = split[:2]
+ else: # testin'
+ self.foundry = split[0]
+ self.family = string.join (split[1:-2], ' ')
self.weight = string.join (split[2:-1], ' ')
self.style = split[-1:][0]
self.FamilyName = '%s %s' % (self.family, self.weight)
font_family = (tags[3])
# To omit 'GNU' (foundry) from font name proper:
# name = tags[2:]
+ #urg
+ if 0: #testing
+ tags.append ('Regular')
name = tags[1:]
global_info['FontName'] = string.join (name,'-')
global_info['FullName'] = string.join (name,' ')
global_info['FamilyName'] = string.join (name[1:-1],
'-')
- global_info['Weight'] = tags[4]
+ if 1:
+ global_info['Weight'] = tags[4]
+ else: #testing
+ global_info['Weight'] = tags[-1]
global_info['FontBBox'] = '0 0 1000 1000'
global_info['Ascender'] = '0'
global_info['Descender'] = '0'
#include "paper-def.hh"
#include "system.hh"
-LY_DEFINE(ly_set_grob_property,"ly:set-grob-property!", 3, 0, 0,
+
+LY_DEFINE (ly_set_grob_property,"ly:set-grob-property!", 3, 0, 0,
(SCM grob, SCM sym, SCM val),
"Set @var{sym} in grob @var{grob} to value @var{val}")
{
Grob * sc = unsmob_grob (grob);
- SCM_ASSERT_TYPE(sc, grob, SCM_ARG1, __FUNCTION__, "grob");
- SCM_ASSERT_TYPE(gh_symbol_p (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
+ SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob");
+ SCM_ASSERT_TYPE (gh_symbol_p (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
if (!type_check_assignment (sym, val, ly_symbol2scm ("backend-type?")))
error ("typecheck failed");
return SCM_UNSPECIFIED;
}
-LY_DEFINE(ly_get_grob_property,
+LY_DEFINE (ly_get_grob_property,
"ly:get-grob-property", 2, 0, 0, (SCM grob, SCM sym),
"Get the value of a value in grob @var{g} of property @var{sym}. It
will return @code{'()} (end-of-list) if @var{g} doesn't have @var{sym} set.
")
{
Grob * sc = unsmob_grob (grob);
- SCM_ASSERT_TYPE(sc, grob, SCM_ARG1, __FUNCTION__, "grob");
- SCM_ASSERT_TYPE(gh_symbol_p (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
+ SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob");
+ SCM_ASSERT_TYPE (gh_symbol_p (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
return sc->internal_get_grob_property (sym);
}
-LY_DEFINE(spanner_get_bound, "ly:get-spanner-bound", 2 , 0, 0,
- (SCM slur, SCM dir),
- "Get one of the bounds of @var{spanner}. @var{dir} may be @code{-1} for
-left, and @code{1} for right.
-")
+LY_DEFINE (spanner_get_bound, "ly:get-spanner-bound", 2 , 0, 0,
+ (SCM slur, SCM dir),
+ "Get one of the bounds of @var{spanner}. @var{dir} is @code{-1} "
+ "for left, and @code{1} for right.")
{
Spanner * sl = dynamic_cast<Spanner*> (unsmob_grob (slur));
- SCM_ASSERT_TYPE(sl, slur, SCM_ARG1, __FUNCTION__, "spanner grob");
- SCM_ASSERT_TYPE(ly_dir_p (dir), slur, SCM_ARG2, __FUNCTION__, "dir");
+ SCM_ASSERT_TYPE (sl, slur, SCM_ARG1, __FUNCTION__, "spanner grob");
+ SCM_ASSERT_TYPE (ly_dir_p (dir), slur, SCM_ARG2, __FUNCTION__, "dir");
return sl->get_bound (to_dir (dir))->self_scm ();
}
-/*
- TODO: make difference between scaled and unscalead variable in
- calling (i.e different funcs.)
- */
-LY_DEFINE(ly_get_paper_var,"ly:get-paper-variable", 2, 0, 0,
+/* TODO: make difference between scaled and unscalead variable in
+ calling (i.e different funcs.) */
+LY_DEFINE (ly_get_paper_var,"ly:get-paper-variable", 2, 0, 0,
(SCM grob, SCM sym),
"Get a variable from the \\paper block.")
{
Grob * sc = unsmob_grob (grob);
- SCM_ASSERT_TYPE(sc, grob, SCM_ARG1, __FUNCTION__, "grob");
- SCM_ASSERT_TYPE(gh_symbol_p (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
+ SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob");
+ SCM_ASSERT_TYPE (gh_symbol_p (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
return sc->get_paper () ->lookup_variable (sym);
}
-LY_DEFINE(ly_get_extent, "ly:get-extent", 3, 0, 0,
- (SCM grob, SCM refp, SCM axis),
- "Get the extent in @var{axis} direction of @var{grob} relative to the
-grob @var{refp}")
+LY_DEFINE (ly_get_extent, "ly:get-extent", 3, 0, 0,
+ (SCM grob, SCM refp, SCM axis),
+ "Get the extent in @var{axis} direction of @var{grob} relative to "
+ "the grob @var{refp}")
{
Grob * sc = unsmob_grob (grob);
Grob * ref = unsmob_grob (refp);
- SCM_ASSERT_TYPE(sc, grob, SCM_ARG1, __FUNCTION__, "grob");
- SCM_ASSERT_TYPE(ref, refp, SCM_ARG2, __FUNCTION__, "grob");
+ SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob");
+ SCM_ASSERT_TYPE (ref, refp, SCM_ARG2, __FUNCTION__, "grob");
- SCM_ASSERT_TYPE(ly_axis_p (axis), axis, SCM_ARG3, __FUNCTION__, "axis");
+ SCM_ASSERT_TYPE (ly_axis_p (axis), axis, SCM_ARG3, __FUNCTION__, "axis");
return ly_interval2scm ( sc->extent (ref, Axis (gh_scm2int (axis))));
}
-LY_DEFINE (ly_get_parent, "ly:get-parent", 2, 0, 0, (SCM grob, SCM axis),
- "Get the parent of @var{grob}. @var{axis} can be 0 for the X-axis, 1
-for the Y-axis.")
+LY_DEFINE (ly_get_parent, "ly:get-parent", 2, 0, 0, (SCM grob, SCM axis),
+ "Get the parent of @var{grob}. @var{axis} is 0 for the X-axis, "
+ "1 for the Y-axis.")
{
Grob * sc = unsmob_grob (grob);
- SCM_ASSERT_TYPE(sc, grob, SCM_ARG1, __FUNCTION__, "grob");
- SCM_ASSERT_TYPE(ly_axis_p (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
+ SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob");
+ SCM_ASSERT_TYPE (ly_axis_p (axis), axis, SCM_ARG2, __FUNCTION__, "axis");
Grob * par = sc->get_parent (Axis (gh_scm2int (axis)));
- return par ? par->self_scm() : SCM_EOL;
+ return par ? par->self_scm () : SCM_EOL;
}
/* ly prefix? */
LY_DEFINE (get_system,
"ly:get-system",
1, 0, 0, (SCM grob),
- "
-Return the System Grob of @var{grob}.
-")
+ "Return the System Grob of @var{grob}.")
{
Grob *me = unsmob_grob (grob);
SCM_ASSERT_TYPE (me, grob, SCM_ARG1, __FUNCTION__, "grob");
LY_DEFINE (get_original,
"ly:get-original",
1, 0, 0, (SCM grob),
- "
-Return the original Grob of @var{grob}
-")
+ "Return the original Grob of @var{grob}")
{
Grob *me = unsmob_grob (grob);
SCM_ASSERT_TYPE (me, grob, SCM_ARG1, __FUNCTION__, "grob");
/* ly prefix? spanner in name? */
-/*
- TODO: maybe we should return a vector -- random access is more
- logical for this list?
- */
+/* TODO: maybe we should return a vector -- random access is more
+ logical for this list? */
LY_DEFINE (get_broken_into,
"ly:get-broken-into", 1, 0, 0, (SCM spanner),
- "
-Return broken-into list for @var{spanner}.
-"
-)
+ "Return broken-into list for @var{spanner}.")
{
/// Spanner *me = unsmob_spanner (spanner);
Spanner *me = dynamic_cast<Spanner*> (unsmob_grob (spanner));
MAKE_SCHEME_CALLBACK (Span_bar,brew_molecule,1);
-/*
- Limitations/Bugs:
+/* Limitations/Bugs:
(1) Elements from 'me->get_grob_property ("elements")' must be
ordered according to their y coordinates relative to their common
(2) This method depends on bar_engraver not being removed from
staff context. If bar_engraver is removed, the size of the staff
lines is evaluated as 0, which results in a solid span bar line
- with faulty y coordinate.
- */
+ with faulty y coordinate. */
-/*
- This routine was originally by Juergen Reuter, but it was a on the
- bulky side. Rewritten by Han-Wen.
- */
+/* This routine was originally by Juergen Reuter, but it was a on the
+ bulky side. Rewritten by Han-Wen. */
SCM
Span_bar::brew_molecule (SCM smobbed_me)
{
Grob *me = unsmob_grob (smobbed_me);
SCM first_elt = me->get_grob_property ("elements");
- // compute common refpoint of elements
+ /* compute common refpoint of elements */
Grob *refp = me;
for (SCM elts = first_elt; gh_pair_p (elts); elts = ly_cdr (elts))
{
refp = staff_bar->common_refpoint (refp, Y_AXIS);
}
- Span_bar::evaluate_glyph(me);
+ Span_bar::evaluate_glyph (me);
SCM glyph = me->get_grob_property ("glyph");
- /*
- glyph may not be a string, when ME is killed by Hara Kiri in
- between.
- */
+ /* glyph may not be a string, when ME is killed by Hara Kiri in
+ between. */
if (!gh_string_p (glyph))
return SCM_EOL;
String glyph_string = ly_scm2string (glyph);
- // compose span_bar_mol
+ /* compose span_bar_mol */
Molecule span_bar_mol;
Interval prev_extent;
if (!prev_extent.empty_b ())
{
- Interval l(prev_extent [UP],
+ Interval l (prev_extent [UP],
ext[DOWN]);
if (l.empty_b ())
{
- /* there is overlap between the bar lines. We do nothign here.
- */
+ /* There is overlap between the bar lines. Do nothing. */
}
else
{
- Molecule interbar
- = Bar_line::compound_barline (staff_bar, glyph_string, l.length());
+ Molecule interbar = Bar_line::compound_barline (staff_bar,
+ glyph_string,
+ l.length ());
interbar.translate_axis (l.center (), Y_AXIS);
span_bar_mol.add_molecule (interbar);
}
prev_extent = ext;
}
- span_bar_mol.translate_axis (- me->relative_coordinate (refp, Y_AXIS), Y_AXIS);
+ span_bar_mol.translate_axis (- me->relative_coordinate (refp, Y_AXIS),
+ Y_AXIS);
return span_bar_mol.smobbed_copy ();
}
evaluate_empty (unsmob_grob (smob));
evaluate_glyph (unsmob_grob (smob));
- /*
- no need to call Bar_line::before_line_breaking (), because the info
- in ELEMENTS already has been procced by Bar_line::before_line_breaking ().
- */
+ /* No need to call Bar_line::before_line_breaking (), because the info
+ in ELEMENTS already has been procced by
+ Bar_line::before_line_breaking (). */
return SCM_UNSPECIFIED;
}
assert (a == Y_AXIS);
Interval i (get_spanned_interval (me));
- /*
- Bar_line::brew_molecule delivers a barline of y-extent (-h/2,h/2), so
- we have to translate ourselves to be in the center of the
- interval that we span. */
+ /* Bar_line::brew_molecule delivers a barline of y-extent (-h/2,h/2), so
+ we have to translate ourselves to be in the center of the
+ interval that we span. */
if (i.empty_b ())
{
me->suicide ();
void
Span_bar::evaluate_empty (Grob*me)
{
- /*
- TODO: filter all hara-kiried out of ELEMENS list, and then
- optionally do suicide. Call this cleanage function from
- center_on_spanned_callback () as well.
-
- */
+ /* TODO: filter all hara-kiried out of ELEMENS list, and then
+ optionally do suicide. Call this cleanage function from
+ center_on_spanned_callback () as well. */
if (!gh_pair_p (me->get_grob_property ("elements")))
{
me->suicide ();
while (gh_pair_p (elts))
{
- gl = unsmob_grob (gh_car (elts))->internal_get_grob_property (glyph_symbol);
+ gl = unsmob_grob (gh_car (elts))
+ ->internal_get_grob_property (glyph_symbol);
if (gh_string_p (gl))
break;
elts =gh_cdr (elts);
}
gl = scm_makfrom0str (type.to_str0 ());
- if (scm_equal_p (me->internal_get_grob_property (glyph_symbol), gl) != SCM_BOOL_T)
+ if (scm_equal_p (me->internal_get_grob_property (glyph_symbol), gl)
+ != SCM_BOOL_T)
me->internal_set_grob_property (glyph_symbol, gl);
}
Interval
Span_bar::get_spanned_interval (Grob*me)
{
- return ly_scm2interval (Axis_group_interface::group_extent_callback (me->self_scm (), gh_int2scm (Y_AXIS)));
+ return ly_scm2interval (Axis_group_interface::group_extent_callback
+ (me->self_scm (), gh_int2scm (Y_AXIS)));
}
Interval iv (get_spanned_interval (me));
if (iv.empty_b ())
{
- /*
- This happens if the bars are hara-kiried from under us.
- */
+ /* This happens if the bars are hara-kiried from under us. */
me->suicide ();
return gh_double2scm (-1);
}
#include "warn.hh"
#include "staff-symbol-referencer.hh"
-MAKE_SCHEME_CALLBACK (Time_signature,brew_molecule,1);
-/*
- TODO: make different functions for special and normal timesigs.
- */
+MAKE_SCHEME_CALLBACK (Time_signature, brew_molecule, 1);
+/* TODO: make different functions for special and normal timesigs. */
SCM
Time_signature::brew_molecule (SCM smob)
{
String char_name = style + to_string (n) + "/" + to_string (d);
me->set_grob_property ("font-family", ly_symbol2scm ("music"));
- Molecule out =
- Font_interface::get_default_font (me)->find_by_name ("timesig-" + char_name);
+ Molecule out = Font_interface::get_default_font (me)
+ ->find_by_name ("timesig-" + char_name);
if (!out.empty_b ())
return out;
- /*
- If there is no such symbol, we default to the numbered style.
- (Here really with a warning!)
- */
+ /* If there is no such symbol, we default to the numbered style.
+ (Here really with a warning!) */
me->warning (_f ("time signature symbol `%s' not found; "
"reverting to numbered style", char_name));
return numbered_time_signature (me, n, d);
Time_signature::numbered_time_signature (Grob*me,int num, int den)
{
SCM chain = Font_interface::font_alist_chain (me);
- me->set_grob_property("font-family", ly_symbol2scm ("number"));
-
- Molecule n = Text_item::text2molecule (me,
- scm_makfrom0str (to_string (num).to_str0 ()),
- chain);
- Molecule d = Text_item::text2molecule (me,
- scm_makfrom0str (to_string (den).to_str0 ()),
- chain);
+ me->set_grob_property ("font-family", ly_symbol2scm ("number"));
+
+ Molecule n =
+ Text_item::text2molecule (me, scm_makfrom0str (to_string (num).to_str0 ()),
+ chain);
+ Molecule d =
+ Text_item::text2molecule (me, scm_makfrom0str (to_string (den).to_str0 ()),
+ chain);
n.align_to (X_AXIS, CENTER);
d.align_to (X_AXIS, CENTER);
Molecule m;
return m;
}
-ADD_INTERFACE (Time_signature,"time-signature-interface",
+ADD_INTERFACE (Time_signature, "time-signature-interface",
"A time signature, in different styles.
The following values for 'style are are recognized:
class Timing_engraver : public Timing_translator, public Engraver
{
protected:
- /*
- Needed to know whether we're advancing in grace notes, or not.
- */
+ /* Needed to know whether we're advancing in grace notes, or not. */
Moment last_moment_;
virtual void start_translation_timestep ();
virtual void stop_translation_timestep ();
public:
- TRANSLATOR_DECLARATIONS(Timing_engraver);
+ TRANSLATOR_DECLARATIONS (Timing_engraver);
};
Moment now = now_mom ();
SCM which = get_property ("whichBar");
- /*
- Set the first bar of the score?
- */
+ /* Set the first bar of the score? */
if (!gh_string_p (which))
which
= (now.main_part_ || now.main_part_ == last_moment_.main_part_)
? SCM_EOL : scm_makfrom0str ("|");
Moment mp = measure_position ();
- bool start_of_measure = (last_moment_.main_part_ != now.main_part_&& !mp.main_part_ );
+ bool start_of_measure = (last_moment_.main_part_ != now.main_part_
+ && !mp.main_part_);
if (start_of_measure)
{
- Moment mlen = Moment(measure_length ());
- unsmob_grob (get_property ("currentCommandColumn"))->set_grob_property ("measure-length", mlen.smobbed_copy());
+ Moment mlen = Moment (measure_length ());
+ unsmob_grob (get_property ("currentCommandColumn"))
+ ->set_grob_property ("measure-length", mlen.smobbed_copy ());
}
if (!gh_string_p (which) && !to_boolean (nonauto))
}
-ENTER_DESCRIPTION(Timing_engraver,
+ENTER_DESCRIPTION (Timing_engraver,
/* descr */ " Responsible for synchronizing timing information from staves.
Normally in @code{Score}. In order to create polyrhythmic music,
this engraver should be removed from @code{Score} and placed in
;; how to get zero-left padding with ``Guile's fprintf'' ?
;;(format #f "txt('\\x~2x',(" i)
;;(format #f "txt('\\x~02x',(" i)
- ;; ugh uhg
- (if (< i 16)
- (format #f "txt('\\x0~x',(" i)
- (format #f "txt('\\x~x',(" i))
+ ;; ugh: python's '%02x' % i
+ (format #f "&#x~2,'0x;" i)
(sketch-numbers->string (map mul-scale (list x y)))
"))\n"))
;; Interface functions
(define (char i)
- (tagify "tspan" (make-string 1 (integer->char i))))
+ (if (or
+ #t
+ (= i #x9)
+ (= i #xa)
+ (= i #xd)
+ (>= i #x20))
+ ;;(tagify "tspan" (format #f "&#x~2,'0x;" i))
+ (tagify "tspan" (format #f "à~2,'0x;" i))
+ ;; how to access remaining characters??
+ ;;;(tagify "tspan" (format #f "&#x~2,'0x;" #x20)
+ (begin
+ (format #t "can't display char: ~x\n" i)
+ " ")))
(define (end-output)
"</g></svg>")
`(height . ,(number->string (* output-scale (+ depth height))))))
-(define (fontify name-mag-pair expr)
-
- ;; for simple sodipodi with feta20.pfb:
-;; (tagify "text" (dispatch expr) '(style . "fill:black;stroke:none;font-family:futa20;font-style:normal;font-weight:normal;font-size:20;fill-opacity:1;stroke-opacity:1;stroke-width:1pt;stroke-linejoin:miter;stroke-linecap:butt;text-anchor:start;writing-mode:lr;"))
-
- ;; Sketch' svg input filter groks this:
- (tagify "text" (dispatch expr) '(style . "fill:black;stroke:none;font-family:LilyPond-Feta-20;font-style:normal;font-weight:normal;font-size:20;fill-opacity:1;stroke-opacity:1;stroke-width:1pt;stroke-linejoin:miter;stroke-linecap:butt;text-anchor:start;writing-mode:lr;"))
+(define font-alist '(("feta13" . ("LilyPond-Feta13" . "13"))
+ ("feta20" . "fill:black;stroke:none;font-family:lilypond;font-style:feta;font-weight:normal;font-size:20;fill-opacity:1;stroke-opacity:1;stroke-width:1pt;stroke-linejoin:miter;stroke-linecap:butt;text-anchor:start;writing-mode:lr;")
+ ("parmesan20" . "fill:black;stroke:none;font-family:lilypond;font-style:parmesan;font-weight:normal;font-size:20;fill-opacity:1;stroke-opacity:1;stroke-width:1pt;stroke-linejoin:miter;stroke-linecap:butt;text-anchor:start;writing-mode:lr;")
+ ))
+(define (get-font name-mag-pair)
+ ;; name-mag-pair: (quote ("feta20" . 0.569055118110236))"feta20"(quote ("feta20" . 0.569055118110236))
+ (let ((f (assoc (caadr name-mag-pair) font-alist)))
+ (if (pair? f)
+ (cdr f)
+ (begin
+ (format #t "font not found: ~s\n" (caadr name-mag-pair))
+ (cdr (assoc "feta20" font-alist))))))
- )
+(define (fontify name-mag-pair expr)
+ (string-append
+ (tagify "text" (dispatch expr) (cons 'style (get-font name-mag-pair)))))
(define (header creator generate)
ly_paper_to_latexpaper = {
- 'a4' : 'a4paper',
'letter' : 'letterpaper',
- 'a3' : 'a3paper'
+ 'a3' : 'a3paper',
+ 'a4' : 'a4paper',
+ 'a5' : 'a5paper',
+ 'a6' : 'a6paper',
}
#TODO: should set textheight (enlarge) depending on papersize.