]> git.donarmstrong.com Git - lilypond.git/blob - lily/font-interface.cc
* lily/bar-line.cc (compound_barline): fix : for staff without
[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--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "all-font-metrics.hh"
10 #include "font-metric.hh"
11 #include "font-interface.hh"
12 #include "grob.hh"
13 #include "output-def.hh"
14 #include "warn.hh"
15
16
17 /* todo: split up this func, reuse in text_item?  */
18 Font_metric *
19 Font_interface::get_default_font (Grob *me)
20 {
21   Font_metric *fm = unsmob_metrics (me->get_property ("font"));
22   if (!fm)
23     {
24       SCM chain = music_font_alist_chain (me);
25       
26       fm = select_font (me->get_paper (), chain);
27       me->set_property ("font", fm->self_scm ());
28     }
29   
30   return fm;
31 }
32
33 LY_DEFINE (ly_font_interface_get_default_font, "ly:get-default-font",
34           1 , 0, 0, (SCM grob),
35           "Return the default font for grob @var{gr}.")
36 {
37   Grob *gr = unsmob_grob (grob);
38   SCM_ASSERT_TYPE (gr, grob, SCM_ARG1, __FUNCTION__, "grob");
39
40   return Font_interface::get_default_font (gr)->self_scm ();
41 }
42
43
44 SCM
45 Font_interface::music_font_alist_chain (Grob *g)
46 {
47   SCM defaults
48     = g->get_paper ()->lookup_variable (ly_symbol2scm ("font-defaults"));
49   return g->get_property_alist_chain (defaults);
50 }
51
52 SCM
53 Font_interface::text_font_alist_chain (Grob *g)
54 {
55   SCM defaults
56     = g->get_paper ()->lookup_variable (ly_symbol2scm ("text-font-defaults"));
57   return g->get_property_alist_chain (defaults);
58 }
59
60 ADD_INTERFACE (Font_interface, "font-interface",
61                "Any symbol that is typeset through fixed sets of glyphs, "
62                " (ie. fonts)",
63                "font-magnification font font-series font-shape "
64                "font-family font-encoding font-name font-size");