{"action":"created","issue":{"url":"https://api.github.com/repos/servo/servo/issues/11302","repository_url":"https://api.github.com/repos/servo/servo","labels_url":"https://api.github.com/repos/servo/servo/issues/11302/labels{/name}","comments_url":"https://api.github.com/repos/servo/servo/issues/11302/comments","events_url":"https://api.github.com/repos/servo/servo/issues/11302/events","html_url":"https://github.com/servo/servo/issues/11302","id":155994281,"number":11302,"title":"Selection or insertion point renders incorrectly when inside ligature","user":{"login":"mbrubeck","id":5920,"avatar_url":"https://avatars.githubusercontent.com/u/5920?v=3","gravatar_id":"","url":"https://api.github.com/users/mbrubeck","html_url":"https://github.com/mbrubeck","followers_url":"https://api.github.com/users/mbrubeck/followers","following_url":"https://api.github.com/users/mbrubeck/following{/other_user}","gists_url":"https://api.github.com/users/mbrubeck/gists{/gist_id}","starred_url":"https://api.github.com/users/mbrubeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbrubeck/subscriptions","organizations_url":"https://api.github.com/users/mbrubeck/orgs","repos_url":"https://api.github.com/users/mbrubeck/repos","events_url":"https://api.github.com/users/mbrubeck/events{/privacy}","received_events_url":"https://api.github.com/users/mbrubeck/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/servo/servo/labels/A-layout/text","name":"A-layout/text","color":"d7e102"},{"url":"https://api.github.com/repos/servo/servo/labels/C-assigned","name":"C-assigned","color":"02d7e1"},{"url":"https://api.github.com/repos/servo/servo/labels/E-less%20easy","name":"E-less easy","color":"02e10c"},{"url":"https://api.github.com/repos/servo/servo/labels/I-wrong","name":"I-wrong","color":"e10c02"}],"state":"open","locked":false,"assignee":{"login":"shinglyu","id":3250983,"avatar_url":"https://avatars.githubusercontent.com/u/3250983?v=3","gravatar_id":"","url":"https://api.github.com/users/shinglyu","html_url":"https://github.com/shinglyu","followers_url":"https://api.github.com/users/shinglyu/followers","following_url":"https://api.github.com/users/shinglyu/following{/other_user}","gists_url":"https://api.github.com/users/shinglyu/gists{/gist_id}","starred_url":"https://api.github.com/users/shinglyu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shinglyu/subscriptions","organizations_url":"https://api.github.com/users/shinglyu/orgs","repos_url":"https://api.github.com/users/shinglyu/repos","events_url":"https://api.github.com/users/shinglyu/events{/privacy}","received_events_url":"https://api.github.com/users/shinglyu/received_events","type":"User","site_admin":false},"milestone":null,"comments":7,"created_at":"2016-05-20T15:51:15Z","updated_at":"2016-05-24T18:49:10Z","closed_at":null,"body":"If Servo renders this textbox with a font that has an `ffi` ligature (which includes the default fonts on most systems), and you use the arrow and/or shift keys to position the insertion point or selection boundary within the \"ffi\" string, then Servo draws the selection or insertion point at the wrong location (after the ligature instead of inside it):\r\n\r\n```html\r\n<textarea style=\"font-family: sans-serif;\">ffi</textarea>\r\n```\r\n\r\nWe *could* fix this by re-running text shaping when a selection boundary is moved into a ligature, splitting the text run at the selection boundary so the characters on opposite sides no longer form ligatures.  But this would require reconstructing flows (which is expensive), and it would make glyphs change as the cursor moves around (which is ugly).\r\n\r\nA better solution is to compute where inside the ligature to draw the selection or caret. Gecko does this just by dividing the total width of the ligature evenly over each grapheme clusters it contains. This will require extra [flags][1] in the glyph store to record which glyph entries are ligature starts and cluster starts. Then [advance_for_byte_range][2] will need to use this information to adjust the result if the range includes partial ligatures.  For comparison, Gecko’s code for this is mostly in [GetAdvanceWidth][4] and [ComputeLigatureData][4].\r\n\r\n[1]: https://github.com/servo/servo/blob/8b82eb6a04d80298e083b0c74d2db8cacb340f34/components/gfx/text/glyph.rs#L74-L77\r\n[2]: https://github.com/servo/servo/blob/8b82eb6a04d80298e083b0c74d2db8cacb340f34/components/gfx/text/glyph.rs#L556\r\n[3]: https://dxr.mozilla.org/mozilla-central/rev/c67dc1f9fab86d4f2cf3224307809c44fe3ce820/gfx/thebes/gfxTextRun.cpp#253-273\r\n[4]: https://dxr.mozilla.org/mozilla-central/rev/c67dc1f9fab86d4f2cf3224307809c44fe3ce820/gfx/thebes/gfxTextRun.cpp#1007-1046"},"comment":{"url":"https://api.github.com/repos/servo/servo/issues/comments/221366975","html_url":"https://github.com/servo/servo/issues/11302#issuecomment-221366975","issue_url":"https://api.github.com/repos/servo/servo/issues/11302","id":221366975,"user":{"login":"mbrubeck","id":5920,"avatar_url":"https://avatars.githubusercontent.com/u/5920?v=3","gravatar_id":"","url":"https://api.github.com/users/mbrubeck","html_url":"https://github.com/mbrubeck","followers_url":"https://api.github.com/users/mbrubeck/followers","following_url":"https://api.github.com/users/mbrubeck/following{/other_user}","gists_url":"https://api.github.com/users/mbrubeck/gists{/gist_id}","starred_url":"https://api.github.com/users/mbrubeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbrubeck/subscriptions","organizations_url":"https://api.github.com/users/mbrubeck/orgs","repos_url":"https://api.github.com/users/mbrubeck/repos","events_url":"https://api.github.com/users/mbrubeck/events{/privacy}","received_events_url":"https://api.github.com/users/mbrubeck/received_events","type":"User","site_admin":false},"created_at":"2016-05-24T18:49:10Z","updated_at":"2016-05-24T18:49:10Z","body":"That screencast shows the bug that I was trying to describe.  Servo always paints the entire ligature as selected, even if internally only part of it is selected.  (You can type another letter like \"x\" and only the \"real\" selection will be replaced.)"}}
{"actor":{"display_login":"mbrubeck"}}