Bug 236477 - letter-spacing is totally broken in Burmese and Thai and Lao
Summary: letter-spacing is totally broken in Burmese and Thai and Lao
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Text (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on: 236489
Blocks:
  Show dependency treegraph
 
Reported: 2022-02-10 17:29 PST by Myles C. Maxfield
Modified: 2022-02-17 17:30 PST (History)
2 users (show)

See Also:


Attachments
Test case (6.35 KB, text/html)
2022-02-10 17:29 PST, Myles C. Maxfield
no flags Details
Test case (217 bytes, text/html)
2022-02-10 17:31 PST, Myles C. Maxfield
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Myles C. Maxfield 2022-02-10 17:29:24 PST
Created attachment 451625 [details]
Test case

WebKit destroys the shapes of the letters. Compare to Chrome / Firefox.
Comment 1 Myles C. Maxfield 2022-02-10 17:31:26 PST
Created attachment 451626 [details]
Test case
Comment 2 Myles C. Maxfield 2022-02-10 17:34:52 PST
Oh, wow, ComplexTextController applies letter-spacing to _every glyph_. That's totally bogus.
Comment 3 Myles C. Maxfield 2022-02-10 23:29:20 PST
It looks like the correct iterator to use is kCFStringCursorMovementCluster.

This is turning out to be harder than I thought it would be. Because Burmese text is so complicated, it looks like I can't:

- add space to the right side of a glyph if the character just after the character the glyph corresponds to is a boundary, because of the string "ဂြို". This string has 4 code points, but no glyph corresponds to the last code point - the last glyph corresponds to the second-to-last and last code points together.
- add space to the left side of a glyph if the character the glyph corresponds to is a boundary, because of the same string "ဂြို". Here, the leftmost character corresponds to string index 1 and then the next glyph corresponds to string index 0. Therefore, if we did this, we'd inject letter-spacing in the middle of the cluster.

I think the solution is to keep track of cluster boundaries as we iterate across glyphs, and insert space to the right of a glyph if the current glyph and the next glyph belong to different clusters.
Comment 4 Myles C. Maxfield 2022-02-10 23:43:11 PST
https://twitter.com/OhBendy/status/1492033041988001837 indicates that this is a problem for Thai and Lao too.
Comment 5 Radar WebKit Bug Importer 2022-02-17 17:30:31 PST
<rdar://problem/89118337>