Finn Bock wrote:Using your description as a jumping point, here is my ideas for page breaking. I suppose it is even more pie-in-the-sky since I haven't yet written anything about it.
As I have been doing a few experiments about page breaking, I'm happy to
join in this conversation.
I rarely find myself feeling the urge to enter these conversations (it's not really my forte), but every now and then, I find I might offer an idea or two I think (hope) will be constructive...
The algorithm that the PageLM uses are a slightly modified knuth (no
need to maintain fitnessclass, and with the ability to decide on a break
when there is N pages of lookahead). The elements return from the LMs
are boxes (for lines), spaces and penalties.
Note that using the box - penalty - glue representation does not necessarily involve using Knuth's algorithm. A first-fit (or best-fit) algorithm could be enough in most situations; and if there are no adjustable elements in the fo document (for exaple, lots of paragraphs without adjustable spaces between them) Knuth's algorithm becomes a best-fit. Given its higher cost, maybe it could be used only when it could really produce a better output.
I don't know how the spec deals with this, but I doubt the spec cares which algorithm is used. That said, would it be a good idea to determine which algorithm to use based on something in userconfig.xml or something? If the Knuth system is more 'expensive' in terms of resources, we could make non-Knuth the default, and enable Knuth via a config file.
The elements are not returned from the LMs but pushed from the LM into the pageLM:
parent.generateElement(new Space(resolveBefore()); parent.generateElement(new Box(lineHeigth);
I'm not sure it is always possible to do this: sometimes the representation of a block depends on the properties of a higher level block. For example:
outer block | --------- | | inner inner block block 1 2
In order to decide whether there can be a page break between the lines
generated by innerBlock1 and innerBlock2, we must know:
- if inner block 1 has keep-with-next
- if inner block 2 has keep-with-previous
- if outer block has keep-together
This can be done if the outer BlockLM calls receives the elements created
by its child, looks at them and adds / removes / corrects; could this be
done if the inner BlockLMs directly give their element to the top-level
BTW, what about your great refactoring of all the knuth code?
Web Maestro Clay -- <[EMAIL PROTECTED]> - <http://homepage.mac.com/webmaestro/> My religion is simple. My religion is kindness. - HH The 14th Dalai Lama of Tibet