Canvas Formatted Text
- Category
- Graphics
- Type
- New or changed feature
- Status
- No longer pursuing (Chrome No longer pursuing)
- Intent stage
- Start incubating
Summary
Easily render multiline formatted text in Canvas, while letting the browser handle the hard parts of line-breaking and other language-specific constraints.
Motivation
You have a paragraph of text. You want to write it to the canvas. Canvas only supplies fill/strokeText -- only line of text at a time. Where do you break your paragraph up? Doing this is JavaScript is hard and error prone. For example, the author must consider: where are the break opportunities between words or Graphemes? Break opportunities are based primarily on the Unicode Spec but also use dictionaries for languages like Thai and French that dictate additional line breaking rules. Other consideration include identifying grapheme clusters, handling Bidi text, proper text shaping and kerning. Luckily, the browser already has a powerful line breaking, text shaping component used for regular HTML layout. This feature enables authors to tap into the browser's layout feature while maintaining control over the layout of multi-line formatted text.
Standards & signals
- Firefox: No signal
- Safari: No signal
- Web developers: No signals
- Tracking bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1155764
Ecosystem
- Web Platform Tests: https://wpt.fyi/results/?q=canvas-formatted-text
- Chrome Platform Showcase: https://chrome-platform-showcase.paulkinlan-ea.deno.net/features
- GenDN reference: https://gendn.paulkinlan-ea.deno.net/features
- chrome.dev demos search: https://www.google.com/search?q=site%3Achrome.dev+Canvas%20Formatted%20Text
- MDN Web Docs: https://developer.mozilla.org/en-US/search?q=Canvas%20Formatted%20Text
- Baseline status: https://webstatus.dev/?q=Canvas%20Formatted%20Text
Explainers: https://github.com/WICG/canvas-formatted-text/blob/main/README.md