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