]> git.donarmstrong.com Git - lilypond.git/blob - lily/font-interface.cc
Run `make grand-replace'.
[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--2008 Han-Wen Nienhuys <hanwen@xs4all.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->layout (), chain);
26       me->set_property ("font", fm->self_scm ());
27     }
28
29   return fm;
30 }
31
32 SCM
33 Font_interface::music_font_alist_chain (Grob *g)
34 {
35   SCM defaults
36     = g->layout ()->lookup_variable (ly_symbol2scm ("font-defaults"));
37   if (defaults == SCM_UNDEFINED)
38     defaults = SCM_EOL;
39   return g->get_property_alist_chain (defaults);
40 }
41
42 SCM
43 Font_interface::text_font_alist_chain (Grob *g)
44 {
45   SCM defaults
46     = g->layout ()->lookup_variable (ly_symbol2scm ("text-font-defaults"));
47   if (defaults == SCM_UNDEFINED)
48     defaults = SCM_EOL;
49   return g->get_property_alist_chain (defaults);
50 }
51
52 ADD_INTERFACE (Font_interface,
53                "Any symbol that is typeset through fixed sets of glyphs,"
54                " (i.e., fonts).",
55
56                /* properties */
57                "font "
58                "font-encoding "
59                "font-family "
60                "font-name "
61                "font-series "
62                "font-shape "
63                "font-size "
64                );