WICG / canvas-formatted-text

Other
82 stars 17 forks source link

New capability: per-line formatting #48

Closed travisleithead closed 2 years ago

travisleithead commented 2 years ago

This PR adds a new capability to FormattedText construction in order to provide "line-at-a-time" formatting: lines. Rather than formatting all of the constructed text in one shot (via format), the new capability instead performs partial formatting enough to identify the next line break given the specified inline size contraint. The mechanism to generate the lines conforms to the JavaScript iterator protocol. The output of each step of the iterator is a FormattedTextLine instance, and it is the responsibility of the caller to collect and place these lines as desired. Unlike format, results of the iterator are not collected under a single "container" object, and so FormattedText container-specific functionality will not be available for line metrics generated via this method.

Finally, the coordinate spaces section has been re-written: two coordinate spaces are introduced--one for easily handling pointer input, and one for easily handling relative line metrics regardless of writing mode/direction.

Fixes #46

travisleithead commented 2 years ago

Not ready for merging yet...

travisleithead commented 2 years ago

OK, ready for review.

travisleithead commented 2 years ago

Note: I'm considering a few alternative designs... stay tuned.