- From: Paul Cotton <Paul.Cotton@microsoft.com>
- Date: Wed, 17 Dec 2014 15:40:39 +0000
- To: "public-canvas-api@w3.org" <public-canvas-api@w3.org>
FYI.
Paul Cotton, Microsoft Canada
17 Eleanor Drive, Ottawa, Ontario K2E 6A3
Tel: (425) 705-9596 Fax: (425) 936-7329
-----Original Message-----
From: bugzilla@jessica.w3.org [mailto:bugzilla@jessica.w3.org]
Sent: Wednesday, December 17, 2014 7:35 AM
To: public-html-admin@w3.org
Subject: [Bug 27638] New: FEATURE REQUEST: Selectively enable metrics in measureText using optional second argument
https://www.w3.org/Bugs/Public/show_bug.cgi?id=27638
Bug ID: 27638
Summary: FEATURE REQUEST: Selectively enable metrics in
measureText using optional second argument
Product: HTML WG
Version: unspecified
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P2
Component: HTML Canvas 2D Context
Assignee: jaymunro@microsoft.com
Reporter: motiz88@gmail.com
QA Contact: public-html-bugzilla@w3.org
CC: mike@w3.org, public-html-admin@w3.org,
public-html-wg-issue-tracking@w3.org
Hello,
I am the author of https://github.com/motiz88/canvas-text-metrics-polyfill .
I'd like to make the case for a small enhancement following up on the resolution of https://www.w3.org/Bugs/Public/show_bug.cgi?id=7798 , relating to the properties added to TextMetrics ( https://html.spec.whatwg.org/#drawing-text-to-the-bitmap ).
Background: Browser support for this useful and simple API is still surprisingly scarce (to my knowledge only Chrome Canary has it, behind an experimental flag, with a buggy implementation), so I have written a polyfill (which I believe is the first conforming to this API) based mainly on off-screen drawing and scanning. This approach is rather slow in the general case, but results in a robust and (at least, largely) conforming polyfill.
My suggested enhancement below, already implemented in my polyfill, would enable such polyfills (and possibly native implementations?) to be lighter and faster, in cases where e.g. only one or two metrics are needed out of the whole set. The availability of a fully conforming and performant polyfill may finally spur adoption of this API by developers and browser makers.
<suggestion>
interface CanvasRenderingContext2D {
...
TextMetrics measureText(DOMString text, optional CanvasMeasureTextOptions options); ...
};
interface CanvasMeasureTextOptions {
// x-direction
attribute boolean width; // advance width
attribute boolean actualBoundingBoxLeft;
attribute boolean actualBoundingBoxRight;
// y-direction
attribute boolean fontBoundingBoxAscent;
attribute boolean fontBoundingBoxDescent;
attribute boolean actualBoundingBoxAscent;
attribute boolean actualBoundingBoxDescent;
attribute boolean emHeightAscent;
attribute boolean emHeightDescent;
attribute boolean hangingBaseline;
attribute boolean alphabeticBaseline;
attribute boolean ideographicBaseline; };
Augmented semantics of measureText():
If the options argument is missing or null, measureText() behaves as currently specified, and must return a TextMetrics object with valid values set on all its specified properties.
If there is a non-null options argument, then the returned TextMetrics object is only required to contain the set of properties whose names coincide with the names of properties on the options object which are both (1) set, and (2) equal to true. The TextMetrics object MAY additionally contain some properties it is not required to, in which case their values are not defined.
</suggestion>
I would appreciate any feedback on this.
Thanks,
Moti Zilberman
--
You are receiving this mail because:
You are on the CC list for the bug.
Received on Wednesday, 17 December 2014 15:41:10 UTC