• Etienne Bergeron's avatar
    Fix script intersection when performing ItemizeTextToRuns · d07fc52f
    Etienne Bergeron authored
    This CL applying multiple change to fix the way ItemizeTextToRuns
    split a sequence of codepoints into runs with same/compatible
    scripts.
    
     *) Increase kMaxScripts to support codepoints with large amount of scripts.
        Some codepoint has much more than the previous maximum 5 scripts
        (see indic_fraction test u+A830, dev_danda u+0964).
    
     *) Only rely on Script extensions to find longest script interval
        see: http://www.unicode.org/reports/tr24/tr24-29.html
        (more specifically Table 7. Script_Extensions Examples)
    
        Cases where script was 'Common' and Script Extensions has a set of
        explicit script was not handled properly.
    
                     Script       Script Extensions     Results
         Previously: Common       {Hira Kana}       ->  {Hira Kana Common}
         Currently:  Common       {Hira Kana}       ->  {Hira Kana}
    
        This mistake has the consequene to put lot of codepoints from different
        scripts into the same bucket ('common') and there won't be a font that
        can renders (too) different scripts. Which is causing expensive fallback
        fonts lookups.
    
        ""
          U+30FC  Scx = {Hira Kana}  Script = Common
    
          Example 1. Mixed script detection for spoofing.
          Using the Script property alone, for example, will not detect that the U+30FC
          KATAKANA-HIRAGANA PROLONGED SOUND MARK (Script=Common) should not be mixed with
          Latin.
        ""
    
      *) Inherited script should only be applied to the previous codepoint.
         It was incorrectly intersected with the previous or the next one.
    
    [ RUN      ] ItemizeTextToRunsScripts/RenderTextTestWithRunListCase.ItemizeTextToRuns/diac_lat
    ../../ui/gfx/render_text_unittest.cc(930): error: Expected equality of these values:
      param.expected
        Which is: "[0][1->2]"
      GetRunListStructureString()
        Which is: "[0->2]"
    
        That was causing more codepoints to be appended to long sequence of script
        when type was 'Common'.
    
    
    Bug: 1017194
    Change-Id: Ia1339697a44d0d7bbac389997e9fa2878e6eac1d
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1876489Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
    Reviewed-by: default avatarAlexei Svitkine <asvitkine@chromium.org>
    Commit-Queue: Etienne Bergeron <etienneb@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#710416}
    d07fc52f
render_text_unittest.cc 255 KB