Glen Mazza wrote:

> The title centers correctly in 0.20.5, but is left-justified in 1.0.
> [...]
> Luca, are you looking at this issue of text alignment in general?

Yes, this happens when the text is short and the algorithm is not able to
find a set of breaking points: the fallback method can't compute the
needed indent, and the text is left-aligned instead of centered.

One way to solve this problem is to use, instead of the constant
DEFAULT_SPACE_WIDTH, a value computed according to the line width and the
maximum acceptable adjustment; this would prevent the algorithm from
failing. This value should be computed by the LineLM, and the InlineLMs
have to know it.

Another way is to use, instead of considerLegalBreak(), a different method
to evaluate a possible break point if no breakpoints are found: this
alternative method would be much simpler, and would re-create the
behaviour of the old getNextBreakPoss method (add content to the existing
line if possible, otherwise start another line).

I think this could be a much better solution:
- it's simpler: it's just another private method in the LineLM
- it would solve not only this issue with centered text, but also the
other situations in which the Knuth's algorithm fails (for example, when
there is a word larger than the line: see Simon's test file id=12494 for
bug 29124)

I have already done it, so if you agree I could create a patch in a short
time.

> Also, any chance we can get the Knuth classes commented so we have a
> better idea what KnuthBox, KnuthPenalty, KnuthGlue, etc. are for?

Sure, I should have done this before!
I'll try and comment these files as soon as possible.

Regards,
    Luca


Reply via email to