<div dir="ltr">What I need is something to bridge that gap between the 1-line of unbroken text that harfbuzz generates, and the fragments I need to be able to assemble a multi-line paragraph.<br><div class="gmail_quote"><div dir="ltr"><div><div><br></div>What Freetype does is give me images of individual letters, which I can then put together to make words and sentences, because words and sentences are made up of individual letters. But I cannot do that with harfbuzz because its output is one line of text, whereas I need smaller pieces that I can use to build a paragraph. The only way to get these pieces is to find the spots in the shaped text where the whole line can be shaped in two pieces with an identical result. This requires knowledge of all the glyph shaping rules and opentype features, which is why it sounds like it can *only* be HarfBuzz’s responsibility.<br><br></div>There is only one “workaround” I’ve seen (the mozilla one) where it simply assumes each space-separated word is a fragment that will not affect the shaping of its neighbors. But this only works for justified text; in many fonts the space is kerned with letters such as T and L.<br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 13, 2016 at 7:44 PM, Adam Twardoch (List) <span dir="ltr"><<a href="mailto:list.adam@twardoch.com" target="_blank">list.adam@twardoch.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>Both XeTeX and Mozilla Firefox have opensource code which uses HarfBuzz for line setting but combines it with other techniques to perform paragraph-level line breaking, hyphenation and justification. </div><div><br></div><div>In a way, FreeType takes a font, glyph ids and their positions, and delivers an image. HarfBuzz takes a font and plain Unicode text, and delivers glyph ids and their positions in a line. </div><div><br></div><div>But "something else" (e.g. code that needs to be written) would be needed for paragraphs. </div><div><br></div><div>Paragraph setting is not at all easy, and can be done in a number of ways. If your paragraphs are always left-aligned, rectangular, and don't use hyphenation, then it’s easy. But if they need to wrap around graphics or use freeform margins, use hyphenation, multiple fonts etc. — the code needs to deal with situations that are completely out of scope for HarfBuzz. Yes, even setting one word in bold or italic would require the paragraph composer code to be aware of multiple fonts and some kind of “markup” or “rich text” — something that HarfBuzz doesn’t do and isn’t intended for. </div><div><br></div><div>Best,</div><div>Adam<br><br>Sent from my mobile phone.</div><div><div><div><br>On 13.06.2016, at 17:00, Kelvin Ma <<a href="mailto:kelvinsthirteen@gmail.com" target="_blank">kelvinsthirteen@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><div><div><div>So I’ve not received an answer to this anywhere, so, how do I typeset paragraphs with Harfbuzz? How do I use the ‘safe-to-break’ iterator?<br><br></div>Because it sounds like right now I’d have to shape the *entire* paragraph as one line, then find the last shaped glyph that falls before the cutoff point, then iterate backwards from the character corresponding to the glyph following *that*, on each breakpoint, reshaping the whole line each time until something fits. Then I’d have to do that all over again for the second line until the entire paragraph is shaped. So to typeset 5 lines of text I’d have to shape about 22 lines of text. To typeset a 20 line paragraph I’d have to shape about 240 lines of text.<br><br></div>Surely this is not how harfbuzz expects users to use it?<br><br></div>(Asking because I need harfbuzz for my <a href="https://github.com/kelvin13/Knockout" target="_blank">typesetter app</a>)<br></div>
</div></blockquote></div></div><blockquote type="cite"><div><span>_______________________________________________</span><span><br><span>HarfBuzz mailing list</span><br><span><a href="mailto:HarfBuzz@lists.freedesktop.org" target="_blank">HarfBuzz@lists.freedesktop.org</a></span><br><span><a href="https://lists.freedesktop.org/mailman/listinfo/harfbuzz" target="_blank">https://lists.freedesktop.org/mailman/listinfo/harfbuzz</a></span><br></span></div></blockquote></div></blockquote></div><br></div>
</div></div></div><br></div>