Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

advance is measured as distance up to left side of character #3994

Open
r12a opened this issue Sep 4, 2018 · 10 comments
Open

advance is measured as distance up to left side of character #3994

r12a opened this issue Sep 4, 2018 · 10 comments
Labels
i18n-tracker Group bringing to attention of Internationalization, or tracked by i18n but not needing response. topic: canvas

Comments

@r12a
Copy link

r12a commented Sep 4, 2018

https://html.spec.whatwg.org/multipage/canvas.html#dom-textmetrics-advances

advances attribute

Returns a frozen array containing advances for each character in the measured text\. Each advance is measured as the distance from the beginning of the string \(starting at 0\) up to the left side of the character\. 

Does that work the same way for text in right-to-left scripts, such as Arabic, Hebrew, etc?

@r12a r12a added the i18n-tracker Group bringing to attention of Internationalization, or tracked by i18n but not needing response. label Sep 4, 2018
@r12a
Copy link
Author

r12a commented Sep 4, 2018

Oh, and also how does it work for vertically set text?

@annevk
Copy link
Member

annevk commented Sep 5, 2018

cc @whatwg/canvas

@fserb
Copy link
Contributor

fserb commented Sep 5, 2018

On RTL text, the advances will be decreasing and always pointing to the left side of the character, the same as on LTR.

I'm not sure we have vertically set text on canvas, nor I really understand how kerning works on these situations (do we have vertical kerning?)

@annevk
Copy link
Member

annevk commented Sep 5, 2018

There's commented out methods for vertical text on canvas, so I guess that's not supported yet.

@domenic
Copy link
Member

domenic commented Sep 5, 2018

Should we add a clarifying note that it's from the left side even in RTL text? (Assuming that's the right metric.)

@r12a
Copy link
Author

r12a commented Sep 6, 2018

I apologise that i don't know much about canvas, or what the offset information will be used for,, but i have a couple of additional questions.

I guess that it is important to decide where is the position of the 'start of the string', in order to know whether to use positive or negative advances. Presumably that is indicated by the base direction in force for the context in which the string is being used? How will that be detected?

I'm also guessing that in bidi text such as

bidi-right copy

the offsets will still be negative even for the LTR text, based on the fact that the string is in an overall RTL base direction?

@kojiishi
Copy link

Thank you @annevk for adding a link, I wasn't aware this issue was already raised.

In #4026, @litherum and I agree that this should be in the visual order, and that advances are always from left to right (though there are cases where they are negative, such as combining marks.) It makes, however, knowing the advance of, say the 3rd character in the source text harder, because index of advances no longer matches to the index of the source text.

At this point, I don't know how to solve it, nor whether it is needed to be solved. I hope we can find solution if we learn the needs better, so I'm leaning to take the visual order for now, and keep listening to web authors what they want in addition. Opinion on this point is greatly appreciated.

@annevk
Copy link
Member

annevk commented Sep 13, 2018

What happens if multiple code points get rendered as a single glyph? Would a web developer need to know that too? If so, it seems this API is broken and would need to return something more informative.

@annevk
Copy link
Member

annevk commented Sep 13, 2018

Per #4026 (comment) by @jfkthame this is indeed fundamentally broken. @fserb I think the best way forward is to remove this feature for now.

@fserb
Copy link
Contributor

fserb commented Sep 13, 2018

Commenting on the other bug.

domenic added a commit that referenced this issue Sep 14, 2018
This reverts commit 7711a1f. As
discussed in #3995, these changes were made prematurely without
appropriate implementer signoff. Since then, a plethora of issues around
the changes here have been opened up (e.g. #3994, #4023, #4030, #4033,
#4034). We revert these changes until a more complete and agreed-upon
specification can replace them.

Closes #3995.
domenic added a commit that referenced this issue Sep 17, 2018
This reverts commit 7711a1f. As
discussed in #3995, these changes were made prematurely without
appropriate implementer sign-off. Since then, a plethora of issues
around the changes here have been opened up (e.g. #3994, #4023, #4026,
#4030, #4033, #4034). We revert these changes until a more complete and
agreed-upon specification can replace them.

Closes #3995.
mustaqahmed pushed a commit to mustaqahmed/html that referenced this issue Feb 15, 2019
This reverts commit 7711a1f. As
discussed in whatwg#3995, these changes were made prematurely without
appropriate implementer sign-off. Since then, a plethora of issues
around the changes here have been opened up (e.g. whatwg#3994, whatwg#4023, whatwg#4026,
whatwg#4030, whatwg#4033, whatwg#4034). We revert these changes until a more complete and
agreed-upon specification can replace them.

Closes whatwg#3995.
mustaqahmed pushed a commit to mustaqahmed/html that referenced this issue Feb 15, 2019
This reverts commit 7711a1f. As
discussed in whatwg#3995, these changes were made prematurely without
appropriate implementer sign-off. Since then, a plethora of issues
around the changes here have been opened up (e.g. whatwg#3994, whatwg#4023, whatwg#4026,
whatwg#4030, whatwg#4033, whatwg#4034). We revert these changes until a more complete and
agreed-upon specification can replace them.

Closes whatwg#3995.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
i18n-tracker Group bringing to attention of Internationalization, or tracked by i18n but not needing response. topic: canvas
Development

No branches or pull requests

5 participants