<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body 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 id="AppleMailSignature"><br></div><div id="AppleMailSignature">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 id="AppleMailSignature"><br></div><div id="AppleMailSignature">But "something else" (e.g. code that needs to be written) would be needed for paragraphs. </div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">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 id="AppleMailSignature"><br></div><div id="AppleMailSignature">Best,</div><div id="AppleMailSignature">Adam<br><br>Sent from my mobile phone.</div><div><br>On 13.06.2016, at 17:00, Kelvin Ma <<a href="mailto:kelvinsthirteen@gmail.com">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">typesetter app</a>)<br></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>HarfBuzz mailing list</span><br><span><a href="mailto:HarfBuzz@lists.freedesktop.org">HarfBuzz@lists.freedesktop.org</a></span><br><span><a href="https://lists.freedesktop.org/mailman/listinfo/harfbuzz">https://lists.freedesktop.org/mailman/listinfo/harfbuzz</a></span><br></div></blockquote></body></html>