- From: Charles Pritchard <chuck@jumis.com>
- Date: Tue, 30 Aug 2011 15:56:04 -0700
On Aug 30, 2011, at 3:26 PM, "Tab Atkins Jr." <jackalmage at gmail.com> wrote: > On Tue, Aug 30, 2011 at 3:19 PM, Charles Pritchard <chuck at jumis.com> wrote: >> >> 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. > > Agreed, though there are multiple baselines that could be requested. > The diagram you link to points out three of them. The alphabetic > baseline is what you want most of the time, but all of them can be > useful depending on the type of text you're formatting. The author would have to set ctx.textBaseline, and re-run TextMetrics for each baseline they are incorporating. The enumeration of supported baselines is already in the canvas spec.
Received on Tuesday, 30 August 2011 15:56:04 UTC