+2004-05-17 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+
+ * lily/book-paper-def.cc (ly_bookpaper_fonts): move from Paperdef
+ (find_scaled_font): move from Paper_def
+
+2004-05-16 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * lily/my-lily-parser.cc (LY_DEFINE): new function ly_parser_lookup
+ (LY_DEFINE): add SCM_ASSERT_TYPE everywhere.
+
+ * po/fr.po: update po.
+
+ * lily/include/book-paper-def.hh (class Book_paper_def): new file.
+
+ * lily/book-paper-def.cc (print_smob): new file.
+
2004-05-16 Heikki Junes <hjunes@cc.hut.fi>
* buildscripts/lilypond-words.py: search words also from
--- /dev/null
+/*
+ book-paper-def.cc -- implement Book_paper_def
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+*/
+
+#include "paper-def.hh"
+#include "dimensions.hh"
+#include "book-paper-def.hh"
+#include "ly-smobs.icc"
+#include "font-metric.hh"
+#include "virtual-font-metric.hh"
+#include "scaled-font-metric.hh"
+
+IMPLEMENT_SMOBS (Book_paper_def);
+IMPLEMENT_DEFAULT_EQUAL_P (Book_paper_def);
+
+
+SCM
+Book_paper_def::mark_smob (SCM m)
+{
+ Book_paper_def * mo = (Book_paper_def*) SCM_CELL_WORD_1 (m);
+
+ return mo->scaled_fonts_;
+}
+
+Font_metric*
+Book_paper_def::find_scaled_font (Font_metric *f, Real m, SCM input_enc_name)
+{
+ Real lookup_mag = m;
+ if (!dynamic_cast<Virtual_font_metric*> (f))
+ {
+ lookup_mag /= output_scale_;
+ }
+
+ SCM sizes = scm_hashq_ref (scaled_fonts_, f->self_scm (), SCM_BOOL_F);
+ if (sizes != SCM_BOOL_F)
+ {
+ SCM met = scm_assoc (scm_make_real (lookup_mag), sizes);
+ if (ly_c_pair_p (met))
+ return unsmob_metrics (ly_cdr (met));
+ }
+ else
+ sizes = SCM_EOL;
+
+ /* Hmm. We're chaining font - metrics. Should consider whether to
+ merge virtual-font and scaled_font. */
+ SCM val = SCM_EOL;
+ if (Virtual_font_metric * vf = dynamic_cast<Virtual_font_metric*> (f))
+ {
+ /*
+ For fontify_atom (), the magnification and name must be known
+ at the same time. That's impossible for
+
+ Scaled (Virtual_font (Font1,Font2))
+
+ so we replace by
+
+ Virtual_font (Scaled (Font1), Scaled (Font2))
+
+ */
+
+ SCM lst = SCM_EOL;
+ SCM *t = &lst;
+ for (SCM s = vf->get_font_list (); ly_c_pair_p (s); s = ly_cdr (s))
+ {
+ Font_metric *scaled = find_scaled_font (unsmob_metrics (ly_car (s)),
+ m, input_enc_name);
+ *t = scm_cons (scaled->self_scm (), SCM_EOL);
+ t = SCM_CDRLOC(*t);
+ }
+
+ vf = new Virtual_font_metric (lst);
+ val = vf->self_scm ();
+ }
+ else
+ {
+ if (!ly_c_symbol_p (input_enc_name))
+ {
+#if 0
+ /* FIXME.*/
+ SCM var = ly_module_lookup (scope_, ly_symbol2scm ("inputencoding"));
+ input_enc_name = scm_variable_ref (var);
+
+#endif
+ input_enc_name = ly_symbol2scm ("latin1");
+ }
+
+ val = Modified_font_metric::make_scaled_font_metric (input_enc_name,
+ f, lookup_mag);
+ }
+
+ sizes = scm_acons (scm_make_real (lookup_mag), val, sizes);
+ scm_gc_unprotect_object (val);
+ scm_hashq_set_x (scaled_fonts_, f->self_scm (), sizes);
+ return unsmob_metrics (val);
+}
+
+
+
+Book_paper_def::Book_paper_def ()
+{
+ output_scale_ = 1.0;
+ scaled_fonts_ = SCM_EOL;
+ smobify_self ();
+ scaled_fonts_ = scm_c_make_hash_table (11);
+}
+
+Book_paper_def::~Book_paper_def ()
+{
+}
+
+
+
+
+LY_DEFINE(ly_make_bookpaper, "ly:make-bookpaper",
+ 1,0,0,
+ (SCM size),
+ "Make a paperbook, for staff space SIZE, which is in INTERNAL_UNIT.")
+{
+ Book_paper_def * bp = new Book_paper_def ;
+
+ SCM_ASSERT_TYPE(ly_c_number_p (size), size,
+ SCM_ARG1, __FUNCTION__, "number");
+
+
+ bp->output_scale_ = (ly_scm2double (size)) MM;
+
+ return scm_gc_unprotect_object (bp->self_scm ());
+}
+
+
+LY_DEFINE(ly_bookpaper_fonts, "ly:bookpaper-fonts",
+ 1,0,0,
+ (SCM bp),
+ "Return fonts scaled up BP")
+{
+ Book_paper_def * b = unsmob_bookpaper (bp);
+
+ SCM_ASSERT_TYPE(b, bp,
+ SCM_ARG1, __FUNCTION__, "bookpaper");
+
+ SCM func = ly_scheme_function ("hash-table->alist");
+
+ SCM l = SCM_EOL;
+ for (SCM s = scm_call_1 (func, b->scaled_fonts_); ly_c_pair_p (s); s = ly_cdr (s))
+ {
+ SCM entry = ly_car (s);
+ for (SCM t = ly_cdr (entry); ly_c_pair_p (t); t = ly_cdr (t))
+ {
+ Font_metric *fm= unsmob_metrics (ly_cdar (t));
+
+ if (dynamic_cast<Modified_font_metric*> (fm))
+ l = scm_cons (fm->self_scm (), l);
+ }
+ }
+ return l;
+}
+
+
+LY_DEFINE(ly_bookpaper_outputscale, "ly:bookpaper-outputscale",
+ 1,0,0,
+ (SCM bp),
+ "Get outputscale for BP.")
+{
+ Book_paper_def * b = unsmob_bookpaper (bp);
+
+ SCM_ASSERT_TYPE(b, bp,
+ SCM_ARG1, __FUNCTION__, "bookpaper");
+ return scm_make_real (b->output_scale_);
+}
+
+int
+Book_paper_def::print_smob (SCM s, SCM p, scm_print_state*)
+{
+ scm_puts ("#<Book_paper>", p);
+ return 1;
+}
+
+
+Paper_def *
+Book_paper_def::scale_paper (Paper_def* pd) const
+{
+ SCM proc = ly_scheme_function ("scale-paper");
+ SCM new_pap = scm_call_2 (proc, pd->self_scm (), self_scm ());
+
+ scm_gc_protect_object (new_pap);
+
+ Paper_def* p = unsmob_paper (new_pap);
+
+ p->bookpaper_ = (Book_paper_def*) this;
+ return p;
+}
#include <stdio.h>
+#include "book-paper-def.hh"
#include "ly-smobs.icc"
#include "stencil.hh"
#include "book.hh"
Book::Book ()
: Input ()
{
+ bookpaper_ = 0;
header_ = SCM_EOL;
assert (!scores_.size ());
smobify_self ();
int score_count = book->scores_.size ();
for (int i = 0; i < score_count; i++)
scm_gc_mark (book->scores_[i]->self_scm ());
+
+ if (book->bookpaper_)
+ scm_gc_mark (book->bookpaper_->self_scm ());
return book->header_;
}
for (int i = 0; i < score_count; i++)
{
Paper_def *paper = 0;
- SCM systems = scores_[i]->book_rendering (outname, default_def, &paper);
+ SCM systems = scores_[i]->book_rendering (outname,
+ bookpaper_,
+ default_def, &paper);
if (systems != SCM_UNDEFINED)
{
Score_lines sc;
sc.paper_ = paper;
sc.lines_ = systems;
- sc.header_ =header;
+ sc.header_ = header;
paper_book->score_lines_.push (sc);
}
for (int i = 0; i < score_count; i++)
{
Paper_def *paper = 0;
- SCM systems = scores_[i]->book_rendering ("<markup>", default_def,
+ SCM systems = scores_[i]->book_rendering ("<markup>",
+ bookpaper_,
+ default_def,
&paper);
if (systems != SCM_UNDEFINED)
{
#include <math.h>
+#include "book-paper-def.hh"
#include "all-font-metrics.hh"
#include "paper-def.hh"
#include "font-interface.hh"
}
Font_metric *fm = unsmob_metrics (scm_force (SCM_VECTOR_REF (font_vector, i)));
- return paper->find_scaled_font (fm, requested / size, input_encoding_name);
+ return paper->bookpaper_->find_scaled_font (fm, requested / size, input_encoding_name);
+
}
Font_metric * fm = all_fonts_global->find_font (ly_scm2string (name));
- return paper->find_scaled_font (fm, rmag, encoding_name);
+ return paper->bookpaper_->find_scaled_font (fm, rmag, encoding_name);
}
else if (scm_instance_p (name))
{
return 0;
}
-
-
Font_metric *
select_font (Paper_def *paper, SCM chain)
{
public:
SCM header_;
+ Book_paper_def *bookpaper_;
+
Link_array<Score> scores_;
-
Book ();
void process (String outname, Music_output_def*, SCM header);
#define CHAR *CHAR_TO_PT *PT_TO_MM
#define INTERNAL_UNIT "mm"
+
#endif
String print_dimen (Real);
class Bezier;
class Bezier_bow;
class Book;
+class Book_paper_def;
class Break_algorithm;
class Change_iterator;
class Change_translator;
{
protected:
VIRTUAL_COPY_CONSTRUCTOR (Music_output_def, Paper_def);
- SCM scaled_fonts_;
-public:
+public:
+ Book_paper_def * bookpaper_;
static int score_count_;
Paper_def ();
SCM output_module_;
Protected_scm file_;
String filename_;
- Paper_def * paper_ ; // THIS IS BROKEN.
void output_expr (SCM expr, Offset o);
- void output_metadata (Paper_def*, SCM);
+ void output_metadata (Book_paper_def*, SCM);
void output_music_output_def (Music_output_def* odef);
public:
void dump_scheme (SCM);
void output_scheme (SCM scm);
void output_stencil (Stencil);
- void output_header (Paper_def*, SCM, int, bool);
+ void output_header (Book_paper_def*, SCM, int, bool);
void output_line (SCM, Offset*, bool);
void output_page (Page*, bool);
};
Score ();
Score (Score const&);
- SCM book_rendering (String, Music_output_def*, Paper_def**);
+ SCM book_rendering (String, Book_paper_def*, Music_output_def*, Paper_def**);
};
+
DECLARE_UNSMOB (Score, score);
SCM ly_run_translator (SCM, SCM);
SCM ly_render_output (SCM, SCM);
-void default_rendering (SCM, SCM, SCM, SCM);
+void default_rendering (SCM, SCM, SCM, SCM, SCM);
#endif /* SCORE_HH */
--- /dev/null
+/*
+ scaled-font-metric.cc -- declare Modified_font_metric
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1999--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+ */
+
+#include <ctype.h>
+
+#include "warn.hh"
+#include "scaled-font-metric.hh"
+#include "string.hh"
+#include "stencil.hh"
+
+Modified_font_metric::Modified_font_metric (String coding, Font_metric* m, Real magn)
+{
+ coding_vector_ = SCM_EOL;
+ coding_mapping_ = SCM_EOL;
+ coding_table_ = SCM_EOL;
+ coding_description_ = SCM_EOL;
+
+ coding_scheme_ = coding;
+ magnification_ = magn;
+
+ SCM desc = m->description_;
+
+ Real total_mag = magn * ly_scm2double (ly_cdr (desc));
+ assert (total_mag);
+
+ description_ = scm_cons (ly_car (desc), scm_make_real (total_mag));
+ orig_ = m;
+
+ if (coding_scheme_ != "TeX"
+ && coding_scheme_ != "ASCII"
+ && coding_scheme_ != orig_->coding_scheme ())
+ {
+ coding_vector_ = scm_call_1 (ly_scheme_function ("get-coding-vector"),
+ scm_makfrom0str (coding_scheme_.to_str0 ()));
+
+ if (!ly_c_vector_p (coding_vector_))
+ {
+ programming_error ("get-coding-vector should return vector");
+ coding_vector_ = scm_c_make_vector (256, ly_symbol2scm (".notdef"));
+ }
+
+
+ coding_table_ = scm_call_1 (ly_scheme_function ("get-coding-table"),
+ scm_makfrom0str (orig_->coding_scheme ().to_str0 ()));
+
+ coding_mapping_ = scm_call_2 (ly_scheme_function ("make-encoding-mapping"),
+ coding_vector_,
+ coding_table_);
+
+ coding_description_= SCM_EOL;
+
+ coding_description_ = scm_acons (ly_symbol2scm ("input-name"),
+ scm_makfrom0str (coding_scheme_.to_str0 ()),
+ coding_description_);
+
+ coding_description_ = scm_acons (ly_symbol2scm ("input-vector"),
+ coding_vector_, coding_description_);
+ coding_description_ = scm_acons (ly_symbol2scm ("output-name"),
+ scm_makfrom0str (orig_->coding_scheme ().to_str0 ()),
+ coding_description_);
+ coding_description_ = scm_acons (ly_symbol2scm ("output-table"),
+ coding_table_,
+ coding_description_);
+
+ coding_description_ = scm_acons (ly_symbol2scm ("char-mapping"),
+ coding_mapping_,
+ coding_description_);
+ }
+}
+
+
+
+LY_DEFINE (ly_font_encoding_alist, "ly:font-encoding-alist",
+ 1, 0, 0,
+ (SCM font),
+ "Given the Modified_font_metric @var{font}, return an "
+ "alist. Keys are input-name, input-vector, "
+ "output-name, output-table, mapping.")
+{
+ Modified_font_metric *fm
+ = dynamic_cast<Modified_font_metric*> (unsmob_metrics (font));
+
+ SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "Modified_font_metric");
+ return fm->coding_description_;
+}
+
+SCM
+Modified_font_metric::make_scaled_font_metric (SCM coding, Font_metric *m, Real s)
+{
+ /*
+ UGOHR.
+ */
+ if (ly_c_symbol_p (coding))
+ coding = scm_symbol_to_string (coding);
+
+ String scheme = ly_scm2string (coding);
+
+ Modified_font_metric *sfm = new Modified_font_metric (scheme, m, s);
+
+ return sfm->self_scm ();
+}
+
+Real
+Modified_font_metric::design_size () const
+{
+ return orig_->design_size ();
+}
+
+
+Box
+Modified_font_metric::get_indexed_char (int i) const
+{
+ Box b = orig_->get_indexed_char (i);
+ b.scale (magnification_);
+ return b;
+}
+
+Box
+Modified_font_metric::get_ascii_char (int i) const
+{
+ Box b = orig_->get_ascii_char (i);
+ b.scale (magnification_);
+ return b;
+}
+
+int
+Modified_font_metric::count () const
+{
+ return orig_->count ();
+}
+
+Offset
+Modified_font_metric::get_indexed_wxwy (int k) const
+{
+ Offset o = orig_->get_indexed_wxwy (k);
+ return o * magnification_;
+}
+
+int
+Modified_font_metric::name_to_index (String s) const
+{
+ return orig_->name_to_index (s);
+}
+
+int
+Modified_font_metric::index_to_ascii (int k) const
+{
+ return orig_->index_to_ascii (k);
+}
+
+String
+Modified_font_metric::coding_scheme () const
+{
+ return coding_scheme_;
+}
+
+void
+Modified_font_metric::derived_mark () const
+{
+ scm_gc_mark (coding_vector_);
+ scm_gc_mark (coding_description_);
+ scm_gc_mark (coding_table_);
+ scm_gc_mark (coding_mapping_);
+}
+
+Box
+Modified_font_metric::tex_kludge (String text) const
+{
+ Interval ydims;
+ Real w=0.0;
+
+ /*
+ TODO: put this klutchness behind ly:option switch.
+ */
+ for (int i = 0; i < text.length (); i++)
+ {
+ switch (text[i])
+ {
+ case '\\':
+ // accent marks use width of base letter
+ if (i +1 < text.length ())
+ {
+ if (text[i+1]=='\'' || text[i+1]=='`' || text[i+1]=='"' ||
+ text[i+1]=='^')
+ {
+ i++;
+ break;
+ }
+ // for string width \\ is a \ and \_ is a _.
+ if (text[i+1]=='\\' || text[i+1]=='_')
+ {
+ break;
+ }
+ }
+
+ for (i++; (i < text.length ()) && !isspace (text[i])
+ && text[i]!='{' && text[i]!='}'; i++)
+ ;
+
+ // ugh.
+ i--; // Compensate for the increment in the outer loop!
+ break;
+ case '{': // Skip '{' and '}'
+ case '}':
+ break;
+
+ default:
+ Box b = get_ascii_char ((unsigned char)text[i]);
+
+ // Ugh, use the width of 'x' for unknown characters
+ if (b[X_AXIS].length () == 0)
+ b = get_ascii_char ((unsigned char)'x');
+
+ w += b[X_AXIS].length ();
+ ydims.unite (b[Y_AXIS]);
+ break;
+ }
+ }
+
+ if (ydims.is_empty ())
+ ydims = Interval (0, 0);
+
+ return Box (Interval (0, w), ydims);
+}
+
+Box
+Modified_font_metric::text_dimension (String text)
+{
+ Box b;
+ if (coding_scheme_ == "TeX")
+ {
+ b = tex_kludge (text);
+ }
+ else if (coding_scheme_ == "ASCII"
+ || coding_scheme_ == orig_->coding_scheme ())
+ {
+ Interval ydims;
+
+ Real w=0.0;
+
+ for (int i = 0; i < text.length (); i++)
+ {
+ Box b = get_ascii_char ((unsigned char)text[i]);
+
+ w += b[X_AXIS].length ();
+ ydims.unite (b[Y_AXIS]);
+ }
+ if (ydims.is_empty ())
+ ydims = Interval (0, 0);
+
+ b = Box(Interval(0,w), ydims);
+ }
+ else
+ {
+ Interval ydims;
+ Real w = 0.0;
+
+ for (int i = 0; i < text.length (); i++)
+ {
+ SCM sym = scm_vector_ref (coding_vector_,
+ SCM_MAKINUM((unsigned char) text[i]));
+
+ Box char_box;
+
+ if (!ly_c_symbol_p (sym))
+ continue;
+
+ char const * chars = SCM_SYMBOL_CHARS(sym);
+
+ int idx = orig_->name_to_index (chars);
+ if (idx >= 0)
+ {
+ char_box = orig_->get_indexed_char (idx);
+ }
+
+ char_box.scale (magnification_);
+ if (!char_box[X_AXIS].is_empty ())
+ w += char_box[X_AXIS][RIGHT]; // length ?
+
+ ydims.unite (char_box[Y_AXIS]);
+ }
+
+ if (ydims.is_empty ())
+ ydims = Interval (0, 0);
+
+
+ b = Box (Interval (0, w), ydims);
+ }
+
+ return b;
+}
+
+Font_metric*
+Modified_font_metric::original_font () const
+{
+ return orig_;
+}
*/
#include "book.hh"
+#include "book-paper-def.hh"
#include "file-name.hh"
#include "file-path.hh"
#include "lily-version.hh"
(SCM parser_smob, SCM symbol, SCM val),
"Bind SYMBOL to VAL in PARSER_SMOB's module.")
{
- SCM_ASSERT_TYPE (ly_c_symbol_p (symbol), symbol, SCM_ARG1, __FUNCTION__, "symbol");
My_lily_parser *parser = unsmob_my_lily_parser (parser_smob);
+ SCM_ASSERT_TYPE (ly_c_symbol_p (symbol), symbol, SCM_ARG2, __FUNCTION__, "symbol");
+ SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG2, __FUNCTION__, "parser");
+
+
parser->lexer_->set_identifier (scm_symbol_to_string (symbol), val);
return SCM_UNSPECIFIED;
}
+LY_DEFINE(ly_parser_lookup, "ly:parser-lookup",
+ 2, 0, 0,
+ (SCM parser_smob, SCM symbol),
+ "Lookup @var{symbol} in @var{parser_smob}'s module. Undefined is '().")
+{
+ My_lily_parser *parser = unsmob_my_lily_parser (parser_smob);
+
+ SCM_ASSERT_TYPE (ly_c_symbol_p (symbol), symbol, SCM_ARG2, __FUNCTION__, "symbol");
+ SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG2, __FUNCTION__, "parser");
+
+ SCM val= parser->lexer_->lookup_identifier (ly_scm2string (scm_symbol_to_string (symbol)));
+ if (val != SCM_UNDEFINED)
+ return val;
+ else
+ return SCM_EOL;
+}
LY_DEFINE (ly_parser_parse_string, "ly:parser-parse-string",
2, 0, 0,
"Parse the string LY_CODE with PARSER_SMOB."
"Upon failure, throw @code{ly-file-failed} key.")
{
-#if 0
- SCM_ASSERT_TYPE (ly_c_parser_p (parser), music, SCM_ARG1, __FUNCTION__, "parser");
-#endif
- SCM_ASSERT_TYPE (ly_c_string_p (ly_code), ly_code, SCM_ARG1, __FUNCTION__, "string");
-#if 1
My_lily_parser *parser = unsmob_my_lily_parser (parser_smob);
+
+ SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG1, __FUNCTION__, "parser");
+ SCM_ASSERT_TYPE (ly_c_string_p (ly_code), ly_code, SCM_ARG2, __FUNCTION__, "string");
+
parser->parse_string (ly_scm2string (ly_code));
-#else
- My_lily_parser *parser = unsmob_my_lily_parser (parser_smob);
- My_lily_parser *clone = new My_lily_parser (*parser);
- clone->parse_string (ly_scm2string (ly_code));
- clone = 0;
-#endif
return SCM_UNSPECIFIED;
}
return paper ? paper->clone () : new Paper_def;
}
+
+Book_paper_def*
+get_bookpaper (My_lily_parser *parser)
+{
+ SCM id = parser->lexer_->lookup_identifier ("$defaultbookpaper");
+ Book_paper_def *paper = unsmob_bookpaper (id);
+ return paper->clone ();
+}
+
+
+/*
+ TODO: move this to Scheme? Why take the parser arg, and all the back
+ & forth between scm and c++?
+ */
LY_DEFINE (ly_parser_print_score, "ly:parser-print-score",
2, 0, 0,
(SCM parser_smob, SCM score_smob),
"Print score, i.e., the classic way.")
{
-#if 0
- SCM_ASSERT_TYPE (ly_c_parser_p (parser), music, SCM_ARG1, __FUNCTION__, "parser");
- SCM_ASSERT_TYPE (ly_c_music_p (music), music, SCM_ARG1, __FUNCTION__, "music");
-#endif
My_lily_parser *parser = unsmob_my_lily_parser (parser_smob);
Score *score = unsmob_score (score_smob);
+ SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG1, __FUNCTION__, "parser");
+ SCM_ASSERT_TYPE (score, score_smob, SCM_ARG2, __FUNCTION__, "score");
+
SCM header = is_module (score->header_) ? score->header_
: parser->header_.to_SCM ();
SCM os = scm_makfrom0str (outname.to_string ().to_str0 ());
for (int i = 0; i < score->defs_.size (); i++)
- default_rendering (score->music_, score->defs_[i]->self_scm (), header,
- os);
+ default_rendering (score->music_, score->defs_[i]->self_scm (),
+ get_bookpaper (parser)->self_scm (),
+ header, os);
if (score->defs_.is_empty ())
{
Music_output_def *paper = get_paper (parser);
- default_rendering (score->music_, paper->self_scm (), header, os);
+ default_rendering (score->music_, paper->self_scm (),
+ get_bookpaper (parser)->self_scm (),
+ header, os);
scm_gc_unprotect_object (paper->self_scm ());
}
return SCM_UNDEFINED;
(SCM parser_smob, SCM book_smob),
"Print book.")
{
-#if 0
- SCM_ASSERT_TYPE (ly_c_parser_p (parser_smob), parser_smob, SCM_ARG1, __FUNCTION__, "parser_smob");
- SCM_ASSERT_TYPE (ly_c_music_p (book_smob), book_smob, SCM_ARG1, __FUNCTION__, "book_smob");
-#endif
My_lily_parser *parser = unsmob_my_lily_parser (parser_smob);
Book *book = unsmob_book (book_smob);
+ Book_paper_def *bp = unsmob_bookpaper (parser->lexer_->lookup_identifier ("$defaultbookpaper"));
+
+ SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG1, __FUNCTION__, "Lilypond parser");
+ SCM_ASSERT_TYPE (book, book_smob, SCM_ARG2, __FUNCTION__, "Book");
+
+ book->bookpaper_ = bp; // ugh. changing argument.
SCM header = parser->header_;
File_name outname (parser->output_basename_);
Paper_def *paper = score_lines_[0].paper_;
Paper_outputter *out = paper->get_paper_outputter (outname);
int page_count = scm_ilength (pages);
- out->output_header (paper, scopes (0), page_count, false);
+ out->output_header (paper->bookpaper_, scopes (0), page_count, false);
for (SCM s = pages; s != SCM_EOL; s = ly_cdr (s))
{
int count = score_lines_.size ();
Paper_def * p = score_lines_.top ().paper_;
Paper_outputter *out = p->get_paper_outputter (outname);
- out->output_header (p, scopes (count - 1), 0, true);
+ out->output_header (p->bookpaper_, scopes (count - 1), 0, true);
SCM top_lines = score_lines_.top ().lines_;
Paper_line *first = unsmob_paper_line (scm_vector_ref (top_lines,
#include <math.h>
+#include "book-paper-def.hh"
#include "virtual-font-metric.hh"
#include "all-font-metrics.hh"
#include "string.hh"
Paper_def::Paper_def ()
{
- /* Do not remove this statement, scm_make_hash_table may trigger GC. */
- scaled_fonts_ = SCM_EOL;
- scaled_fonts_ = scm_c_make_hash_table (11);
+ bookpaper_ = 0;
}
Paper_def::Paper_def (Paper_def const&src)
: Music_output_def (src)
{
/* Do not remove this statement, scm_make_hash_table may trigger GC. */
- scaled_fonts_ = SCM_EOL;
- scaled_fonts_ = scm_c_make_hash_table (11);
+ bookpaper_ = 0;
}
Paper_def::~Paper_def ()
void
Paper_def::derived_mark ()
{
- scm_gc_mark (scaled_fonts_);
+ if (bookpaper_)
+ scm_gc_mark (bookpaper_->self_scm ());
}
Real
Paper_def::get_dimension (SCM s) const
{
SCM val = lookup_variable (s);
- SCM scale = lookup_variable (ly_symbol2scm ("outputscale"));
-
- Real sc = ly_scm2double (scale);
- return ly_scm2double (val) / sc;
+ return ly_scm2double (val);
}
/* FIXME. This is broken until we have a generic way of
progress_indication (_f ("paper output to `%s'...",
outname == "-" ? String ("<stdout>") : outname));
return new Paper_outputter (outname);
-}
-
-Font_metric*
-Paper_def::find_scaled_font (Font_metric *f, Real m, SCM input_enc_name)
-{
- SCM scale_var = SCM_EOL;
- Real lookup_mag = m;
- if (!dynamic_cast<Virtual_font_metric*> (f))
- {
- scale_var = ly_module_lookup (scope_, ly_symbol2scm ("outputscale"));
- lookup_mag /= ly_scm2double (scm_variable_ref (scale_var));
- }
-
- SCM sizes = scm_hashq_ref (scaled_fonts_, f->self_scm (), SCM_BOOL_F);
- if (sizes != SCM_BOOL_F)
- {
- SCM met = scm_assoc (scm_make_real (lookup_mag), sizes);
- if (ly_c_pair_p (met))
- return unsmob_metrics (ly_cdr (met));
- }
- else
- sizes = SCM_EOL;
-
- /* Hmm. We're chaining font - metrics. Should consider whether to
- merge virtual-font and scaled_font. */
- SCM val = SCM_EOL;
- if (Virtual_font_metric * vf = dynamic_cast<Virtual_font_metric*> (f))
- {
- /*
- For fontify_atom (), the magnification and name must be known
- at the same time. That's impossible for
-
- Scaled (Virtual_font (Font1,Font2))
-
- so we replace by
-
- Virtual_font (Scaled (Font1), Scaled (Font2))
-
- */
-
- SCM lst = SCM_EOL;
- SCM *t = &lst;
- for (SCM s = vf->get_font_list (); ly_c_pair_p (s); s = ly_cdr (s))
- {
- Font_metric *scaled = find_scaled_font (unsmob_metrics (ly_car (s)),
- m, input_enc_name);
- *t = scm_cons (scaled->self_scm (), SCM_EOL);
- t = SCM_CDRLOC(*t);
- }
-
- vf = new Virtual_font_metric (lst);
- val = vf->self_scm ();
- }
- else
- {
-
- if (!ly_c_symbol_p (input_enc_name))
- {
- SCM var = ly_module_lookup (scope_, ly_symbol2scm ("inputencoding"));
- input_enc_name = scm_variable_ref (var);
- }
- val = Modified_font_metric::make_scaled_font_metric (input_enc_name,
- f, lookup_mag);
- }
-
- sizes = scm_acons (scm_make_real (lookup_mag), val, sizes);
- scm_gc_unprotect_object (val);
- scm_hashq_set_x (scaled_fonts_, f->self_scm (), sizes);
- return unsmob_metrics (val);
-}
-
-/* Return alist to translate internally used fonts back to real-world
- coordinates. */
-SCM
-Paper_def::font_descriptions () const
-{
- SCM func = ly_scheme_function ("hash-table->alist");
-
- SCM l = SCM_EOL;
- for (SCM s = scm_call_1 (func, scaled_fonts_); ly_c_pair_p (s); s = ly_cdr (s))
- {
- SCM entry = ly_car (s);
- for (SCM t = ly_cdr (entry); ly_c_pair_p (t); t = ly_cdr (t))
- {
- Font_metric *fm= unsmob_metrics (ly_cdar (t));
-
- if (dynamic_cast<Modified_font_metric*> (fm))
- l = scm_cons (fm->self_scm (), l);
- }
- }
- return l;
}
Paper_def*
#include <math.h>
#include <time.h>
+#include "book-paper-def.hh"
#include "array.hh"
#include "dimensions.hh"
#include "font-metric.hh"
Paper_outputter::Paper_outputter (String filename)
{
filename_ = filename;
- paper_ = 0;
file_ = scm_open_file (scm_makfrom0str (filename.to_str0 ()),
scm_makfrom0str ("w"));
}
void
-Paper_outputter::output_metadata (Paper_def *paper, SCM scopes)
+Paper_outputter::output_metadata (Book_paper_def *paper, SCM scopes)
{
SCM fields = SCM_EOL;
for (int i = dump_header_fieldnames_global.size (); i--; )
}
void
-Paper_outputter::output_header (Paper_def *paper, SCM scopes, int page_count,
+Paper_outputter::output_header (Book_paper_def * bookpaper,
+
+ SCM scopes,
+ int page_count,
bool is_classic)
{
- paper_ = paper; // BROKEN BROKEN BROKEN.
String creator = gnu_lilypond_version_string ();
creator += " (http://lilypond.org)";
time_t t (time (0));
output_scheme (scm_list_n (ly_symbol2scm ("header"),
scm_makfrom0str (creator.to_str0 ()),
scm_makfrom0str (time_stamp.to_str0 ()),
- paper->self_scm (),
+ bookpaper->self_scm (), // FIXME.
scm_int2num (page_count),
ly_bool2scm (is_classic),
SCM_UNDEFINED));
- output_metadata (paper, scopes);
- output_music_output_def (paper);
-
+ output_metadata (bookpaper, scopes);
+ output_scheme (scm_list_2 (ly_symbol2scm ("define-fonts"),
+ bookpaper->self_scm ()));
output_scheme (scm_list_1 (ly_symbol2scm ("header-end")));
}
void
Paper_outputter::output_stencil (Stencil stil)
{
- SCM fonts = find_expression_fonts (stil.expr ());
-
- output_scheme (scm_list_3 (ly_symbol2scm ("define-fonts"),
- paper_->self_scm (),
- ly_quote_scm (ly_list_qsort_uniq_x (fonts))));
-
- interpret_stencil_expression (stil.expr (), paper_outputter_dump,
+ interpret_stencil_expression (stil.expr (), paper_outputter_dump,
(void*) this, Offset (0,0));
}
#include "book.hh"
+#include "book-paper-def.hh"
#include "context-def.hh"
#include "dimensions.hh"
#include "event.hh"
{
$$ = new Book;
$$->set_spot (THIS->here_input ());
+ $$->bookpaper_ = unsmob_bookpaper (THIS->lexer_->lookup_identifier ("$defaultbookpaper"));
}
| book_body score_block {
Score *score = $2;
+++ /dev/null
-/*
- scaled-font-metric.cc -- declare Modified_font_metric
-
- source file of the GNU LilyPond music typesetter
-
- (c) 1999--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-
- */
-
-#include <ctype.h>
-
-#include "warn.hh"
-#include "scaled-font-metric.hh"
-#include "string.hh"
-#include "stencil.hh"
-
-Modified_font_metric::Modified_font_metric (String coding, Font_metric* m, Real magn)
-{
- coding_vector_ = SCM_EOL;
- coding_mapping_ = SCM_EOL;
- coding_table_ = SCM_EOL;
- coding_description_ = SCM_EOL;
-
- coding_scheme_ = coding;
- magnification_ = magn;
-
- SCM desc = m->description_;
-
- Real total_mag = magn * ly_scm2double (ly_cdr (desc));
- assert (total_mag);
-
- description_ = scm_cons (ly_car (desc), scm_make_real (total_mag));
- orig_ = m;
-
- if (coding_scheme_ != "TeX"
- && coding_scheme_ != "ASCII"
- && coding_scheme_ != orig_->coding_scheme ())
- {
- coding_vector_ = scm_call_1 (ly_scheme_function ("get-coding-vector"),
- scm_makfrom0str (coding_scheme_.to_str0 ()));
-
- if (!ly_c_vector_p (coding_vector_))
- {
- programming_error ("get-coding-vector should return vector");
- coding_vector_ = scm_c_make_vector (256, ly_symbol2scm (".notdef"));
- }
-
-
- coding_table_ = scm_call_1 (ly_scheme_function ("get-coding-table"),
- scm_makfrom0str (orig_->coding_scheme ().to_str0 ()));
-
- coding_mapping_ = scm_call_2 (ly_scheme_function ("make-encoding-mapping"),
- coding_vector_,
- coding_table_);
-
- coding_description_= SCM_EOL;
-
- coding_description_ = scm_acons (ly_symbol2scm ("input-name"),
- scm_makfrom0str (coding_scheme_.to_str0 ()),
- coding_description_);
-
- coding_description_ = scm_acons (ly_symbol2scm ("input-vector"),
- coding_vector_, coding_description_);
- coding_description_ = scm_acons (ly_symbol2scm ("output-name"),
- scm_makfrom0str (orig_->coding_scheme ().to_str0 ()),
- coding_description_);
- coding_description_ = scm_acons (ly_symbol2scm ("output-table"),
- coding_table_,
- coding_description_);
-
- coding_description_ = scm_acons (ly_symbol2scm ("char-mapping"),
- coding_mapping_,
- coding_description_);
- }
-}
-
-
-
-LY_DEFINE (ly_font_encoding_alist, "ly:font-encoding-alist",
- 1, 0, 0,
- (SCM font),
- "Given the Modified_font_metric @var{font}, return an "
- "alist. Keys are input-name, input-vector, "
- "output-name, output-table, mapping.")
-{
- Modified_font_metric *fm
- = dynamic_cast<Modified_font_metric*> (unsmob_metrics (font));
-
- SCM_ASSERT_TYPE (fm, font, SCM_ARG1, __FUNCTION__, "Modified_font_metric");
- return fm->coding_description_;
-}
-
-SCM
-Modified_font_metric::make_scaled_font_metric (SCM coding, Font_metric *m, Real s)
-{
- /*
- UGOHR.
- */
- if (ly_c_symbol_p (coding))
- coding = scm_symbol_to_string (coding);
-
- String scheme = ly_scm2string (coding);
-
- Modified_font_metric *sfm = new Modified_font_metric (scheme, m, s);
-
- return sfm->self_scm ();
-}
-
-Real
-Modified_font_metric::design_size () const
-{
- return orig_->design_size ();
-}
-
-
-Box
-Modified_font_metric::get_indexed_char (int i) const
-{
- Box b = orig_->get_indexed_char (i);
- b.scale (magnification_);
- return b;
-}
-
-Box
-Modified_font_metric::get_ascii_char (int i) const
-{
- Box b = orig_->get_ascii_char (i);
- b.scale (magnification_);
- return b;
-}
-
-int
-Modified_font_metric::count () const
-{
- return orig_->count ();
-}
-
-Offset
-Modified_font_metric::get_indexed_wxwy (int k) const
-{
- Offset o = orig_->get_indexed_wxwy (k);
- return o * magnification_;
-}
-
-int
-Modified_font_metric::name_to_index (String s) const
-{
- return orig_->name_to_index (s);
-}
-
-int
-Modified_font_metric::index_to_ascii (int k) const
-{
- return orig_->index_to_ascii (k);
-}
-
-String
-Modified_font_metric::coding_scheme () const
-{
- return coding_scheme_;
-}
-
-void
-Modified_font_metric::derived_mark () const
-{
- scm_gc_mark (coding_vector_);
- scm_gc_mark (coding_description_);
- scm_gc_mark (coding_table_);
- scm_gc_mark (coding_mapping_);
-}
-
-Box
-Modified_font_metric::tex_kludge (String text) const
-{
- Interval ydims;
- Real w=0.0;
-
- /*
- TODO: put this klutchness behind ly:option switch.
- */
- for (int i = 0; i < text.length (); i++)
- {
- switch (text[i])
- {
- case '\\':
- // accent marks use width of base letter
- if (i +1 < text.length ())
- {
- if (text[i+1]=='\'' || text[i+1]=='`' || text[i+1]=='"' ||
- text[i+1]=='^')
- {
- i++;
- break;
- }
- // for string width \\ is a \ and \_ is a _.
- if (text[i+1]=='\\' || text[i+1]=='_')
- {
- break;
- }
- }
-
- for (i++; (i < text.length ()) && !isspace (text[i])
- && text[i]!='{' && text[i]!='}'; i++)
- ;
-
- // ugh.
- i--; // Compensate for the increment in the outer loop!
- break;
- case '{': // Skip '{' and '}'
- case '}':
- break;
-
- default:
- Box b = get_ascii_char ((unsigned char)text[i]);
-
- // Ugh, use the width of 'x' for unknown characters
- if (b[X_AXIS].length () == 0)
- b = get_ascii_char ((unsigned char)'x');
-
- w += b[X_AXIS].length ();
- ydims.unite (b[Y_AXIS]);
- break;
- }
- }
-
- if (ydims.is_empty ())
- ydims = Interval (0, 0);
-
- return Box (Interval (0, w), ydims);
-}
-
-Box
-Modified_font_metric::text_dimension (String text)
-{
- Box b;
- if (coding_scheme_ == "TeX")
- {
- b = tex_kludge (text);
- }
- else if (coding_scheme_ == "ASCII"
- || coding_scheme_ == orig_->coding_scheme ())
- {
- Interval ydims;
-
- Real w=0.0;
-
- for (int i = 0; i < text.length (); i++)
- {
- Box b = get_ascii_char ((unsigned char)text[i]);
-
- w += b[X_AXIS].length ();
- ydims.unite (b[Y_AXIS]);
- }
- if (ydims.is_empty ())
- ydims = Interval (0, 0);
-
- b = Box(Interval(0,w), ydims);
- }
- else
- {
- Interval ydims;
- Real w = 0.0;
-
- for (int i = 0; i < text.length (); i++)
- {
- SCM sym = scm_vector_ref (coding_vector_,
- SCM_MAKINUM((unsigned char) text[i]));
-
- Box char_box;
-
- if (!ly_c_symbol_p (sym))
- continue;
-
- char const * chars = SCM_SYMBOL_CHARS(sym);
-
- int idx = orig_->name_to_index (chars);
- if (idx >= 0)
- {
- char_box = orig_->get_indexed_char (idx);
- }
-
- char_box.scale (magnification_);
- if (!char_box[X_AXIS].is_empty ())
- w += char_box[X_AXIS][RIGHT]; // length ?
-
- ydims.unite (char_box[Y_AXIS]);
- }
-
- if (ydims.is_empty ())
- ydims = Interval (0, 0);
-
-
- b = Box (Interval (0, w), ydims);
- }
-
- return b;
-}
-
-Font_metric*
-Modified_font_metric::original_font () const
-{
- return orig_;
-}
#include <stdio.h>
#include "book.hh"
+#include "book-paper-def.hh"
#include "cpu-timer.hh"
#include "global-context.hh"
#include "ly-module.hh"
}
void
-default_rendering (SCM music, SCM outdef, SCM header, SCM outname)
+default_rendering (SCM music, SCM outdef,
+ SCM book_outputdef,
+ SCM header, SCM outname)
{
SCM context = ly_run_translator (music, outdef);
+ Book_paper_def * bpd = unsmob_bookpaper (book_outputdef);
+ if (bpd &&
+ unsmob_paper (outdef))
+ {
+ outdef = bpd->scale_paper (unsmob_paper (outdef))->self_scm (); // mem
+ // leak.
+ }
+
if (Global_context *g = dynamic_cast<Global_context*>
(unsmob_context (context)))
{
delete output;
}
}
-
+
SCM
-Score::book_rendering (String outname, Music_output_def *default_def,
+Score::book_rendering (String outname,
+ Book_paper_def* paperbook,
+ Music_output_def *default_def,
Paper_def **paper)
{
SCM out = scm_makfrom0str (outname.to_str0 ());
for (int i = 0; !i || i < outdef_count; i++)
{
Music_output_def *def = outdef_count ? defs_[i] : default_def;
+ if (Paper_def * pd = dynamic_cast<Paper_def*> (def))
+ {
+ def = paperbook->scale_paper (pd);
+ }
+
if (!(no_paper_global_b && dynamic_cast<Paper_def*> (def)))
{
SCM context = ly_run_translator (music_, def->self_scm ());
\include "engraver-init.ly"
}
+%
+% 20pt staff, 5 pt = 1.75 mm
+%
+
+#(define-public $defaultbookpaper (ly:make-bookpaper 1.7573))
+
+
+
#(set-default-paper-size "a4")
# Messages français pour lilypond.
-# Copyright © 2001 Free Software Foundation, Inc.
+# Copyright © 2004 Free Software Foundation, Inc.
# Michel Robitaille <robitail@IRO.UMontreal.CA>, traducteur depuis/since 1996.
#
msgid ""
"Project-Id-Version: lilypond 2.2.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2004-03-31 16:22+0200\n"
-"PO-Revision-Date: 2004-04-04 08:00-0500\n"
+"PO-Revision-Date: 2004-05-10 08:00-0500\n"
"Last-Translator: Michel Robitaille <robitail@IRO.UMontreal.CA>\n"
"Language-Team: French <traduc@traduc.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=ISO-8859-1\n"
"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: lilylib.py:60
msgid "lilylib module"
% Functions for direct and embedded PostScript
-/blot-diameter { lilypondpaperblotdiameter } bind def
-
/set_tex_dimen {
cvr def
} bind def
% Nice rectangle with rounded corners
/draw_box % breapth width depth height
{
- currentdict /testing known {
+% currentdict /testing known {
%% real thin lines for testing
/blot 0.005 def
- }{
- /blot blot-diameter def
- } ifelse
+% }{
+% /blot blot-diameter def
+% } ifelse
0 setlinecap
blot setlinewidth
(ly:parser-print-book parser book)))
(define-public (print-score-as-book parser score)
- (let ((book (ly:score-bookify score)))
+ (let
+ ((book (ly:score-bookify score))
+ )
+
(ly:parser-print-book parser book)))
(define-public (print-score parser score)
" /Helvetica-Bold " ;; ugh
" draw_ez_ball"))
-(define (filledbox breapth width depth height)
+(define (filledbox breapth width depth height) ; FIXME : use draw_round_box
(string-append (ly:numbers->string (list breapth width depth height))
" draw_box"))
"{\n"
"set-ps-scale-to-lily-scale\n"))
-(define (stem breapth width depth height)
+(define (stem breapth width depth height) ; FIXME: use draw_round_box.
(string-append
(ly:numbers->string (list breapth width depth height))
" draw_box" ))
(string-encode-integer
(inexact->exact (round (* 1000 (ly:font-magnification font)))))))
-(define (define-fonts paper font-list)
+(define (define-fonts bookpaper)
+ (string-append
+ "\\def\\lilypondpaperunit{mm}" ;; UGH. FIXME.
+ (tex-number-def "lilypondpaper" 'outputscale
+ (number->string (exact->inexact
+ (ly:bookpaper-outputscale bookpaper))))
(apply string-append
- (map (lambda (x) (font-load-command paper x)) font-list)))
-
+ (map (lambda (x) (font-load-command bookpaper x))
+ (ly:bookpaper-fonts bookpaper)
+ )))
+)
(define (unknown)
"%\n\\unknown\n")
(string-append
"\\def\\" prefix (symbol->tex-key key) (string->param number) "%\n"))
-(define (output-paper-def pd)
- (apply
- string-append
- (module-map
- (lambda (sym var)
- (let ((val (variable-ref var))
- (key (symbol->tex-key sym)))
-
- (cond
- ((string? val)
- (tex-string-def "lilypondpaper" sym val))
- ((number? val)
- (tex-number-def "lilypondpaper" sym
- (if (integer? val)
- (number->string val)
- (number->string (exact->inexact val)))))
- (else ""))))
-
- (ly:output-def-scope pd))))
+(define (output-paper-def paper)
+ (apply
+ string-append
+ (module-map
+ (lambda (sym var)
+ (let ((val (variable-ref var))
+ (key (symbol->tex-key sym)))
+
+ (cond
+ ((string? val)
+ (tex-string-def "lilypondpaper" sym val))
+ ((number? val)
+ (tex-number-def "lilypondpaper" sym
+ (if (integer? val)
+ (number->string val)
+ (number->string (exact->inexact val)))))
+ (else ""))))
+
+ (ly:output-def-scope pd))))
(define (output-scopes paper scopes fields basename)
(define (output-scope scope)
(define (symmetric-x-triangle t w h)
(embedded-ps (list 'symmetric-x-triangle t w h)))
-(define (font-load-command paper font)
+(define (font-load-command bookpaper font)
(string-append
"\\font\\" (font-command font) "="
(ly:font-filename font)
(ly:number->string (inexact->exact
(round (* 1000
(ly:font-magnification font)
- (ly:paper-lookup paper 'outputscale)))))
+ (ly:bookpaper-outputscale bookpaper)))))
"\n"))
(define (ez-ball c l b)
"\\lilypondspecial\n"
"\\lilypondpostscript\n"))
+; why paper?
(define (header creator time-stamp paper page-count classic?)
(string-append
"% Generated by " creator "\n"
(mm (eval 'mm m)))
(module-define! m 'fonts (make-cmr-tree (/ sz (* 20 pt))))
-
(module-define! m 'staffheight sz)
(module-define! m 'staff-space ss)
(module-define! m 'staffspace ss)
;; !! synchronize with feta-params.mf
(module-define! m 'linethickness (+ (* 0.3 pt) (* 0.04 ss)))
- (module-define! m 'outputscale ss)
(module-define! m 'ledgerlinethickness (+ (* 0.5 pt) (/ ss 10)))
(module-define! m 'blotdiameter (* 0.35 pt))
- (module-define! m 'interscoreline (* 4 mm))))
+ (module-define! m 'interscoreline (* 4 mm))
+
+ (module-define! m 'dimension-variables
+ '(pt mm cm in staffheight staff-space
+ staffspace linethickness ledgerlinethickness
+ blotdiameter interscoreline))
+ ))
(define-public (set-global-staff-size sz)
"Set the default staff size, where SZ is thought to be in PT."
;;; TODO: should raise (generic) exception with throw, and catch
;;; that in parse-scm.cc
(ly:warn "Must use #(set-paper-size .. ) within \\paper { ... }")))
+
+(define-public (scale-paper pap bookpap)
+ (let*
+ ((scale (ly:bookpaper-outputscale bookpap))
+ (new-pap (ly:output-def-clone pap))
+ (dim-vars (ly:paper-lookup pap 'dimension-variables))
+ (scope (ly:output-def-scope new-pap))
+ )
+
+ (for-each
+ (lambda (v)
+ (module-define! scope v
+ (* (ly:paper-lookup pap v) scale)))
+
+
+ dim-vars)
+
+ new-pap
+ ))