[whatwg] Canvas lack of drawString method

Stefan Haustein sh at kobjects.org
Tue Oct 17 14:50:41 PDT 2006


I would like to second the drawString() request.

It makes sense to have a simple API, but it should be balanced with 
application simplicity and readability to some extent. Doing CSS black 
magic to overlay text and a Canvas object just seems inadequate for 
something like axis labeling.

As noted earlier by somebody else (did not find the mail...), we would 
also need a simple Font object, but the minimum requirements seem rather 

Font Canvas.createFont(String cssFontProperties);
Canvas.setFont(Font font) // set current font
Canvas.drawString(int x, int y, String text);
Font Canvas.getFont() // current font

int Font.stringWidth(String s);
int Font.getHeight();  // includes leading
int Font.getBaselinePosition();
int Font.getAscent();
int Font.getDescent();

Best regards
Stefan Haustein

Alfonso Baqueiro wrote:
> Hello Charles,
> 2006/10/17, Charles Iliya Krempeaux <supercanadian at gmail.com 
> <mailto:supercanadian at gmail.com>>:
>     Hello Alfonso,
>     On 10/17/06, *Alfonso Baqueiro* < abaqueiro at gmail.com
>     <mailto:abaqueiro at gmail.com>> wrote:
>         The canvas component is very promising, but the lack of
>         drawString method could be a great error for its success, this
>         lack is a huge limitation, how could you resolve this problem?
>     I believe that some people's reason for not wanting to add it was
>     because of Accessibility concerns.
>     Although normal text in a webpage... or even a text image (with
>     the "alt" attribute filled in properly) could be "read" by a
>     person with disabilities, text embedded in the canvas element
>     could not.
>     Perhaps people need to think about how to add Accessibility to the
>     canvas while allowing a "drawString" procedure.
> Well a drawString method in canvas can be used for drawing the axis 
> labels or values on a dinamic javascript graphic, but is non sense an 
> aural reader read it, theres no way (yet) to read an image to a 
> blinded people, there are cases where is imposible the accessibility, 
> is imposible for a blind to play video games, and accessibility dont 
> stop the video games creation. In the case of images or the canvas the 
> alt attribute could do the job.
>     See ya

More information about the whatwg mailing list