WICG / canvas-formatted-text

Other
82 stars 17 forks source link

FormattedText size and text decorations #56

Open schenney-chromium opened 10 months ago

schenney-chromium commented 10 months ago

FormattedText provides a width/height of the line, which has two potential meanings in the presence of text decorations like shadows, underlines etc.

In standard web contexts, text decorations do not contribute to text size for the purposes of computing overflow (scrollbars) or otherwise have any impact on how the text is laid out. This is an important principle: text decorations do not affect layout. This argues for not including decorations in the metrics, if only because it would make it possible to reproduce standard HTML line layout when rendered.

But when rendering lines in a canvas, maybe you want to know how much bigger the painted area is when shadows and decorations are applied. In particular, you may wish to prevent visual overlap. Such information could be provided; it is the ink overflow.

The obvious options are to define it as one or the other, or provide both, or make it a parameter. I lean toward defining it as the scrollable overflow size.