offsets. Fixes overflow errors in the PFA.
* scm/new-markup.scm (strut-markup): change calling interface for
markup. Pass paper-def, not grob. This would \markup to be used
separately from grobs.
* 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>
+
+ * mf/parmesan-clefs.mf: use # quantities for char_box
+ offsets. Fixes overflow errors in the PFA.
+
+ * scm/new-markup.scm (strut-markup): change calling interface for
+ markup. Pass paper-def, not grob. This would \markup to be used
+ separately from grobs.
+
+ * 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 Graham Percival <gperlist@shaw.ca>
* Documentation/user/ tutorial.itely, refman.itely: add warning
#(define (brew-double-time-sig grob)
(define (frac-to-mol font frac)
(let*
- (
- (d (fontify-text font (number->string (cdr frac))))
+ ((d (fontify-text font (number->string (cdr frac))))
(n (fontify-text font (number->string (car frac))))
- (c (ly:molecule-combine-at-edge d Y UP n 0.0))
- )
+ (c (ly:molecule-combine-at-edge d Y UP n 0.0)) )
(ly:molecule-align-to! c Y CENTER)
c
))
(let*
- (
- (chain (Font_interface::get_property_alist_chain grob))
- (font (ly:get-font grob chain))
+ ((chain (Font_interface::get_property_alist_chain grob))
+ (font (ly:paper-get-font (ly:grob-get-paper grob) chain))
(f1 '(6 . 4))
- (musfont (ly:get-font grob (cons (list '(font-relative-size . 2) '(font-family . music)) chain)))
+ (musfont (ly:paper-get-font (ly:grob-get-paper grob) (cons (list '(font-relative-size . 2) '(font-family . music)) chain)))
(plus (ly:molecule-translate-axis (ly:find-glyph-by-name musfont "scripts-stopped") 0.1 Y))
(f2 '(3 . 2))
(m1 (frac-to-mol font f1))
- (m2 (frac-to-mol font f2))
- )
+ (m2 (frac-to-mol font f2)) )
(ly:molecule-combine-at-edge
(ly_symbol2scm ("font-relative-size"),
scm_int2num (-1)), SCM_EOL),
ac);
- fm = Font_interface::get_font (me, ac);
+ fm = Font_interface::get_font (me->get_paper (), ac);
}
else
fm = Font_interface::get_default_font (me);
if (fm)
return fm;
- fm = get_font (me, font_alist_chain (me));
+ fm = get_font (me->get_paper (), font_alist_chain (me));
me->set_grob_property ("font", fm->self_scm ());
return fm;
}
return Font_interface::get_default_font (gr)->self_scm ();
}
-LY_DEFINE(ly_font_interface_get_font,"ly:get-font", 2, 0, 0,
- (SCM grob, 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.\n")
-{
- Grob * gr = unsmob_grob (grob);
- SCM_ASSERT_TYPE(gr, grob, SCM_ARG1, __FUNCTION__, "grob");
-
- Font_metric*fm = Font_interface::get_font (gr, chain);
- return fm->self_scm();
-}
-
Font_metric *
-Font_interface::get_font (Grob *me, SCM chain)
+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)))
{
- Paper_def * p = me->get_paper ();
-
- SCM proc = p->lookup_variable (ly_symbol2scm ("properties-to-font"));
- SCM fonts = p->lookup_variable (ly_symbol2scm ("fonts"));
+ 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);
Real rmag = gh_pair_p (mag) && gh_number_p (gh_cdr (mag))
? gh_scm2double (gh_cdr (mag)) : 1.0;
- Font_metric *fm = me->get_paper ()->find_font (name, rmag);
+ Font_metric *fm = paper->find_font (name, rmag);
return fm;
}
return sc->get_paper () ->lookup_variable (sym);
}
+/* TODO: make difference between scaled and unscalead variable in
+ calling (i.e different funcs.) */
+LY_DEFINE (ly_grob_paper,"ly:grob-paper", 1, 0, 0,
+ (SCM grob),
+ "Get \\paper definition from a grob.")
+{
+ Grob * sc = unsmob_grob (grob);
+ SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob");
+
+ return sc->get_paper ()->self_scm ();
+}
+
+
LY_DEFINE (ly_get_extent, "ly:get-extent", 3, 0, 0,
struct Font_interface
{
static SCM font_alist_chain (Grob*);
- static Font_metric * get_font (Grob*, SCM alist_chain);
+ 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));
friend int yyparse (void*);
};
+Paper_def * unsmob_paper (SCM x);
#endif // Paper_def_HH
ly_symbol2scm ("music")),
SCM_UNDEFINED);
- Font_metric *fm = Font_interface::get_font (me,
+ Font_metric *fm = Font_interface::get_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,alist_chain);
+ = Font_interface::get_font (me->get_paper (), alist_chain);
SCM sml = me->get_grob_property ("use-breve-rest");
if (measures == 1)
#include "paper-outputter.hh"
#include "ly-modules.hh"
-
/*
This is an almost empty thing. The only substantial thing this class
handles, is scaling up and down to real-world dimensions (internally
}
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)
+{
+ return dynamic_cast<Paper_def*> (unsmob_music_output_def (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, scm_list_n (alist, SCM_UNDEFINED));
+ fm = Font_interface::get_font (me->get_paper (), scm_list_n (alist, SCM_UNDEFINED));
int lo = 0;
#include "text-item.hh"
#include "font-interface.hh"
#include "virtual-font-metric.hh"
-
+#include "paper-def.hh"
MAKE_SCHEME_CALLBACK(Text_item,interpret_markup,3);
SCM
-Text_item::interpret_markup (SCM grob, SCM props, SCM markup)
+Text_item::interpret_markup (SCM paper, SCM props, SCM markup)
{
if (gh_string_p (markup))
{
- Grob *me = unsmob_grob (grob);
- Font_metric *fm = Font_interface::get_font (me, props);
+ Paper_def *pap = unsmob_paper (paper);
+ Font_metric *fm = Font_interface::get_font (pap, props);
SCM list = scm_list_n (ly_symbol2scm ("text"), markup, SCM_UNDEFINED);
if (!markup_p (markup))
programming_error ("Markup head has no markup signature.");
- return scm_apply_2 (func, grob, props, args);
+ return scm_apply_2 (func, paper, props, args);
}
else
{
draw zd -- ze;
%right-handed puncta as in do clef
- draw_vaticana_do_clef(exact_center + (0.55reduced_il, 0), reduction);
+ draw_vaticana_do_clef(exact_center + (0.55reduced_il#, 0), reduction);
set_char_box(0 - xpart exact_center,
1.05reduced_il# + xpart exact_center,
draw zc -- zd;
%right-handed puncta as in do clef
- draw_medicaea_do_clef(exact_center + (0.7reduced_il, 0), reduction);
+ draw_medicaea_do_clef(exact_center + (0.7reduced_il#, 0), reduction);
set_char_box(0 - xpart exact_center,
1.7reduced_il# + xpart exact_center,
def draw_hufnagel_do_fa_clef(expr exact_center, reduction) =
draw_hufnagel_do_clef(exact_center, reduction);
- draw_hufnagel_fa_clef(exact_center + (0, -2staff_space), reduction);
+ draw_hufnagel_fa_clef(exact_center + (0, -2staff_space#), reduction);
set_char_box(0 - xpart exact_center,
1.20reduced_il# + xpart exact_center,
1.15reduced_il# + 2staff_space# - ypart exact_center,
-
"
Internally markup is stored as lists, whose head is a function.
;; syntax, description and example.
;;
-(define-public (simple-markup grob props . rest)
- (Text_item::interpret_markup grob props (car rest)))
+(define-public (simple-markup paper props . rest)
+ (Text_item::interpret_markup paper props (car rest)))
(define-public (stack-molecule-line space molecules)
(if (pair? molecules)
'())
)
-(define-public (line-markup grob props . rest)
+(define-public (line-markup paper props . rest)
"A horizontal line of markups. Syntax:
\\line << MARKUPS >>
"
(stack-molecule-line
(cdr (chain-assoc 'word-space props))
- (map (lambda (x) (interpret-markup grob props x)) (car rest)))
+ (map (lambda (x) (interpret-markup paper props x)) (car rest)))
)
-(define-public (combine-markup grob props . rest)
+(define-public (combine-markup paper props . rest)
(ly:molecule-add
- (interpret-markup grob props (car rest))
- (interpret-markup grob props (cadr rest))))
+ (interpret-markup paper props (car rest))
+ (interpret-markup paper props (cadr rest))))
(define (font-markup qualifier value)
- (lambda (grob props . rest)
- (interpret-markup grob (cons (cons `(,qualifier . ,value) (car props)) (cdr props)) (car rest))
+ (lambda (paper props . rest)
+ (interpret-markup paper (cons (cons `(,qualifier . ,value) (car props)) (cdr props)) (car rest))
))
(define-public (set-property-markup qualifier)
- (lambda (grob props . rest )
- (interpret-markup grob
+ (lambda (paper props . rest )
+ (interpret-markup paper
(cons (cons `(,qualifier . ,(car rest))
(car props)) (cdr props))
(cadr rest))
))
-(define-public (finger-markup grob props . rest)
- (interpret-markup grob
+(define-public (finger-markup paper props . rest)
+ (interpret-markup paper
(cons (list '(font-relative-size . -3)
'(font-family . number))
props)
;; TODO: baseline-skip should come from the font.
-(define-public (column-markup grob props . rest)
+(define-public (column-markup paper props . rest)
(stack-lines
-1 0.0 (cdr (chain-assoc 'baseline-skip props))
- (map (lambda (x) (interpret-markup grob props x)) (car rest)))
+ (map (lambda (x) (interpret-markup paper props x)) (car rest)))
)
-(define-public (dir-column-markup grob props . rest)
+(define-public (dir-column-markup paper props . rest)
"Make a column of args, going up or down, depending on DIRECTION."
(let*
(
(stack-lines
(if (number? dir) dir -1)
0.0 (cdr (chain-assoc 'baseline-skip props))
- (map (lambda (x) (interpret-markup grob props x)) (car rest)))
+ (map (lambda (x) (interpret-markup paper props x)) (car rest)))
))
-(define-public (center-markup grob props . rest)
+(define-public (center-markup paper props . rest)
(let*
(
- (mols (map (lambda (x) (interpret-markup grob props x)) (car rest)))
+ (mols (map (lambda (x) (interpret-markup paper props x)) (car rest)))
(cmols (map (lambda (x) (ly:molecule-align-to! x X CENTER)) mols))
)
mols)
))
-(define-public (right-align-markup grob props . rest)
- (let* ((m (interpret-markup grob props (car rest))))
+(define-public (right-align-markup paper props . rest)
+ (let* ((m (interpret-markup paper props (car rest))))
(ly:molecule-align-to! m X RIGHT)
m))
-(define-public (halign-markup grob props . rest)
+(define-public (halign-markup paper props . rest)
"Set horizontal alignment. Syntax: haling A MARKUP. A=-1 is LEFT,
A=1 is right, values in between vary alignment accordingly."
- (let* ((m (interpret-markup grob props (cadr rest))))
+ (let* ((m (interpret-markup paper props (cadr rest))))
(ly:molecule-align-to! m X (car rest))
m))
-(define-public (left-align-markup grob props . rest)
- (let* ((m (interpret-markup grob props (car rest))))
+(define-public (left-align-markup paper props . rest)
+ (let* ((m (interpret-markup paper props (car rest))))
(ly:molecule-align-to! m X RIGHT)
m))
-(define-public (musicglyph-markup grob props . rest)
+(define-public (musicglyph-markup paper props . rest)
(ly:find-glyph-by-name
- (ly:get-font grob (cons '((font-name . ()) (font-family . music)) props))
+ (ly:paper-get-font paper (cons '((font-name . ()) (font-family . music)) props))
(car rest))
)
-(define-public (lookup-markup grob props . rest)
+(define-public (lookup-markup paper props . rest)
"Lookup a glyph by name."
(ly:find-glyph-by-name
- (ly:get-font grob props)
+ (ly:paper-get-font paper props)
(car rest))
)
-(define-public (char-markup grob props . rest)
+(define-public (char-markup paper props . rest)
"Syntax: \\char NUMBER. "
- (ly:get-glyph (ly:get-font grob props) (car rest))
+ (ly:get-glyph (ly:paper-get-font paper props) (car rest))
)
-(define-public (raise-markup grob props . rest)
+(define-public (raise-markup paper props . rest)
"Syntax: \\raise AMOUNT MARKUP. "
(ly:molecule-translate-axis (interpret-markup
- grob
+ paper
props
(cadr rest))
(car rest) Y))
-(define-public (fraction-markup grob props . rest)
+(define-public (fraction-markup paper props . rest)
"Make a fraction of two markups.
Syntax: \\fraction MARKUP1 MARKUP2."
(let*
- ((m1 (interpret-markup grob props (car rest)))
- (m2 (interpret-markup grob props (cadr rest))))
+ ((m1 (interpret-markup paper props (car rest)))
+ (m2 (interpret-markup paper props (cadr rest))))
(ly:molecule-align-to! m1 X CENTER)
(ly:molecule-align-to! m2 X CENTER)
)))
-(define-public (note-markup grob props . rest)
+(define-public (note-markup paper props . rest)
"Syntax: \\note #LOG #DOTS #DIR. By using fractional values
for DIR, you can obtain longer or shorter stems."
(log (car rest))
(dot-count (cadr rest))
(dir (caddr rest))
- (font (ly:get-font grob (cons '((font-family . music)) props)))
+ (font (ly:paper-get-font paper (cons '((font-family . music)) props)))
(stemlen (max 3 (- log 1)))
(headgl
(ly:find-glyph-by-name font (string-append "noteheads-" (number->string (min log 2)))))
stemgl
))
-(define-public (normal-size-super-markup grob props . rest)
+(define-public (normal-size-super-markup paper props . rest)
(ly:molecule-translate-axis (interpret-markup
- grob
+ paper
props (car rest))
(* 0.5 (cdr (chain-assoc 'baseline-skip props)))
Y)
)
-(define-public (super-markup grob props . rest)
+(define-public (super-markup paper props . rest)
"Syntax: \\super MARKUP. "
(ly:molecule-translate-axis (interpret-markup
- grob
+ paper
(cons '((font-relative-size . -2)) props) (car rest))
(* 0.5 (cdr (chain-assoc 'baseline-skip props)))
Y)
)
-(define-public (translate-markup grob props . rest)
+(define-public (translate-markup paper props . rest)
"Syntax: \\translate OFFSET MARKUP. "
- (ly:molecule-translate (interpret-markup grob props (cadr rest))
+ (ly:molecule-translate (interpret-markup paper props (cadr rest))
(car rest))
)
-(define-public (sub-markup grob props . rest)
+(define-public (sub-markup paper props . rest)
"Syntax: \\sub MARKUP."
(ly:molecule-translate-axis (interpret-markup
- grob
+ paper
(cons '((font-relative-size . -2)) props)
(car rest))
(* -0.5 (cdr (chain-assoc 'baseline-skip props)))
Y)
)
-(define-public (normal-size-sub-markup grob props . rest)
+(define-public (normal-size-sub-markup paper props . rest)
(ly:molecule-translate-axis (interpret-markup
- grob
+ paper
props (car rest))
(* -0.5 (cdr (chain-assoc 'baseline-skip props)))
Y)
)
-(define-public (hbracket-markup grob props . rest)
+(define-public (hbracket-markup paper props . rest)
"Horizontal brackets around its single argument. Syntax \\hbracket MARKUP."
(let*
(
(th 0.1) ;; todo: take from GROB.
- (m (interpret-markup grob props (car rest)))
+ (m (interpret-markup paper props (car rest)))
)
(bracketify-molecule m X th (* 2.5 th) th)
))
-(define-public (bracket-markup grob props . rest)
+(define-public (bracket-markup paper props . rest)
"Vertical brackets around its single argument. Syntax \\bracket MARKUP."
(let*
(
(th 0.1) ;; todo: take from GROB.
- (m (interpret-markup grob props (car rest)))
+ (m (interpret-markup paper props (car rest)))
)
(bracketify-molecule m Y th (* 2.5 th) th)
))
;; todo: fix negative space
-(define (hspace-markup grob props . rest)
+(define (hspace-markup paper props . rest)
"Syntax: \\hspace NUMBER."
(let*
((amount (car rest)))
(ly:make-molecule "" (cons amount amount) '(-1 . 1)))
))
-(define-public (override-markup grob props . rest)
+(define-public (override-markup paper props . rest)
"Tack the 1st arg in REST onto PROPS, e.g.
\override #'(font-family . married) \"bla\"
"
- (interpret-markup grob (cons (list (car rest)) props)
+ (interpret-markup paper (cons (list (car rest)) props)
(cadr rest)))
-(define-public (smaller-markup grob props . rest)
+(define-public (smaller-markup paper props . rest)
"Syntax: \\smaller MARKUP"
(let*
(
(entry (cons 'font-relative-size (- fs 1)))
)
(interpret-markup
- grob (cons (list entry) props)
+ paper (cons (list entry) props)
(car rest))
))
-(define-public (bigger-markup grob props . rest)
+(define-public (bigger-markup paper props . rest)
"Syntax: \\bigger MARKUP"
(let*
(
(entry (cons 'font-relative-size (+ fs 1)))
)
(interpret-markup
- grob (cons (list entry) props)
+ paper (cons (list entry) props)
(car rest))
))
-(define-public (box-markup grob props . rest)
+(define-public (box-markup paper props . rest)
"Syntax: \\box MARKUP"
(let*
(
(th 0.1)
(pad 0.2)
- (m (interpret-markup grob props (car rest)))
+ (m (interpret-markup paper props (car rest)))
)
(box-molecule m th pad)
))
-(define-public (strut-markup grob props . rest)
+(define-public (strut-markup paper props . rest)
"Syntax: \strut
A box of the same height as the space.
"
(let*
- ((m (Text_item::interpret_markup grob props " ")))
+ ((m (Text_item::interpret_markup paper props " ")))
(ly:molecule-set-extent! m 0 '(1000 . -1000))
m))
conversions.append (((1,9,5), conv, 'HaraKiriVerticalGroup -> RemoveEmptyVerticalGroup'))
+def conv (str):
+ if re.search ("ly:get-font", str):
+ sys.stderr.write (r"(ly:get-font foo ..) has been replaced by" + \
+ " (ly:paper-get-font (ly:grob-get-paper foo) .. ).\n" +\
+ "please update manually.")
+
+ raise FatalConversionError()
+ return str
+
+
+conversions.append (((1,9,6), conv, 'ly:get-font deprecated.'))
+
################################
# END OF CONVERSIONS
################################