]> git.donarmstrong.com Git - lilypond.git/blob - lily/font-interface.cc
release: 1.3.100
[lilypond.git] / lily / font-interface.cc
1 /*   
2   font-interface.cc --  implement Font_interface
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #include "all-font-metrics.hh"
11 #include "font-metric.hh"
12 #include "font-interface.hh"
13 #include "score-element.hh"
14 #include "paper-def.hh"
15
16 /*
17   todO : split up this func, reuse in text_item? 
18  */
19 Font_metric *
20 Font_interface::get_default_font (Score_element*me)
21 {
22   Font_metric * fm =  unsmob_metrics (me->get_elt_property ("font"));
23   if (fm)
24     return fm;
25
26   SCM ss = me->paper_l ()->style_sheet_;
27
28   SCM proc = gh_cdr (scm_assoc (ly_symbol2scm ("properties-to-font"),
29                                 ss));
30
31   SCM fonts = gh_cdr (scm_assoc (ly_symbol2scm ("fonts"), ss));
32   SCM defaults = gh_cdr (scm_assoc (ly_symbol2scm ("font-defaults"),
33                                     ss));
34
35   assert (gh_procedure_p (proc));
36   SCM font_name = gh_call2 (proc, fonts,
37                             gh_list (me->mutable_property_alist_,
38                                      me->immutable_property_alist_,
39                                      defaults,
40                                      SCM_UNDEFINED));
41
42   fm = me->paper_l ()->find_font (font_name, 1.0);
43   me->set_elt_property ("font", fm->self_scm ());
44   return fm;
45 }