Closed Bug 1310559 Opened 5 years ago Closed 4 months ago

Use UEastAsianWidth in GetUnicharWidth

Categories

(Core :: Internationalization, defect, P3)

defect

Tracking

()

RESOLVED FIXED
95 Branch
Tracking Status
firefox52 --- wontfix
firefox95 --- fixed

People

(Reporter: m_kato, Assigned: jfkthame)

References

Details

Attachments

(2 files, 1 obsolete file)

GetUnicharWidth only supports UTF-16.  But now, we have ICU, so we can use ICU function (UCHAR_EAST_ASIAN_WIDTH) for this to support U+10000+ .
Summary: Use UEastAsianWidth in GetUnicharWidth/ → Use UEastAsianWidth in GetUnicharWidth
Priority: -- → P3

The GetUnicharWidth function has a bunch of hardcoded Unicode ranges for combining characters and for "wide" (East Asian) chars, but these have not been kept up to date with new versions of Unicode.

We should instead use Unicode character property APIs, and get rid of the hardcoded ranges here.

In addition, GetUnicharStringWidth looks like it was written before supplementary-plane characters were even a thing, and is oblivious to surrogate pairs. So any supplementary-plane characters will count as width=2, regardless of whether they're really "wide" or "narrow".

Assignee: nobody → jfkthame
Status: NEW → ASSIGNED

Now that GetUnicharStringWidth is aware of surrogate pairs, we also need to handle them here
so that the count doesn't get out of sync with what we originally measured.

Attachment #9244759 - Attachment is obsolete: true
Pushed by jkew@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/a89547fb5bb0
Modernize (and simplify) GetUnicharWidth implementation. r=m_kato
https://hg.mozilla.org/integration/autoland/rev/b7f3c5a2704f
Update GetUnicharStringWidth implementation to handle surrogate pairs. r=m_kato
Status: ASSIGNED → RESOLVED
Closed: 4 months ago
Resolution: --- → FIXED
Target Milestone: --- → 95 Branch
Regressions: 1747114
You need to log in before you can comment on or make changes to this bug.