OLD | NEW |
1 /* | 1 /* |
2 This file is part of LilyPond, the GNU music typesetter. | 2 This file is part of LilyPond, the GNU music typesetter. |
3 | 3 |
4 Copyright (C) 2006--2015 Joe Neeman <joeneeman@gmail.com> | 4 Copyright (C) 2006--2015 Joe Neeman <joeneeman@gmail.com> |
5 | 5 |
6 LilyPond is free software: you can redistribute it and/or modify | 6 LilyPond is free software: you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
8 the Free Software Foundation, either version 3 of the License, or | 8 the Free Software Foundation, either version 3 of the License, or |
9 (at your option) any later version. | 9 (at your option) any later version. |
10 | 10 |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 | 576 |
577 SCM footnotes = Page_layout_problem::get_footnotes_from_lines (systems); | 577 SCM footnotes = Page_layout_problem::get_footnotes_from_lines (systems); |
578 | 578 |
579 foot = Page_layout_problem::add_footnotes_to_footer (footnotes, foot, book_); | 579 foot = Page_layout_problem::add_footnotes_to_footer (footnotes, foot, book_); |
580 | 580 |
581 p->set_property ("foot-stencil", foot.smobbed_copy ()); | 581 p->set_property ("foot-stencil", foot.smobbed_copy ()); |
582 | 582 |
583 return page; | 583 return page; |
584 } | 584 } |
585 | 585 |
| 586 // TODO: pass lines_per_page by const reference |
586 SCM | 587 SCM |
587 Page_breaking::make_pages (vector<vsize> lines_per_page, SCM systems) | 588 Page_breaking::make_pages (vector<vsize> lines_per_page, SCM systems) |
588 { | 589 { |
589 if (scm_is_null (systems)) | 590 if (scm_is_null (systems)) |
590 return SCM_EOL; | 591 return SCM_EOL; |
591 | 592 |
592 int first_page_number | 593 int first_page_number |
593 = robust_scm2int (book_->paper_->c_variable ("first-page-number"), 1); | 594 = robust_scm2int (book_->paper_->c_variable ("first-page-number"), 1); |
594 SCM ret = SCM_EOL; | 595 SCM ret = SCM_EOL; |
595 bool reset_footnotes_on_new_page = to_boolean (book_->top_paper ()->c_variable
("reset-footnotes-on-new-page")); | 596 bool reset_footnotes_on_new_page = to_boolean (book_->top_paper ()->c_variable
("reset-footnotes-on-new-page")); |
596 SCM label_page_table = book_->top_paper ()->c_variable ("label-page-table"); | 597 SCM label_page_table = book_->top_paper ()->c_variable ("label-page-table"); |
597 if (SCM_UNBNDP (label_page_table)) | 598 if (SCM_UNBNDP (label_page_table)) |
598 label_page_table = SCM_EOL; | 599 label_page_table = SCM_EOL; |
599 | 600 |
600 // Build a list of (systems configuration . footnote-count) triples. | 601 // Build a list of (systems configuration . footnote-count) triples. |
601 // Note that we lay out the staves and find the configurations, | 602 // Note that we lay out the staves and find the configurations, |
602 // but we do not draw anything in this function. It is important | 603 // but we do not draw anything in this function. It is important |
603 // that all staves are laid out vertically before any are drawn; some | 604 // that all staves are laid out vertically before any are drawn; some |
604 // grobs (like tuplet brackets) look at their neighbours while drawing | 605 // grobs (like tuplet brackets) look at their neighbours while drawing |
605 // themselves. If this happens before the neighbouring staves have | 606 // themselves. If this happens before the neighbouring staves have |
606 // been laid out, bad side-effects could happen (in particular, | 607 // been laid out, bad side-effects could happen (in particular, |
607 // Align_interface::align_to_ideal_distances might be called). | 608 // Align_interface::align_to_ideal_distances might be called). |
608 SCM systems_configs_fncounts = SCM_EOL; | 609 SCM systems_configs_fncounts = SCM_EOL; |
609 vsize footnote_count = 0; | 610 vsize footnote_count = 0; |
610 Real last_page_force = 0; | 611 Real last_page_force = 0; |
611 | 612 |
612 for (vsize i = 0; i < lines_per_page.size (); i++) | 613 for (vsize i = 0; i < lines_per_page.size (); i++) |
613 { | 614 { |
614 int page_num = i + first_page_number; | 615 int page_num = first_page_number + static_cast<int> (i); |
615 bool bookpart_last_page = (i == lines_per_page.size () - 1); | 616 bool bookpart_last_page = (i == lines_per_page.size () - 1); |
616 bool rag = ragged () || (bookpart_last_page && ragged_last ()); | 617 bool rag = ragged () || (bookpart_last_page && ragged_last ()); |
617 SCM line_count = scm_from_int (lines_per_page[i]); | 618 SCM line_count = scm_from_int (lines_per_page[i]); |
618 SCM lines = scm_list_head (systems, line_count); | 619 SCM lines = scm_list_head (systems, line_count); |
619 int fn_lines = Page_layout_problem::get_footnote_count (lines); | 620 int fn_lines = Page_layout_problem::get_footnote_count (lines); |
620 Page_layout_problem::add_footnotes_to_lines (lines, reset_footnotes_on_new
_page ? 0 : footnote_count, book_); | 621 Page_layout_problem::add_footnotes_to_lines (lines, reset_footnotes_on_new
_page ? 0 : footnote_count, book_); |
621 | 622 |
622 SCM config = SCM_EOL; | 623 SCM config = SCM_EOL; |
623 SCM dummy_page = make_page (page_num, bookpart_last_page); | 624 SCM dummy_page = make_page (page_num, bookpart_last_page); |
624 Page_layout_problem layout (book_, dummy_page, lines); | 625 Page_layout_problem layout (book_, dummy_page, lines); |
(...skipping 13 matching lines...) Expand all Loading... |
638 last_page_force = layout.force (); | 639 last_page_force = layout.force (); |
639 | 640 |
640 systems_configs_fncounts = scm_cons (scm_cons (lines, config), systems_con
figs_fncounts); | 641 systems_configs_fncounts = scm_cons (scm_cons (lines, config), systems_con
figs_fncounts); |
641 footnote_count += fn_lines; | 642 footnote_count += fn_lines; |
642 systems = scm_list_tail (systems, line_count); | 643 systems = scm_list_tail (systems, line_count); |
643 } | 644 } |
644 | 645 |
645 // TODO: previously, the following loop caused the systems to be | 646 // TODO: previously, the following loop caused the systems to be |
646 // drawn. Now that we no longer draw anything in Page_breaking, | 647 // drawn. Now that we no longer draw anything in Page_breaking, |
647 // it is safe to merge these two loops. | 648 // it is safe to merge these two loops. |
648 int page_num = first_page_number + lines_per_page.size () - 1; | 649 int page_num = first_page_number + static_cast<int> (lines_per_page.size ()) -
1; |
649 for (SCM s = systems_configs_fncounts; scm_is_pair (s); s = scm_cdr (s)) | 650 for (SCM s = systems_configs_fncounts; scm_is_pair (s); s = scm_cdr (s)) |
650 { | 651 { |
651 SCM lines = scm_caar (s); | 652 SCM lines = scm_caar (s); |
652 SCM config = scm_cdar (s); | 653 SCM config = scm_cdar (s); |
653 | 654 |
654 bool bookpart_last_page = scm_is_eq (s, systems_configs_fncounts); | 655 bool bookpart_last_page = scm_is_eq (s, systems_configs_fncounts); |
655 SCM page = draw_page (lines, config, page_num, bookpart_last_page); | 656 SCM page = draw_page (lines, config, page_num, bookpart_last_page); |
656 /* collect labels */ | 657 /* collect labels */ |
657 SCM page_num_scm = scm_from_int (page_num); | 658 SCM page_num_scm = scm_from_int (page_num); |
658 for (SCM l = lines; scm_is_pair (l); l = scm_cdr (l)) | 659 for (SCM l = lines; scm_is_pair (l); l = scm_cdr (l)) |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 Real hanging = max (hanging_begin, hanging_rest); | 1094 Real hanging = max (hanging_begin, hanging_rest); |
1094 cur.tallness_ = hanging - prev_hanging; | 1095 cur.tallness_ = hanging - prev_hanging; |
1095 prev_hanging = hanging; | 1096 prev_hanging = hanging; |
1096 prev_hanging_begin = hanging_begin; | 1097 prev_hanging_begin = hanging_begin; |
1097 prev_hanging_rest = hanging_rest; | 1098 prev_hanging_rest = hanging_rest; |
1098 prev_refpoint_hanging = refpoint_hanging; | 1099 prev_refpoint_hanging = refpoint_hanging; |
1099 } | 1100 } |
1100 } | 1101 } |
1101 | 1102 |
1102 vsize | 1103 vsize |
1103 Page_breaking::min_page_count (vsize configuration, vsize first_page_num) | 1104 Page_breaking::min_page_count (vsize configuration, int first_page_num) |
1104 { | 1105 { |
1105 vsize ret = 1; | 1106 int ret = 1; |
1106 vsize page_starter = 0; | 1107 vsize page_starter = 0; |
1107 Real cur_rod_height = 0; | 1108 Real cur_rod_height = 0; |
1108 Real cur_spring_height = 0; | 1109 Real cur_spring_height = 0; |
1109 Real cur_page_height = page_height (first_page_num, false); | 1110 Real cur_page_height = page_height (first_page_num, false); |
1110 int line_count = 0; | 1111 int line_count = 0; |
1111 | 1112 |
1112 cache_line_details (configuration); | 1113 cache_line_details (configuration); |
1113 | 1114 |
1114 if (cached_line_details_.size ()) | 1115 if (cached_line_details_.size ()) |
1115 cur_page_height -= min_whitespace_at_top_of_page (cached_line_details_[0]); | 1116 cur_page_height -= min_whitespace_at_top_of_page (cached_line_details_[0]); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1170 { | 1171 { |
1171 cur_page_height = page_height (first_page_num + ret - 1, true); | 1172 cur_page_height = page_height (first_page_num + ret - 1, true); |
1172 cur_page_height -= min_whitespace_at_top_of_page (cached_line_details_[pag
e_starter]); | 1173 cur_page_height -= min_whitespace_at_top_of_page (cached_line_details_[pag
e_starter]); |
1173 cur_page_height -= min_whitespace_at_bottom_of_page (cached_line_details_.
back ()); | 1174 cur_page_height -= min_whitespace_at_bottom_of_page (cached_line_details_.
back ()); |
1174 | 1175 |
1175 if (!too_few_lines (line_count - cached_line_details_.back ().compressed_n
ontitle_lines_count_) | 1176 if (!too_few_lines (line_count - cached_line_details_.back ().compressed_n
ontitle_lines_count_) |
1176 && cur_rod_height > cur_page_height | 1177 && cur_rod_height > cur_page_height |
1177 /* don't increase the page count if the last page had only one system
*/ | 1178 /* don't increase the page count if the last page had only one system
*/ |
1178 && cur_rod_height > cached_line_details_.back ().full_height ()) | 1179 && cur_rod_height > cached_line_details_.back ().full_height ()) |
1179 ret++; | 1180 ret++; |
1180 assert (ret <= cached_line_details_.size ()); | 1181 assert (static_cast<vsize> (ret) <= cached_line_details_.size ()); |
1181 } | 1182 } |
1182 | 1183 |
1183 return ret; | 1184 return ret; |
1184 } | 1185 } |
1185 | 1186 |
1186 // If systems_per_page_ is positive, we don't really try to space on N pages; | 1187 // If systems_per_page_ is positive, we don't really try to space on N pages; |
1187 // we just put the requested number of systems on each page and penalize | 1188 // we just put the requested number of systems on each page and penalize |
1188 // if the result doesn't have N pages. | 1189 // if the result doesn't have N pages. |
1189 Page_spacing_result | 1190 Page_spacing_result |
1190 Page_breaking::space_systems_on_n_pages (vsize configuration, vsize n, vsize fir
st_page_num) | 1191 Page_breaking::space_systems_on_n_pages (vsize configuration, vsize n, int first
_page_num) |
1191 { | 1192 { |
1192 Page_spacing_result ret; | 1193 Page_spacing_result ret; |
1193 | 1194 |
1194 if (systems_per_page_ > 0) | 1195 if (systems_per_page_ > 0) |
1195 { | 1196 { |
1196 Page_spacing_result ret = space_systems_with_fixed_number_per_page (config
uration, first_page_num); | 1197 Page_spacing_result ret = space_systems_with_fixed_number_per_page (config
uration, first_page_num); |
1197 ret.demerits_ += (ret.force_.size () == n) ? 0 : BAD_SPACING_PENALTY; | 1198 ret.demerits_ += (ret.force_.size () == n) ? 0 : BAD_SPACING_PENALTY; |
1198 return ret; | 1199 return ret; |
1199 } | 1200 } |
1200 | 1201 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1235 Break_position const &pos = breaks_[current_end_breakpoint_]; | 1236 Break_position const &pos = breaks_[current_end_breakpoint_]; |
1236 if (Paper_score *ps = system_specs_[pos.system_spec_index_].pscore_) | 1237 if (Paper_score *ps = system_specs_[pos.system_spec_index_].pscore_) |
1237 return robust_scm2double (ps->layout ()->lookup_variable (penalty_sym), 0.0)
; | 1238 return robust_scm2double (ps->layout ()->lookup_variable (penalty_sym), 0.0)
; |
1238 | 1239 |
1239 return robust_scm2double (book_->paper_->lookup_variable (penalty_sym), 0.0); | 1240 return robust_scm2double (book_->paper_->lookup_variable (penalty_sym), 0.0); |
1240 } | 1241 } |
1241 | 1242 |
1242 // If systems_per_page_ is positive, we don't really try to space on N | 1243 // If systems_per_page_ is positive, we don't really try to space on N |
1243 // or N+1 pages; see the comment to space_systems_on_n_pages. | 1244 // or N+1 pages; see the comment to space_systems_on_n_pages. |
1244 Page_spacing_result | 1245 Page_spacing_result |
1245 Page_breaking::space_systems_on_n_or_one_more_pages (vsize configuration, vsize
n, vsize first_page_num, | 1246 Page_breaking::space_systems_on_n_or_one_more_pages (vsize configuration, vsize
n, int first_page_num, |
1246 Real penalty_for_fewer_page
s) | 1247 Real penalty_for_fewer_page
s) |
1247 { | 1248 { |
1248 Page_spacing_result n_res; | 1249 Page_spacing_result n_res; |
1249 Page_spacing_result m_res; | 1250 Page_spacing_result m_res; |
1250 | 1251 |
1251 if (systems_per_page_ > 0) | 1252 if (systems_per_page_ > 0) |
1252 { | 1253 { |
1253 Page_spacing_result ret = space_systems_with_fixed_number_per_page (config
uration, first_page_num); | 1254 Page_spacing_result ret = space_systems_with_fixed_number_per_page (config
uration, first_page_num); |
1254 ret.demerits_ += (ret.force_.size () == n || ret.force_.size () == (n - 1)
) ? 0 : BAD_SPACING_PENALTY; | 1255 ret.demerits_ += (ret.force_.size () == n || ret.force_.size () == (n - 1)
) ? 0 : BAD_SPACING_PENALTY; |
1255 return ret; | 1256 return ret; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1288 Real page_spacing_weight = robust_scm2double (book_->paper_->c_variable ("page
-spacing-weight"), 10); | 1289 Real page_spacing_weight = robust_scm2double (book_->paper_->c_variable ("page
-spacing-weight"), 10); |
1289 n_res.demerits_ += penalty_for_fewer_pages * page_spacing_weight; | 1290 n_res.demerits_ += penalty_for_fewer_pages * page_spacing_weight; |
1290 | 1291 |
1291 if (n_res.force_.size ()) | 1292 if (n_res.force_.size ()) |
1292 n_res.force_.back () += penalty_for_fewer_pages; | 1293 n_res.force_.back () += penalty_for_fewer_pages; |
1293 | 1294 |
1294 return (m_res.demerits_ < n_res.demerits_) ? m_res : n_res; | 1295 return (m_res.demerits_ < n_res.demerits_) ? m_res : n_res; |
1295 } | 1296 } |
1296 | 1297 |
1297 Page_spacing_result | 1298 Page_spacing_result |
1298 Page_breaking::space_systems_on_best_pages (vsize configuration, vsize first_pag
e_num) | 1299 Page_breaking::space_systems_on_best_pages (vsize configuration, int first_page_
num) |
1299 { | 1300 { |
1300 if (systems_per_page_ > 0) | 1301 if (systems_per_page_ > 0) |
1301 return space_systems_with_fixed_number_per_page (configuration, first_page_n
um); | 1302 return space_systems_with_fixed_number_per_page (configuration, first_page_n
um); |
1302 | 1303 |
1303 cache_line_details (configuration); | 1304 cache_line_details (configuration); |
1304 Page_spacer ps (cached_line_details_, first_page_num, this); | 1305 Page_spacer ps (cached_line_details_, first_page_num, this); |
1305 | 1306 |
1306 return finalize_spacing_result (configuration, ps.solve ()); | 1307 return finalize_spacing_result (configuration, ps.solve ()); |
1307 } | 1308 } |
1308 | 1309 |
1309 Page_spacing_result | 1310 Page_spacing_result |
1310 Page_breaking::space_systems_with_fixed_number_per_page (vsize configuration, | 1311 Page_breaking::space_systems_with_fixed_number_per_page (vsize configuration, |
1311 vsize first_page_num) | 1312 int first_page_num) |
1312 { | 1313 { |
1313 Page_spacing_result res; | 1314 Page_spacing_result res; |
1314 Page_spacing space (page_height (first_page_num, false), this); | 1315 Page_spacing space (page_height (first_page_num, false), this); |
1315 vsize line = 0; | 1316 vsize line = 0; |
1316 vsize page = 0; | 1317 int page_num = first_page_num; |
1317 vsize page_first_line = 0; | 1318 vsize page_first_line = 0; |
1318 | 1319 |
1319 cache_line_details (configuration); | 1320 cache_line_details (configuration); |
1320 while (line < cached_line_details_.size ()) | 1321 while (line < cached_line_details_.size ()) |
1321 { | 1322 { |
1322 page++; | 1323 page_num++; |
1323 space.clear (); | 1324 space.clear (); |
1324 space.resize (page_height (first_page_num + page, false)); | 1325 space.resize (page_height (page_num, false)); |
1325 | 1326 |
1326 int system_count_on_this_page = 0; | 1327 int system_count_on_this_page = 0; |
1327 while (system_count_on_this_page < systems_per_page_ | 1328 while (system_count_on_this_page < systems_per_page_ |
1328 && line < cached_line_details_.size ()) | 1329 && line < cached_line_details_.size ()) |
1329 { | 1330 { |
1330 Line_details const &cur_line = cached_line_details_[line]; | 1331 Line_details const &cur_line = cached_line_details_[line]; |
1331 space.append_system (cur_line); | 1332 space.append_system (cur_line); |
1332 system_count_on_this_page += cur_line.compressed_nontitle_lines_count_
; | 1333 system_count_on_this_page += cur_line.compressed_nontitle_lines_count_
; |
1333 line++; | 1334 line++; |
1334 | 1335 |
(...skipping 10 matching lines...) Expand all Loading... |
1345 res.penalty_ += abs (system_count_on_this_page - systems_per_page_) *
TERRIBLE_SPACING_PENALTY; | 1346 res.penalty_ += abs (system_count_on_this_page - systems_per_page_) *
TERRIBLE_SPACING_PENALTY; |
1346 res.system_count_status_ |= ((system_count_on_this_page < systems_per_
page_)) | 1347 res.system_count_status_ |= ((system_count_on_this_page < systems_per_
page_)) |
1347 ? SYSTEM_COUNT_TOO_FEW : SYSTEM_COUNT_TOO_
MANY; | 1348 ? SYSTEM_COUNT_TOO_FEW : SYSTEM_COUNT_TOO_
MANY; |
1348 } | 1349 } |
1349 | 1350 |
1350 page_first_line = line; | 1351 page_first_line = line; |
1351 } | 1352 } |
1352 | 1353 |
1353 /* Recalculate forces for the last page because we know now that is | 1354 /* Recalculate forces for the last page because we know now that is |
1354 really the last page. */ | 1355 really the last page. */ |
1355 space.resize (page_height (first_page_num + page, true)); | 1356 space.resize (page_height (page_num, true)); |
1356 res.force_.back () = space.force_; | 1357 res.force_.back () = space.force_; |
1357 return finalize_spacing_result (configuration, res); | 1358 return finalize_spacing_result (configuration, res); |
1358 } | 1359 } |
1359 | 1360 |
1360 Page_spacing_result | 1361 Page_spacing_result |
1361 Page_breaking::pack_systems_on_least_pages (vsize configuration, vsize first_pag
e_num) | 1362 Page_breaking::pack_systems_on_least_pages (vsize configuration, int first_page_
num) |
1362 { | 1363 { |
1363 // TODO: add support for min/max-systems-per-page. | 1364 // TODO: add support for min/max-systems-per-page. |
1364 Page_spacing_result res; | 1365 Page_spacing_result res; |
1365 vsize page = 0; | 1366 int page_num = first_page_num; |
1366 vsize page_first_line = 0; | 1367 vsize page_first_line = 0; |
1367 Page_spacing space (page_height (first_page_num, false), this); | 1368 Page_spacing space (page_height (page_num, false), this); |
1368 | 1369 |
1369 cache_line_details (configuration); | 1370 cache_line_details (configuration); |
1370 for (vsize line = 0; line < cached_line_details_.size (); line++) | 1371 for (vsize line = 0; line < cached_line_details_.size (); line++) |
1371 { | 1372 { |
1372 Real prev_force = space.force_; | 1373 Real prev_force = space.force_; |
1373 space.append_system (cached_line_details_[line]); | 1374 space.append_system (cached_line_details_[line]); |
1374 if ((line > page_first_line) | 1375 if ((line > page_first_line) |
1375 && (isinf (space.force_) | 1376 && (isinf (space.force_) |
1376 || ((line > 0) | 1377 || ((line > 0) |
1377 && scm_is_eq (cached_line_details_[line - 1].page_permission_, | 1378 && scm_is_eq (cached_line_details_[line - 1].page_permission_, |
1378 ly_symbol2scm ("force"))))) | 1379 ly_symbol2scm ("force"))))) |
1379 { | 1380 { |
1380 res.systems_per_page_.push_back (line - page_first_line); | 1381 res.systems_per_page_.push_back (line - page_first_line); |
1381 res.force_.push_back (prev_force); | 1382 res.force_.push_back (prev_force); |
1382 res.penalty_ += cached_line_details_[line - 1].page_penalty_; | 1383 res.penalty_ += cached_line_details_[line - 1].page_penalty_; |
1383 page++; | 1384 page_num++; |
1384 space.resize (page_height (first_page_num + page, false)); | 1385 space.resize (page_height (page_num, false)); |
1385 space.clear (); | 1386 space.clear (); |
1386 space.append_system (cached_line_details_[line]); | 1387 space.append_system (cached_line_details_[line]); |
1387 page_first_line = line; | 1388 page_first_line = line; |
1388 } | 1389 } |
1389 | 1390 |
1390 if (line == cached_line_details_.size () - 1) | 1391 if (line == cached_line_details_.size () - 1) |
1391 { | 1392 { |
1392 /* This is the last line */ | 1393 /* This is the last line */ |
1393 /* When the last page height was computed, we did not know yet that it | 1394 /* When the last page height was computed, we did not know yet that it |
1394 * was the last one. If the systems put on it don't fit anymore, the l
ast | 1395 * was the last one. If the systems put on it don't fit anymore, the l
ast |
1395 * system is moved to a new page */ | 1396 * system is moved to a new page */ |
1396 space.resize (page_height (first_page_num + page, true)); | 1397 space.resize (page_height (page_num, true)); |
1397 if ((line > page_first_line) && (isinf (space.force_))) | 1398 if ((line > page_first_line) && (isinf (space.force_))) |
1398 { | 1399 { |
1399 res.systems_per_page_.push_back (line - page_first_line); | 1400 res.systems_per_page_.push_back (line - page_first_line); |
1400 res.force_.push_back (prev_force); | 1401 res.force_.push_back (prev_force); |
1401 /* the last page containing the last line */ | 1402 /* the last page containing the last line */ |
1402 space.resize (page_height (first_page_num + page + 1, true)); | 1403 space.resize (page_height (page_num + 1, true)); |
1403 space.clear (); | 1404 space.clear (); |
1404 space.append_system (cached_line_details_[line]); | 1405 space.append_system (cached_line_details_[line]); |
1405 res.systems_per_page_.push_back (1); | 1406 res.systems_per_page_.push_back (1); |
1406 res.force_.push_back (space.force_); | 1407 res.force_.push_back (space.force_); |
1407 res.penalty_ += cached_line_details_[line - 1].page_penalty_; | 1408 res.penalty_ += cached_line_details_[line - 1].page_penalty_; |
1408 res.penalty_ += cached_line_details_[line].page_penalty_; | 1409 res.penalty_ += cached_line_details_[line].page_penalty_; |
1409 } | 1410 } |
1410 else | 1411 else |
1411 { | 1412 { |
1412 res.systems_per_page_.push_back (line + 1 - page_first_line); | 1413 res.systems_per_page_.push_back (line + 1 - page_first_line); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1482 ret.systems_per_page_.push_back (lines.size ()); | 1483 ret.systems_per_page_.push_back (lines.size ()); |
1483 ret.force_.push_back (ragged ? min (space.force_, 0.0) : space.force_); | 1484 ret.force_.push_back (ragged ? min (space.force_, 0.0) : space.force_); |
1484 ret.penalty_ = line_count_penalty (line_count) + lines.back ().page_penalty_ +
lines.back ().turn_penalty_; | 1485 ret.penalty_ = line_count_penalty (line_count) + lines.back ().page_penalty_ +
lines.back ().turn_penalty_; |
1485 ret.system_count_status_ |= line_count_status (line_count); | 1486 ret.system_count_status_ |= line_count_status (line_count); |
1486 | 1487 |
1487 /* don't do finalize_spacing_result () because we are only an internal functio
n */ | 1488 /* don't do finalize_spacing_result () because we are only an internal functio
n */ |
1488 return ret; | 1489 return ret; |
1489 } | 1490 } |
1490 | 1491 |
1491 Page_spacing_result | 1492 Page_spacing_result |
1492 Page_breaking::space_systems_on_2_pages (vsize configuration, vsize first_page_n
um) | 1493 Page_breaking::space_systems_on_2_pages (vsize configuration, int first_page_num
) |
1493 { | 1494 { |
1494 Real page1_height = page_height (first_page_num, false); | 1495 Real page1_height = page_height (first_page_num, false); |
1495 Real page2_height = page_height (first_page_num + 1, is_last ()); | 1496 Real page2_height = page_height (first_page_num + 1, is_last ()); |
1496 bool ragged1 = ragged (); | 1497 bool ragged1 = ragged (); |
1497 bool ragged2 = ragged () || (is_last () && ragged_last ()); | 1498 bool ragged2 = ragged () || (is_last () && ragged_last ()); |
1498 | 1499 |
1499 /* if there is a forced break, this reduces to 2 1-page problems */ | 1500 /* if there is a forced break, this reduces to 2 1-page problems */ |
1500 cache_line_details (configuration); | 1501 cache_line_details (configuration); |
1501 for (vsize i = 0; i + 1 < cached_line_details_.size (); i++) | 1502 for (vsize i = 0; i + 1 < cached_line_details_.size (); i++) |
1502 if (scm_is_eq (cached_line_details_[i].page_permission_, | 1503 if (scm_is_eq (cached_line_details_[i].page_permission_, |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1675 // FIXME: take into account the height of the footer | 1676 // FIXME: take into account the height of the footer |
1676 Real translate = min (line.shape_.begin_[DOWN], line.shape_.rest_[DOWN]); | 1677 Real translate = min (line.shape_.begin_[DOWN], line.shape_.rest_[DOWN]); |
1677 return max (0.0, max (padding, min_distance + translate)); | 1678 return max (0.0, max (padding, min_distance + translate)); |
1678 } | 1679 } |
1679 | 1680 |
1680 int | 1681 int |
1681 Page_breaking::orphan_penalty () const | 1682 Page_breaking::orphan_penalty () const |
1682 { | 1683 { |
1683 return orphan_penalty_; | 1684 return orphan_penalty_; |
1684 } | 1685 } |
OLD | NEW |