Jeremias Maerki wrote:

>Would you consider sharing what you already
>have? This may help us in the general discussion and may be a good
>starting point.

Ok, I'll try to.

The main change in the LineLM is that the line breaking algorithm does not
select only the node in activeList with fewest demerits: all the nodes
whose demerits are <= a threshold are used to create LineBreakPositions,
so for each paragraph there is a set of layout options (for example, a
paragraph could create 8 to 10 lines, 9 being the layout with fewest

According to the value of widows and orphans, the LineLM creates a
sequence of elements: besides "normal" lines, represented by a box, there
are "optional lines", represented by
  box(0) penalty(inf,0) glue(0,1,0) box(0)
and "removable lines"
  box(0) penalty(inf,0) glue(1,0,1) box(0)
A few complications arise if not every possible layout allows breaks
between lines, but they all can be solved using boxes, glues and
penalties (for example, if a paragraph needs 3 or 4 lines, if it uses 3
it cannot be parted).

The BlockLM, and a block stacking LM in general, adds elements
representing its children's spaces and keep condition, for example
adding a 0 penalty or an infinite penalty according to
child1.mustKeepWithNext(), child2.mustKeepWithPrevious() and

The PageLM, once it has the list of elements representing a whole
page-sequence (or the content before a forced page break), calls the same
breaking algorithm, using only a different selection method which leaves
only one node in activeList.
It has now a rough sequence of pages: each one may may have a positive or
negative difference (with respect to the page height); the glue elements
representing adjustable lines or adjustable spaces in a page are collected
in different lists and they are used to "negotiate" a block progression
adjustment with the LM which created them. In this phase each LineLM
knows how many lines it will finally create.

Then, a new sequence of elements is created, and this time each element
has a fixed width (as the adjustments have already been decided).
This sequence is used to create the final pages; note that if the
adjustments have been enough to perfectly fill the pages, a first fit
algorithm would be enough to recreate the right page breaks.
This phase is needed, at the moment, because the Positions that the
LineLMs store in their elements are not LineBreakPosition (as they still
don't know how many lines they have to create), but maybe it could be
avoided in some way ...

Don't hesitate to ask for further details, I'll try to answer as clearly
as possible!

As per the columns, I did not think about them yet, but if they are
equally wide it shouldn't be terribly hard to handle them ...


Reply via email to