<div dir="ltr">I've just started looking at HarfBuzz and I'm trying to get a better understanding of how it would work as part of a complete text formatting system.  In particular I would like to understand how line-breaking is supposed to interact with HarfBuzz's shaping.<div>

<br></div><div>Suppose, for example, I have a paragraph whose content is "This is difficult."  I'm guessing that the first step is to get HarfBuzz to shape the entire content.  Now let's suppose that I've decided to break this as:</div>

<div><br></div><div>  This is dif-</div><div>  ficult.</div><div><br></div><div>In general, this may require reshaping: for example, difficult might have used an "ffi" ligature.  I can of course do this reshaping just by passing "This is dif-" and "ficult" again to the Harfbuzz shaper. However, apart from being inefficient, that would not be workable if I want to do Knuth-Plass style optimized line-breaking.</div>

<div><br></div><div>Given that I have already shaped "This is difficult.", I would hope that there would be some way to figure out how many characters on each side of the break I need to reshape.  For example, probably in this case it is enough to just reshape the "f-" before and "fi" after the break.  However, I don't see how I can figure this out from the information that HarfBuzz supplies.  I can think of various heuristics (eg stopping at whitespace) but I can't think of algorithm for doing this that will be correct regardless of the font.</div>

<div><br></div><div>James</div></div>