int max_systems_per_page () const;
int min_systems_per_page () const;
Real page_height (int page_number, bool last) const;
+ Real paper_height () const;
vsize system_count () const;
Real line_count_penalty (int line_count) const;
int line_count_status (int line_count) const;
vector<Line_details> cached_line_details_;
vector<Line_details> uncompressed_line_details_;
+ Real paper_height_;
mutable vector<Real> page_height_cache_;
mutable vector<Real> last_page_height_cache_;
{
book_ = pb;
system_count_ = 0;
+ paper_height_ = robust_scm2double (pb->paper_->c_variable ("paper-height"), 1.0);
ragged_ = to_boolean (pb->paper_->c_variable ("ragged-bottom"));
ragged_last_ = to_boolean (pb->paper_->c_variable ("ragged-last-bottom"));
systems_per_page_ = max (0, robust_scm2int (pb->paper_->c_variable ("systems-per-page"), 0));
SCM_UNDEFINED));
}
+// Returns the total height of the paper, including margins and
+// space for the header/footer. This is an upper bound on
+// page_height, and it doesn't depend on the current page.
+Real
+Page_breaking::paper_height () const
+{
+ return paper_height_;
+}
+
Real
Page_breaking::page_height (int page_num, bool last) const
{
// we need to look ahead a few systems in order to find the best solution. But
// we won't, because we stop once we overfill the page with the large header.
vsize page_num = page == VPOS ? 0 : page;
+ Real paper_height = breaker_->paper_height ();
Page_spacing space (breaker_->page_height (page_num + first_page_num_, last),
breaker_);
Page_spacing_node &cur = page == VPOS ? simple_state_[line] : state_.at (line, page);
space.prepend_system (lines_[page_start]);
+ bool overfull = (space.rod_height_ > paper_height
+ || (ragged
+ && (space.rod_height_ + space.spring_len_ > paper_height)));
// This 'if' statement is a little hard to parse. It won't consider this configuration
// if it is overfull unless the current configuration is the first one with this start
// point. We also make an exception (and consider this configuration) if the previous
// configuration we tried had fewer lines than min-systems-per-page.
if (!breaker_->too_few_lines (line_count)
&& page_start < line
- && (isinf (space.force_) || (space.force_ < 0 && ragged)))
+ && overfull)
break;
line_count += lines_[page_start].compressed_nontitle_lines_count_;