Skip to content

Refactor knuth plass line breaker#160

Draft
Omikhleia wants to merge 4 commits intomainfrom
refactor-knuth-plass-line-breaker
Draft

Refactor knuth plass line breaker#160
Omikhleia wants to merge 4 commits intomainfrom
refactor-knuth-plass-line-breaker

Conversation

@Omikhleia
Copy link
Owner

@Omikhleia Omikhleia commented Nov 12, 2025

Some more code and related comments that should perhaps be up-streamed to SILE when completed: an attempt to check the line breaker against the original sources (TeX82, PDFTeX) and bring the implementation closer to them, and properly documented...

  • feat: Remove non-working alternates from line-breaker algorithm = See this SILE issue for rationale. The original author himself, in 2022, advocated the removal of the non-working experiment...
  • refactor: Rewrite the line-breaker algorithm with comments from TeX = As many comments I could extract from the original code source from TeX82 and PDFTeX (see links in in-code top comments), an effort still partial and incomplete, but at least we are closer...
  • feat: Remove non-standard 'sideways' logic from the line-breaker = See this SILE discussion for some overview. There are interesting TeX resources on the topic, but the current approach is not general (e.g. on floats, columns, repeated contents such as table headers &c), so let's not bother with the "old" and broken attempt...
  • feat: Add missing bits from TeX82 line-breaker on adjdemerits and looseness = Interesting to see missing bits when comparing to TeX82's code... The latter only ticks in when looseness != 0 (i.e. not in the default scenario), but the former is more embarrassing (actually affecting some of my books). No idea why these bits were not implemented, but let's try to be even closer to TeX's Knuth-Plass code now...

This was used by SILE's pagebuilder-bestfit naive experimental
package, which we already forbid with re·sil·ient.
…seness

The looseness missing code is only activated when looseness is not 0,
its default - so won't have any effect with default settings.
The adjdemerits missing code (on fit_class vs current fitness) will
however change some line breakpoints in the general case. It's not
clear why this bit of code was skipped...
@Omikhleia Omikhleia marked this pull request as draft November 12, 2025 22:43
@Omikhleia Omikhleia self-assigned this Nov 12, 2025
@Omikhleia Omikhleia added this to the 3.3.0 milestone Nov 12, 2025
@Omikhleia Omikhleia added bug Something isn't working enhancement New feature or request labels Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant