[whatwg] [Canvas] Text height

The measureText method in canvas' 2d context only returns the width of a span of text. Why not the height? 
I understand the desire to keep text rendering simple but for people that want to expand on this even a little bit needing to work around not having access to the height only complicates the simplicity of the whole thing.

Already included in the canvas context is the ability to set the context.textBaseline, this is actually a rather advanced feature I would think but the problem is that if you are changing it from the default and filling text at 0,0 the text will be rendered off the screen. To figure out the position that the text needs to be rendered to get it back on the screen with a textBaseline as 'alphabetic' you would need the height of the text I would think? Also if you are rendering a few lines of text, you would want to know the height of the last line to know where the next line should be rendered. 

Early versions of Bespin used the width of a 'm' character to guess at what the height of all characters would be. This is far to obscure for the standard user to figure out or even have an understanding why in my mind. But that trick doesn't work with fonts that don't have standard proportions. 

I have seen other far more complicated ways to get at the same information but how about just adding height to the measureText method?

Here are some post around the internet of people complicating things to get at this information
http://stackoverflow.com/questions/1134586/how-can-you-find-the-height-of-text-on-an-html-canvas
http://www.html5rocks.com/en/tutorials/canvas/texteffects/#toc-text-shadow-clipping
http://mudcu.be/journal/2011/01/html5-typographic-metrics/#measure


This is my first post to this list, I'm sorry if this isn't formatted the way proposals should be. 
I'm happy to include more information or examples if needed.
I have other ideas to add but I thought I would start here, one property at a time.

Thanks, 
Tyler Larson

Received on Monday, 23 April 2012 10:29:29 UTC