[HarfBuzz] Fwd: Harfbuzz with linebreaking
Simon Cozens
simon at simon-cozens.org
Tue Jun 14 03:50:58 UTC 2016
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