bramstein / typeset

TeX line breaking algorithm in JavaScript
BSD 2-Clause "Simplified" License
990 stars 74 forks source link

Some questions #30

Open NicolasPineau opened 3 years ago

NicolasPineau commented 3 years ago

Hi,

This is not an issue, I apologize if this is an abuse of issue tracker. I'm currently using your work (great job !) in a little project of canvas text editor. I've some questions, I keep trying to find answers from my own but in case you have some clues...

Thanks in advance, Nicolas.

PhilterPaper commented 3 years ago

Regarding the second issue, if an unbreakable "word" is longer than the entire line I think it would be reasonable to arbitrarily break it (to fit), otherwise it can never be fitted. It might first try condensing (squeezing) the text a reasonable amount to cram it into the line. I may have run into this problem with #31 when I tried very short line lengths -- typeset (actually, Perl Text::KnuthPlass, translated from typeset) quit very early and produced no output. Until I get the issue of line lengths resolved, I can't be sure of what's going on here.

PhilterPaper commented 2 years ago

Regarding the first issue, notice in examples/article the "left" justified example is done with a higher tolerance (4) than the other four examples (tolerance of 3). I don't see any explanation for this, but the author apparently saw it.

Add: In the code, there is a "tolerance" setting that defaults to 30. I haven't looked at it in detail to see if it's the same tolerance used in the setting. It seems odd that 30 is quite a bit different than something in the 1..4 range. According to a comment in linebreak.js, tolerance seems to be the maximum acceptable ratio value for a trial layout to be further considered. Anything beyond that is discarded without further consideration. So in examples/article, there was apparently a ratio in excess of 3 (very, very loose) in one case, that the author wanted to be considered. The first try is with 1, and if that ratio is exceeded, try 2 and then 3 (and in one sample, 4).