W3C home > Mailing lists > Public > whatwg@whatwg.org > August 2011

[whatwg] Requesting TextMetrics baseline property

From: Charles Pritchard <chuck@jumis.com>
Date: Tue, 30 Aug 2011 15:19:31 -0700
Message-ID: <4E5D61F3.1040902@jumis.com>

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:
https://developer.mozilla.org/en/drawing_text_using_a_canvas
http://www.whatwg.org/specs/web-apps/current-work/images/baselines.png

It can, but we have to do css hacks/edge detection, as measureText is 
insufficient.
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.

-Charles
Received on Tuesday, 30 August 2011 15:19:31 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:35 UTC