Modify existing Canvas 2D API to expose text baseline and facilitate drawing of focus rings
This proposal modifies the Canvas 2D API to expose a text baseline property to facilitate drawing of focus rings around text to support screen magnifier users and render a point of regard necessary to meet WCAG 2. This is an updated change proposal to address outstanding issues from the decision on the Issue 131 Change Proposal.
WHAT IS NEW INFORMATION:
We now provide a precise definition of which text baseline we are referring to in the details section of this change proposal. Specifically:
The new more detailed definition of which text baseline we are requesting exposed through text metrics:
Added the attribute, baseline, to TextMetrics to acquire the baseline of text. The text baseline is set to the anchor point's vertical position as determined by the current textBaseline value, in CSS pixels.
This is a change over the last proposal for text baseline which makes no reference to the anchor points vertical baseline:
Added the property baseline to TextMetrics to acquire the baseline of text.
Also, as requested by Maciej, we have provided a diff (in the details section) from the original spec. which illustrates how the anchor point's vertical position is calculated.
The reason for this change proposal is to address an outstanding issues resulting from the chairs' decision on the Issue 131 change proposal related to the Canvas 2D API specification. It is also to address an editorial issue related to the omission of Caret and Selection management in the table of contents.
The chairs asked for a clear definition of the text baseline we were requesting added to textMetrics as the canvas specification refers to different baselines and a clearer definition of such information was required as stated in this text from the working group decision:
"However, in examining the bug originally proposing this change, we noted the editor's question 'which baseline?'. As alluded to by the editor, in typography there are many possible definitions of baseline. The Change Proposal does not specify which to use, and does not mention how the measureText() method is supposed to fill it in, in the way it does for the "width" attribute of the TextMetric interface.
Therefore, while the use case seems valid, we find that the Change Proposal does not provide a sufficiently detailed description of the changes necessary to specify it. This constitutes a strong objection to this aspect of the "Modify existing Canvas 2D API caret and focus ring support proposal". This could be rectified by a future, separately raised proposal that provides sufficient detail."
In order to compute drawing rings bounds, bounds for highlighted text, and text caret positions we need access to the text anchor point's vertical position as determined by the current text baseline's value in CSS pixels. Without this property we cannot generate the following text baseline images in canvas without the use of CSS hacks/edge detection, as measureText is insufficient:
This is the revised modifications to the Canvas 2D API Specification and its associated diff (review diff with a text editor) with details of the change listed here:
- Added the attribute, baseline, to TextMetrics to acquire the baseline of text. The text baseline is set to the anchor point's vertical position as determined by the current textBaseline value, in CSS pixels.
- Corrected the table of contents and the section numbers to reflect the added "Caret and Selection Management" left out by the changes applied in response to issue 131 (editorial).
The impact to the specification is minor and it minimizes the impact to authors while producing a more reliably accessible solution.
- Fixes the table of contents and the heading numbers that were not adjusted as a result of the changes in response to issue 131
- Text Baseline:
- Exposes the text baseline in CSS pixels to allow an author to compute the dimensions of a focus ring, text highlight, or caret for drawing.
- It allows allows the author to manage style markers on spans of text presenting different baselines.
- HTML Canvas 2D Context
- Working Group decision on Issue 131
- Modifications to 2D Context (earlier version but still applicable)
- Bug 11342 Request to expose text baseline in TextMetrics
- Bug 11239 Canvas support accessible caret tracking independent of Focus Ring tracking (with refrence to code to implement Bug 11342