]> git.donarmstrong.com Git - lilypond.git/blob - lily/paper-def.cc
(ly_bookpaper_fonts): move from Paperdef
[lilypond.git] / lily / paper-def.cc
1 /*
2   paper-def.cc -- implement Paper_def
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9
10 #include <math.h>
11
12 #include "book-paper-def.hh"
13 #include "virtual-font-metric.hh"
14 #include "all-font-metrics.hh"
15 #include "string.hh"
16 #include "misc.hh"
17 #include "paper-def.hh"
18 #include "warn.hh"
19 #include "scaled-font-metric.hh"
20 #include "main.hh"
21 #include "scm-hash.hh"
22 #include "paper-outputter.hh"
23 #include "ly-module.hh"
24
25 /*
26   This is an almost empty thing. The only substantial thing this class
27   handles is scaling up and down to real-world dimensions (internally
28   dimensions are against global staff-space.)
29  */
30
31 Paper_def::Paper_def ()
32 {
33   bookpaper_ = 0;
34 }
35
36 Paper_def::Paper_def (Paper_def const&src)
37   : Music_output_def (src)
38 {
39   /* Do not remove this statement, scm_make_hash_table may trigger GC.  */
40   bookpaper_ = 0;
41 }
42
43 Paper_def::~Paper_def ()
44 {
45 }
46
47 void
48 Paper_def::derived_mark ()
49 {
50   if (bookpaper_)
51     scm_gc_mark (bookpaper_->self_scm ());
52 }
53
54 Real
55 Paper_def::get_dimension (SCM s) const
56 {
57   SCM val = lookup_variable (s);
58   return ly_scm2double (val);
59 }
60
61 /* FIXME.  This is broken until we have a generic way of
62    putting lists inside the \paper block.  */
63 Interval
64 Paper_def::line_dimensions_int (int n) const
65 {
66   Real lw =  get_dimension (ly_symbol2scm ("linewidth"));
67   Real ind = n? 0.0:get_dimension (ly_symbol2scm ("indent"));
68
69   return Interval (ind, lw);
70 }
71
72 Paper_outputter*
73 Paper_def::get_paper_outputter (String outname) const
74 {
75   progress_indication (_f ("paper output to `%s'...",
76                            outname == "-" ? String ("<stdout>") : outname));
77   return new Paper_outputter (outname);
78
79 }
80
81 Paper_def* 
82 unsmob_paper (SCM x)
83 {
84   return dynamic_cast<Paper_def*> (unsmob_music_output_def (x));
85 }
86   
87
88 LY_DEFINE (ly_paper_def_p, "ly:paper-def?",
89            1, 0, 0, (SCM def),
90            "Is @var{def} a paper definition?")
91 {
92   Paper_def *op = dynamic_cast<Paper_def*> (unsmob_music_output_def (def));
93
94   bool pap = op;
95   return ly_bool2scm (pap);
96 }