[HarfBuzz] Fwd: Harfbuzz with linebreaking

kelvinsthirteen at gmail.com kelvinsthirteen at gmail.com
Tue Jun 14 04:23:47 UTC 2016


No, shaping does tell you about breakpoints in the same way that shaping can link back to original character indexes for any other purpose.

For example, if the shaped sentence "make a difference!" overflows at the glyph “ff”, I know to test break points that come before the 11th character in the string ('f'), since “e”, the glyph that comes after “ff” has a cluster value of 11. So I would shape "make a dif-", (and then "make a " instead if that didn’t fit). We know that  f|f  is a breakpoint from analysis of the text, but we only know to USE the  f|f  breakpoint, and not some other breakpoint like the  r|e  breakpoint after it, from looking at the shaping.

In fact I don’t see any other way to do it; each word has at least one (often many) breakpoints, but only one of them gets used per line. And the only way to know which one to use is to shape.

And the safe to break API is an optimization, but a very important one—otherwise the amount of shaping that has to be done explodes out of proportion from the number of lines that are produced because of that multiplication.

On Jun 13, 2016, at 11:50 PM, Simon Cozens <simon at simon-cozens.org> wrote:
> 
>> On 14/06/2016 13:16, Kelvin Ma wrote:
>> The problem is, I have no idea where, in terms of x-coordinate, any of
>> these breakpoints are going to be until I shape them. So I will have to
>> shape the entire sentence.
> 
> You do have to shape the entire sentence, yes. But that's got nothing to
> do with where your breakpoints are. Shaping doesn't tell you anything
> about break points. That's why it's not Harfbuzz's job.
> 
> Let's take your example again. How do you get from:
> 
>> Take these five sentences which I need to break into a paragraph. The
>> shaper is always going to be involved in this. Did you only count two?
> 
> to:
> 
>> |Take |these |five |sen-|ten|-ces |which |I |need |to |break |into |a
>> |para-|graph. |The |sha-|per |is |al-|ways |go-|ing |to |be
>> |in-|vol-|ved |in |this. |Did |you |on-|ly |count |two?|
> 
> Shaping won't give you the hyphenation points. That's a matter of
> language analysis. So you have to do line breaking at the text layer;
> this is *why* Harfbuzz doesn't involve itself in line breaking.
> 
>> You are right. But I hope I explained why the shaping information has to
>> come before the textual-breakpoint information, because without shaping,
>> you don’t know *where* the breakpoints lie
> 
> Even with shaping, you don't know where the breakpoints lie. Shaping and
> breakpoints are completely orthogonal.
> 
> And line breaking *will* change your shaping - think about what happens
> when you break an RTL Hebrew sentence inside a majority LTR text - you
> need to swap around the two ends of the sentence. The safe-to-break API
> is just an optimization; it says, if you break at this point, you won't
> have to reshape. But it doesn't tell you anything about where you
> *should* or *shouldn't* break - that depends entirely on your
> justification strategy.
> 
> Simon
> 


More information about the HarfBuzz mailing list