[whatwg] 2D canvas feature proposal: text decoration

Ian Hickson ian at hixie.ch
Tue Aug 20 15:32:11 PDT 2013


On Thu, 18 Apr 2013, Justin Novosad wrote:
>
> This is a really simple proposal to add support for text decorations in 
> 2D canvas contexts.
> 
> IDL to add to interface CanvasDrawingStyles:
> 
> attribute DOMString textDecoration;
> 
> It would support all the same modes as the 'text-decoration' CSS 
> property (except inherit), and default would be 'none'.

That's anything but simple. :-)

The CSS text-decoration model is actually quite complex. Also, there have 
been many proposals to split 'text-decoration' into sub-properties, so it 
is only going to get more complicated from there.

What's your use case? That is, when do you need to underline text?


On Thu, 18 Apr 2013, David Dailey wrote:
>
> You know, I'm not quite sure why we have text in canvas at all. It's not 
> really text you know -- it's just a bunch of pixels. You can't select 
> it, you can't copy it to the clipboard, it's not accessible without a 
> bunch of effort that authors generally don't use. It's generally illegal 
> in most civilized places. Why not use SVG?

Or, indeed, HTML.


> It's got text decoration. Text is text. It's just that the more 
> conspiratorial and selfish of the browser vendors back when things were 
> being voted on seemed to push canvas since they already owned it and SVG 
> seemed "hard" and like they might have to learn something by way of 
> graphics in their corporate portfolios.

That's not quite how it went down.

There are times where you really need text in your canvas, e.g. if you 
want to label things in your Mandelbrot set viewer.


On Sat, 20 Apr 2013, Nils Dagsson Moskopp wrote:
> 
> That said, I suspect that anything that makes it easier to create text 
> in canvas can and will be used to create inaccessible interfaces. My 
> personal experience regarding web accessability is very frustrating – 
> authors generally do not care, even if they know about it.
> 
> FYI, I have problems with low-contrast text, but at least I can correct 
> for that using user stylesheets. How would I do that with canvas text?

You cannot (same as with text in a PNG).


On Thu, 18 Apr 2013, Rik Cabanier wrote:
> 
> I checked and the values in CanvasDrawingStyles don't correspond with CSS
> values so it should be OK to turn them into enums.

They're mostly just DOMStrings because I haven't gotten around to changing 
them. Changing strings to enums is risky (I could introduce bugs when 
doing so), so I tend to avoid doing so unless someone makes a specific 
explicit request for a specific property to be converted.


On Fri, 19 Apr 2013, Justin Novosad wrote:
> 
> That sounds OK. However, I would find it unfortunate to re-specify the 
> behavior of the property in the canvas 2d context spec, when we could 
> just spec it like 'font' by saying that it is interpreted the same way 
> as the corresponding CSS property. I think it is a good idea to keep in 
> sync with CSS whenever we can.

Unfortunately, "just" is not really the right word here. The CSS inline 
box model, including the text-decoration part, are non-trivial. CSS has to 
deal with all kinds of things that we don't have to deal with in <canvas>, 
e.g. multiple baselines, multiple lines, etc.


> FWIW, some of the other properties have good reasons for being 
> re-specified in the 2d canvas spec. For example, text alignment works 
> very differently in CSS vs. 2D canvas.

Right. Underlining may fall into this bucket too.


But before we can determine this, we need to determine what your use case 
is. What are you trying to do? Why?

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'


More information about the whatwg mailing list