Hi Patrick, have you seen https://github.com/michal-h21/linebreaking/blob/master/linebreaker.lua ? I think I tried exactly what you want (plus river detection, which doesn't work really well). Regarding your question, every `hlist` node has `glue_sign` and `glue_set` attributes, I tested for overfull boxes with:
--------- function linebreaker.par_badness(head) local n = 0 for line in node.traverse_id(0, head) do print(get_text(line.head), line.glue_order, line.glue_sign, line.glue_set) -- glue_sign: > 0 = normal, 1 = stretch, 2 = shrink -- we count only shrink, but stretch may result in overfull box as well -- I just don't know how to detect which value of glue_set means error if line.glue_sign == 2 and line.glue_set >= 1 then n = n + 1 end end; return n end ------------ I think I've found these vales by experimenting, I couldn't find exact meaning of `glue_set`. So this function just count number of overfull boxes in the paragraph. Michal 2014-12-05 13:30 GMT+01:00 Patrick Gundlach <[email protected]>: > Hello, > > I believe I have asked this question before (sorry). When I call > tex.linebreak(): is there a way to find out if a "overfull hbox" message > occurred (without parsing the log file)? > > I want to reformat a paragraph until no line sticks over the right margin by > increasing some parameters such as emergencystretch. I can now look at the > result and call node.dimensions for every line, but I am looking for an > easier (and cheaper) way. > > Patrick > > >
