[whatwg] Requesting TextMetrics baseline property

Charles Pritchard chuck at jumis.com
Tue Aug 30 15:19:31 PDT 2011

I'd like to see a new property added to the TextMetrics object from 
Canvas 2d.

var t = ctx.measureText('text span');
t == { width: int, baseline: int };

The baseline corresponds to the vertical offset of the anchor point.
A tiny number. It's not the same as height, but it has a similar use.

It allows allows the author to manage style markers on spans of text 
presenting different baselines.

The following textBaseline image can not be generated in canvas:

It can, but we have to do css hacks/edge detection, as measureText is 
By exposing the baseline offset in the TextMetrics method, we would be 
able to generate
the lines in that image, and appropriately position the text captions.

It seems appropriate that the illustration for textBaseline be something
that can be easily generated from within canvas. The same standard is held
for SVG documentation.


More information about the whatwg mailing list