ChordNames.SeparationItem #'padding for adjusting space after chords.
* lily/music-output-def.cc (LY_DEFINE):
new function ly:paper-lookup.
* lily/paper-def.cc: new function ly:paper-font; this function
replaces ly:get-font.
* lily/include/font-interface.hh (struct Font_interface): take
Paper_def iso. Grob for get_font().
2003-09-14 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ * scm/chord-name.scm: remove new-chord-name-brew-molecule ; use
+ ChordNames.SeparationItem #'padding for adjusting space after chords.
+
+ * lily/music-output-def.cc (LY_DEFINE):
+ new function ly:paper-lookup.
+
* mf/parmesan-clefs.mf: use # quantities for char_box
offsets. Fixes overflow errors in the PFA.
+/*
+ accidental.cc -- implement Accidental_interface
+
+ (c) 2001--2003 Han-Wen Nienhuys
+
+ */
#include "font-interface.hh"
#include "item.hh"
#include "molecule.hh"
#include "accidental-interface.hh"
+#include "paper-def.hh"
/*
TODO: insert support for smaller cautionaries, tie-break-reminders.
(ly_symbol2scm ("font-relative-size"),
scm_int2num (-1)), SCM_EOL),
ac);
- fm = Font_interface::get_font (me->get_paper (), ac);
+ fm = select_font (me->get_paper (), ac);
}
else
fm = Font_interface::get_default_font (me);
Break_align_interface::do_alignment (Grob *me)
{
Item * item = dynamic_cast<Item*> (me);
- int rank = Paper_column::get_rank (item->get_column ());
Link_array<Grob> elems
= Pointer_group_interface__extract_grobs (me, (Grob*)0,
"elements");
#include "warn.hh"
-/*
- TODO revise font handling.
-
-
-* relative sizes should relate to staff-space, eg. font-staff-space
-= 1.2 ^ relative-size
-
-* If a relative size is given, lily should magnify the closest
-design size font to match that. (ie. fonts should have variable
-scaling)
-
-(this requires that fonts are stored as (filename , designsize))
-
-
-
- */
-
-SCM
-Font_interface::font_alist_chain (Grob *me)
-{
- /*
- Ugh: why the defaults?
- */
- SCM defaults = me->get_paper ()->lookup_variable (ly_symbol2scm ("font-defaults"));
-
- SCM ch = me->get_property_alist_chain (defaults);
- return ch;
-}
-
-
-MAKE_SCHEME_CALLBACK(Font_interface, get_property_alist_chain, 1);
-SCM
-Font_interface::get_property_alist_chain (SCM grob)
-{
- Grob * g = unsmob_grob (grob);
- SCM_ASSERT_TYPE(g, grob, SCM_ARG1, __FUNCTION__, "grob");
- return font_alist_chain (g);
-}
-
/*
todo: split up this func, reuse in text_item?
*/
if (fm)
return fm;
- fm = get_font (me->get_paper (), font_alist_chain (me));
+ fm = select_font (me->get_paper (), font_alist_chain (me));
me->set_grob_property ("font", fm->self_scm ());
return fm;
}
}
-Font_metric *
-Font_interface::get_font (Paper_def *paper, SCM chain)
-{
- SCM name = ly_assoc_chain (ly_symbol2scm ("font-name"), chain);
-
- if (!gh_pair_p (name) || !gh_string_p (gh_cdr (name)))
- {
- SCM proc = paper->lookup_variable (ly_symbol2scm ("properties-to-font"));
- SCM fonts = paper->lookup_variable (ly_symbol2scm ("fonts"));
-
- assert (gh_procedure_p (proc));
- name = gh_call2 (proc, fonts, chain);
- }
- else
- name = gh_cdr (name);
-
- SCM mag = ly_assoc_chain (ly_symbol2scm ("font-magnification"), chain);
-
- Real rmag = gh_pair_p (mag) && gh_number_p (gh_cdr (mag))
- ? gh_scm2double (gh_cdr (mag)) : 1.0;
-
- Font_metric *fm = paper->find_font (name, rmag);
- return fm;
-}
-
-/*
-SCM routines for looking up fonts.
-
-wtk-fugue2, SCM:
-
-real 0m31.862s
-user 0m29.110s
-sys 0m0.260s
-
-wtk-fugue2, C++:
-
-real 0m26.964s
-user 0m24.850s
-sys 0m0.280s
-
-
-so a 14% speedup.
-
-*/
-
-static SCM shape_sym, family_sym, series_sym, rel_str0_sym, design_str0_sym, wild_sym;
-
-
-static void
-init_syms ()
-{
- shape_sym = scm_permanent_object (ly_symbol2scm ("font-shape"));
- family_sym = scm_permanent_object (ly_symbol2scm ("font-family"));
- series_sym = scm_permanent_object (ly_symbol2scm ("font-series"));
- rel_str0_sym = scm_permanent_object (ly_symbol2scm ("font-relative-size"));
- design_str0_sym = scm_permanent_object (ly_symbol2scm ("font-design-size"));
- wild_sym = scm_permanent_object (ly_symbol2scm ("*"));
-}
-
-ADD_SCM_INIT_FUNC(fi_init_syms, init_syms);
-
-bool
-Font_interface::wild_compare (SCM field_val, SCM val)
-{
- return (val == SCM_BOOL_F || field_val == wild_sym || field_val == val);
-}
-
-
-MAKE_SCHEME_CALLBACK (Font_interface,properties_to_font_name,2);
SCM
-Font_interface::properties_to_font_name (SCM fonts, SCM alist_chain)
+Font_interface::font_alist_chain (Grob*g)
{
- SCM shape = SCM_BOOL_F;
- SCM family = SCM_BOOL_F;
- SCM series = SCM_BOOL_F;
-
+ SCM defaults = g->get_paper ()->lookup_variable (ly_symbol2scm ("font-defaults"));
- SCM point_str0 = ly_assoc_chain (design_str0_sym, alist_chain);
- SCM rel_str0 = SCM_BOOL_F;
-
- shape = ly_assoc_chain (shape_sym, alist_chain);
- family = ly_assoc_chain (family_sym, alist_chain);
- series = ly_assoc_chain (series_sym, alist_chain);
-
- if (gh_pair_p (shape))
- shape = ly_cdr (shape);
- if (gh_pair_p (family))
- family = ly_cdr (family);
- if (gh_pair_p (series))
- series = ly_cdr (series);
-
-
- if (gh_pair_p (point_str0))
- point_str0 = ly_cdr (point_str0);
- else
- {
- rel_str0 = ly_assoc_chain (rel_str0_sym, alist_chain);
- if (gh_pair_p (rel_str0))
- rel_str0 = ly_cdr (rel_str0);
- }
+ return g->get_property_alist_chain (defaults);
+}
- for (SCM s = fonts ; gh_pair_p (s); s = ly_cdr (s))
- {
- SCM qlist = ly_caar (s);
- if (!wild_compare (scm_list_ref (qlist, gh_int2scm (1)), series))
- continue;
- if (!wild_compare (scm_list_ref (qlist, gh_int2scm (2)), shape))
- continue;
- if (!wild_compare (scm_list_ref (qlist, gh_int2scm (3)), family))
- continue;
- if (point_str0 == SCM_BOOL_F && !wild_compare (ly_car (qlist), rel_str0))
- continue;
-
- SCM qname = ly_cdar (s);
- return qname;
- }
-
- warning (_ ("couldn't find any font satisfying "));
- scm_write (scm_list_n (point_str0, shape, series , family, rel_str0,
- SCM_UNDEFINED), scm_current_error_port ());
- scm_flush (scm_current_error_port ());
-
- return scm_makfrom0str ("cmr10");
-
-}
-
ADD_INTERFACE (Font_interface, "font-interface",
return s;
}
+
+
+LY_DEFINE(ly_property_alist_chain, "ly:grob-property-chain",
+ 1,1,0,
+ (SCM grob, SCM defaults),
+ "Return all the properties of @code{grob}. Glue @var{defaults} at the end of the chain.")
+{
+ Grob * g = unsmob_grob (grob);
+ SCM_ASSERT_TYPE(g, grob, SCM_ARG1, __FUNCTION__, "grob");
+
+ if (defaults == SCM_UNDEFINED)
+ defaults = SCM_EOL;
+
+ SCM ch = g->get_property_alist_chain (defaults);
+ return ch;
+}
struct Font_interface
{
static SCM font_alist_chain (Grob*);
- static Font_metric * get_font (Paper_def*, SCM alist_chain);
static Font_metric * get_default_font (Grob*);
- static bool wild_compare (SCM field_val, SCM val);
- DECLARE_SCHEME_CALLBACK (properties_to_font_name, (SCM,SCM));
- DECLARE_SCHEME_CALLBACK (get_property_alist_chain, (SCM));
static bool has_interface (Grob*);
};
};
Paper_def * unsmob_paper (SCM x);
+Font_metric *select_font (Paper_def *paper, SCM chain);
+
#endif // Paper_def_HH
ly_symbol2scm ("music")),
SCM_UNDEFINED);
- Font_metric *fm = Font_interface::get_font (me->get_paper (),
+ Font_metric *fm = select_font (me->get_paper (),
gh_cons (style_alist,
alist_chain));
Molecule m = fm->find_by_name ("scripts-trill-element");
Real staff_space = Staff_symbol_referencer::staff_space (me);
Font_metric *musfont
- = Font_interface::get_font (me->get_paper (), alist_chain);
+ = select_font (me->get_paper (), alist_chain);
SCM sml = me->get_grob_property ("use-breve-rest");
if (measures == 1)
return scm_variable_ref (var);
}
+
+
+LY_DEFINE(ly_paper_lookup,
+ "ly:paper-lookup",
+ 2, 0,0,
+ (SCM pap, SCM sym),
+ "Lookup @var{sym} in @var{pap}. Return the value "
+ " or '() if undefined. "
+ )
+{
+ Music_output_def *op = unsmob_music_output_def (pap);
+ SCM_ASSERT_TYPE (op, pap, SCM_ARG1, __FUNCTION__, "Paper");
+ SCM_ASSERT_TYPE (gh_symbol_p (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
+
+ SCM v = op->lookup_variable (sym);
+
+ if (SCM_VARIABLEP(v))
+ return SCM_VARIABLE_REF(v);
+ else
+ return SCM_EOL;
+}
#include "text-item.hh"
#include "lookup.hh"
#include "font-interface.hh"
-
+#include "paper-def.hh"
String r = to_string (Paper_column::get_rank (me));
SCM properties = Font_interface::font_alist_chain (me);
- SCM scm_mol = Text_item::interpret_markup (p, properties,
+ SCM scm_mol = Text_item::interpret_markup (me->get_paper ()->self_scm (),
+ properties,
scm_makfrom0str (r.to_str0 ()));
Molecule t = *unsmob_molecule (scm_mol);
t.align_to (X_AXIS, CENTER);
return l;
}
-/*
- Font_interface should be reorganised?
-*/
-#include "font-interface.hh"
-
-
-LY_DEFINE(ly_paper_get_font,"ly:paper-get-font", 2, 0, 0,
- (SCM paper, SCM chain),
- "Return a font metric satisfying the font-qualifiers in the alist chain @var{chain}.\n"
-"\n"
-"The font object represents the metric information of a font. Every font\n"
-"that is loaded into LilyPond can be accessed via Scheme. \n"
-"\n"
-"LilyPond only needs to know the dimension of glyph to be able to process\n"
-"them. This information is stored in font metric files. LilyPond can read\n"
-"two types of font-metrics: @TeX{} Font Metric files (TFM files) and\n"
-"Adobe Font Metric files (AFM files). LilyPond will always try to load\n"
-"AFM files first since they are more versatile.\n"
-"\n"
-"An alist chain is a list of alists, containing grob properties.\n")
-{
- Paper_def *pap = unsmob_paper (paper);
- SCM_ASSERT_TYPE(pap, paper, SCM_ARG1, __FUNCTION__, "paper definition");
-
- Font_metric*fm = Font_interface::get_font (pap, chain);
- return fm->self_scm();
-}
-
Paper_def*
unsmob_paper (SCM x)
{
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->get_paper (), scm_list_n (alist, SCM_UNDEFINED));
+ fm = select_font (me->get_paper (), scm_list_n (alist, SCM_UNDEFINED));
int lo = 0;
#include "virtual-font-metric.hh"
#include "paper-def.hh"
-
MAKE_SCHEME_CALLBACK(Text_item,interpret_markup,3);
SCM
Text_item::interpret_markup (SCM paper, SCM props, SCM markup)
if (gh_string_p (markup))
{
Paper_def *pap = unsmob_paper (paper);
- Font_metric *fm = Font_interface::get_font (pap, props);
+ Font_metric *fm = select_font (pap, props);
SCM list = scm_list_n (ly_symbol2scm ("text"), markup, SCM_UNDEFINED);
Text_item::brew_molecule (SCM grob)
{
Grob * me = unsmob_grob (grob);
-
+
SCM t = me->get_grob_property ("text");
SCM chain = Font_interface::font_alist_chain (me);
- return interpret_markup (grob, chain, t);
+ return interpret_markup (me->get_paper ()->self_scm (), chain, t);
}
padding = gh_scm2double (itp);
Grob *common = spanner->get_bound (LEFT)->common_refpoint (spanner->get_bound (RIGHT), X_AXIS);
+ Paper_def * paper = me->get_paper();
Interval span_points;
Drul_array<bool> broken;
SCM text = index_get_cell (edge_text, d);
if (Text_item::markup_p (text))
- edge[d] = *unsmob_molecule (Text_item::interpret_markup (smob, properties, text));
+ edge[d] = *unsmob_molecule (Text_item::interpret_markup (paper->self_scm (), properties, text));
if (!edge[d].empty_b ())
edge[d].align_to (Y_AXIS, CENTER);
span_points[LEFT] += gh_scm2double (ly_car (ew));
span_points[RIGHT] -= gh_scm2double (ly_cdr (ew));
}
-
- Real thick = me->get_paper ()->get_realvar (ly_symbol2scm ("linethickness"));
+
+ Real thick = paper->get_realvar (ly_symbol2scm ("linethickness"));
SCM st = me->get_grob_property ("thickness");
if (gh_number_p (st))
{
me->set_grob_property ("font-family", ly_symbol2scm ("number"));
SCM sn =
- Text_item::interpret_markup (me->self_scm(), chain,
+ Text_item::interpret_markup (me->get_paper ()->self_scm(), chain,
scm_makfrom0str (to_string (num).to_str0 ()));
SCM sd =
- Text_item::interpret_markup (me->self_scm(), chain,
+ Text_item::interpret_markup (me->get_paper ()->self_scm(), chain,
scm_makfrom0str (to_string (den).to_str0 ()));
Molecule n = *unsmob_molecule (sn);
Real ly = gh_scm2double (me->get_grob_property ("left-position"));
Real ry = gh_scm2double (me->get_grob_property ("right-position"));
SCM number = me->get_grob_property ("text");
-
+
+ Paper_def *pap = me->get_paper ();
if (gh_string_p (number) && number_visibility)
{
SCM properties = Font_interface::font_alist_chain (me);
- SCM snum = Text_item::interpret_markup (smob, properties, number);
+ SCM snum = Text_item::interpret_markup (pap->self_scm (), properties, number);
Molecule num = *unsmob_molecule (snum);
num.align_to (X_AXIS, CENTER);
num.translate_axis (w/2, X_AXIS);
if (bracket_visibility)
{
- Real lt = me->get_paper ()->get_realvar (ly_symbol2scm ("linethickness"));
+ Real lt = pap->get_realvar (ly_symbol2scm ("linethickness"));
SCM thick = me->get_grob_property ("thickness");
if (gh_number_p (thick))
(strcmp(cs,":|")!=0 && strcmp(cs,"|:")!=0 && strcmp(cs,"|.")!=0
&& strcmp(cs,":|:")!=0 && strcmp(cs,".|")!=0);
- Real staff_thick = me->get_paper ()->get_realvar (ly_symbol2scm ("linethickness"));
+ Paper_def * paper =me->get_paper ();
+ Real staff_thick = paper->get_realvar (ly_symbol2scm ("linethickness"));
Real half_space = 0.5;
Item * bound = dynamic_cast<Spanner*> (me)->get_bound (LEFT);
{
SCM text = me->get_grob_property ("text");
SCM properties = me->get_property_alist_chain (SCM_EOL);
- SCM snum = Text_item::interpret_markup (smob, properties, text);
+ SCM snum = Text_item::interpret_markup (paper->self_scm (), properties, text);
Molecule num = *unsmob_molecule (snum);
mol.add_at_edge (X_AXIS, LEFT, num, - num.extent (X_AXIS).length ()
(font-series . medium)
))
-#(define properties-to-font Font_interface::properties_to_font_name)
(alist (map chord-to-exception-entry elts)))
(filter (lambda (x) (cdr x)) alist)))
-
-(define-public (new-chord-name-brew-molecule grob)
- (let*
- (
- (ws (ly:get-grob-property grob 'word-space))
- (markup (ly:get-grob-property grob 'text))
- (molecule (interpret-markup grob
- (cons '((word-space . 0.0))
- (Font_interface::get_property_alist_chain grob))
- markup))
- )
-
- ;;
- ;; chord names aren't in staffs, so WS is in global staff space.
- (if (number? ws)
- (ly:molecule-combine-at-edge
- molecule
- X RIGHT (ly:make-molecule "" (cons 0 ws) '(-1 . 1) )
- 0.0)
- molecule)
- ))
-
(ChordName
. (
- (molecule-callback . ,new-chord-name-brew-molecule)
+ (molecule-callback . ,Text_item::brew_molecule)
(after-line-breaking-callback . ,Chord_name::after_line_breaking)
- (word-space . 1.0)
+ (word-space . 0.0)
(font-family . roman)
(meta . ((interfaces . (font-interface rhythmic-grob-interface
text-interface chord-name-interface item-interface ))))