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

Comments

5 participants
@r12a
Collaborator

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-tracking label Sep 4, 2018

@r12a

This comment has been minimized.

Show comment
Hide comment
@r12a

r12a Sep 4, 2018

Collaborator

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

Collaborator

r12a commented Sep 4, 2018

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

@annevk annevk added the topic: canvas label Sep 5, 2018

@annevk

This comment has been minimized.

Show comment
Hide comment
@annevk
Member

annevk commented Sep 5, 2018

@fserb

This comment has been minimized.

Show comment
Hide comment
@fserb

fserb Sep 5, 2018

Contributor

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?)

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

This comment has been minimized.

Show comment
Hide comment
@annevk

annevk Sep 5, 2018

Member

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

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

This comment has been minimized.

Show comment
Hide comment
@domenic

domenic Sep 5, 2018

Member

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

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

This comment has been minimized.

Show comment
Hide comment
@r12a

r12a Sep 6, 2018

Collaborator

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?

Collaborator

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

This comment has been minimized.

Show comment
Hide comment
@kojiishi

kojiishi Sep 13, 2018

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.

kojiishi commented Sep 13, 2018

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

This comment has been minimized.

Show comment
Hide comment
@annevk

annevk Sep 13, 2018

Member

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.

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

This comment has been minimized.

Show comment
Hide comment
@annevk

annevk Sep 13, 2018

Member

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

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

This comment has been minimized.

Show comment
Hide comment
@fserb

fserb Sep 13, 2018

Contributor

Commenting on the other bug.

Contributor

fserb commented Sep 13, 2018

Commenting on the other bug.

domenic added a commit that referenced this issue Sep 14, 2018

Revert "Add advances to TextMetrics and change baselines API"
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

Revert "Add advances to TextMetrics and change baselines API"
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment