sile-typesetter / sile

The SILE Typesetter — Simon’s Improved Layout Engine
https://sile-typesetter.org
MIT License
1.61k stars 97 forks source link

Simplify discretionary logic and line ratio computation #1980

Closed Omikhleia closed 5 months ago

Omikhleia commented 5 months ago

The discretionary nodes still had some weird logic to determine whether a prebreak or a postbreak must be shown: it was doing it at page output time by re-analyzing the line content and making clever guesses (skipping glues etc. until reaching its own presence here...) with a strong assumption on how lines are composed. This extra weirdness of re-parsing the line:

While we fixed and improved it in earlier releases, the typesetter's computeLineRatio still had some code smell too:

This is an attempt at refactoring this beast...

Omikhleia commented 5 months ago

N.B. It changes some internal routines (now breakpointsToLines does more things in one pass, and computeLineRatio does far less things), hence the proposal in "develop" for 0.15. FWIW, I'm running those changes on 0.14 too however (hence my own testing with my "parbox" package which does call computeLineRatio at one point when "minimizing" the paragraph box)

Omikhleia commented 5 months ago

teardown-the-world-and-rebuild.

This is where pushback lives.... and TBH this change also butchers it even further, I'm afraid. But it's not beyond my hope, eventually, to get there.

alerque commented 5 months ago

teardown-the-world-and-rebuild.

This is where pushback lives.... and TBH this change also butchers it even further, I'm afraid. But it's not beyond my hope, eventually, to get there.

Agreed. Every time I've tried to tackle it it gets buried trying to fix things that are entangled with it. As we've been chipping away all around it and have much more modular architecture internally now I'm hopping eventually refactoring pushBack() itself will be easier than it once would have been.

And yes I realize we're gradually loading more and more nasty bits on that one area, but I still think cleaning up these other things makes sense.