Line Breaking

If you're drawing more than a few words, the first thing you have to do when drawing text on the screen is to break it up into lines. Usually a text-rendering process will maintain a line starts array that lists the offset in the backing store of the first character of each line of rendered text. To draw a block of text, you must first build that line starts array.

Dividing a block of text up into lines generally proceeds in three conceptual phases:

1.
Locate all the positions in the text where a line break has to go. This step divides the text into a series of blocks. For the purposes of this discussion, we'll call these blocks “paragraphs,” although most word processing programs allow forced line breaks within a paragraph.
2. ...

Get Unicode Demystified now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.