New issue
Advanced search Search tips

Issue 739641 link

Starred by 3 users

Issue metadata

Status: Fixed
Owner:
Closed: Oct 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows , Mac
Pri: 2
Type: Bug

Blocking:
issue 454835
issue 603386



Sign in to add a comment

RenderTextHarfbuzz doesn't handle <country code> -> Flag Emoji like "🇬🇧" . Also, it DCHECKs when selecting it.

Project Member Reported by tapted@chromium.org, Jul 6 2017

Issue description

Chrome Version       : 61.0.3150.0
OS Version: OS X 10.12.5

Cocoa and RenderTextMac renders it OK, but RenderTextHarfbuzz draws "GB" on Windows and Mac. Mac gets boxes around the letters.

Note I'm not sure if there's a font on Windows 10 that can draw it properly - I get "GB" if I paste into system dialogs too. But we should be able to get the right glyph on Mac.

DCHECK failure is

[83253:775:0706/180932.937341:FATAL:render_text_harfbuzz.cc(734)] Check failed: total > 0 (0 vs. 0)
0   libbase.dylib                       0x0000000111a2673e base::debug::StackTrace::StackTrace(unsigned long) + 174
1   libbase.dylib                       0x0000000111a267dd base::debug::StackTrace::StackTrace(unsigned long) + 29
2   libbase.dylib                       0x0000000111a24c6c base::debug::StackTrace::StackTrace() + 28
3   libbase.dylib                       0x0000000111ac387f logging::LogMessage::~LogMessage() + 479
4   libbase.dylib                       0x0000000111ac11f5 logging::LogMessage::~LogMessage() + 21
5   libgfx.dylib                        0x00000001286dc758 gfx::internal::TextRunHarfBuzz::GetGraphemeBounds(gfx::RenderTextHarfBuzz*, unsigned long) const + 1048
6   libgfx.dylib                        0x00000001286dd10f gfx::internal::TextRunHarfBuzz::GetGraphemeWidthForCharRange(gfx::RenderTextHarfBuzz*, gfx::Range const&) const + 623
7   libgfx.dylib                        0x00000001286e2f15 gfx::RenderTextHarfBuzz::GetSubstringBounds(gfx::Range const&) + 2933
8   libgfx.dylib                        0x000000012871e7a5 gfx::RenderText::DrawSelection(gfx::Canvas*) + 101
9   libgfx.dylib                        0x000000012871e592 gfx::RenderText::Draw(gfx::Canvas*) + 466
10  libviews.dylib                      0x000000013d54edaf views::Textfield::PaintTextAndCursor(gfx::Canvas*) + 1087
11  libviews.dylib                      0x000000013d54e93b views::Textfield::OnPaint(gfx::Canvas*) + 59

Repro: show Bookmarks bubble, paste "🇬🇧" drag-select it from left to right 
 
mac_rtm_top_rthb_bottom.png
11.9 KB View Download
rthb_gb_mac.png
17.2 KB View Download
rthb_gb_win.png
47.1 KB View Download
Blocking: 454835
On the Windows front. The latest Windows 10 build announcement touts "Support for emoji 5.0"

https://blogs.windows.com/windowsexperience/2017/07/07/announcing-windows-10-insider-preview-build-16237-pc/

That adds a couple more flags, but the UK flag has been around since 1.0.

There's also a cursor navigation quirk: Navigating with the left arrow key skips over the position between the GB, navigating forwards does not.

Comment 3 by behdad@chromium.org, Jul 10 2017

Cc: drott@chromium.org
Oh my...  Maybe drott@'s Emoji iterator can be incorporated here to help with font selection.
Project Member

Comment 4 by bugdroid1@chromium.org, Oct 20 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/d19806f0a50d4769e1b208c42312fc2e7b8d5748

commit d19806f0a50d4769e1b208c42312fc2e7b8d5748
Author: Trent Apted <tapted@chromium.org>
Date: Fri Oct 20 06:10:05 2017

MacViews: Use the CoreText Harfbuzz shaper.

Currently the OpenType shaper gets used.

The CoreText shaper gives a closer match to native Cocoa UI, it's what
the renderer uses on Mac, and it's needed to render Emoji flags
properly on Mac.

Bug:  739641 
Change-Id: I217b1f3be21c571292faac1b0d13c8cc21f2b22f
Reviewed-on: https://chromium-review.googlesource.com/724583
Commit-Queue: Trent Apted <tapted@chromium.org>
Reviewed-by: Michael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#510355}
[modify] https://crrev.com/d19806f0a50d4769e1b208c42312fc2e7b8d5748/ui/gfx/harfbuzz_font_skia.cc
[modify] https://crrev.com/d19806f0a50d4769e1b208c42312fc2e7b8d5748/ui/gfx/render_text_harfbuzz.cc
[modify] https://crrev.com/d19806f0a50d4769e1b208c42312fc2e7b8d5748/ui/gfx/render_text_unittest.cc

Project Member

Comment 5 by bugdroid1@chromium.org, Oct 20 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/eb7dee29e43af9e5b2919ce82bee52fa53b45308

commit eb7dee29e43af9e5b2919ce82bee52fa53b45308
Author: Trent Apted <tapted@chromium.org>
Date: Fri Oct 20 10:22:56 2017

Revert "MacViews: Use the CoreText Harfbuzz shaper."

This reverts commit d19806f0a50d4769e1b208c42312fc2e7b8d5748.

Reason for revert: macOS 10.10 has the RTL bug as well

Bug:  776672 

Original change's description:
> MacViews: Use the CoreText Harfbuzz shaper.
> 
> Currently the OpenType shaper gets used.
> 
> The CoreText shaper gives a closer match to native Cocoa UI, it's what
> the renderer uses on Mac, and it's needed to render Emoji flags
> properly on Mac.
> 
> Bug:  739641 
> Change-Id: I217b1f3be21c571292faac1b0d13c8cc21f2b22f
> Reviewed-on: https://chromium-review.googlesource.com/724583
> Commit-Queue: Trent Apted <tapted@chromium.org>
> Reviewed-by: Michael Wasserman <msw@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#510355}

TBR=msw@chromium.org,tapted@chromium.org

Change-Id: I86a8cfd33769bd12a957fb7343db761e92387c7c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug:  739641 
Reviewed-on: https://chromium-review.googlesource.com/730523
Reviewed-by: Trent Apted <tapted@chromium.org>
Commit-Queue: Trent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#510395}
[modify] https://crrev.com/eb7dee29e43af9e5b2919ce82bee52fa53b45308/ui/gfx/harfbuzz_font_skia.cc
[modify] https://crrev.com/eb7dee29e43af9e5b2919ce82bee52fa53b45308/ui/gfx/render_text_harfbuzz.cc
[modify] https://crrev.com/eb7dee29e43af9e5b2919ce82bee52fa53b45308/ui/gfx/render_text_unittest.cc

Project Member

Comment 6 by bugdroid1@chromium.org, Oct 20 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/bc00f85ea66ad1630735d808923aac9858446955

commit bc00f85ea66ad1630735d808923aac9858446955
Author: Trent Apted <tapted@chromium.org>
Date: Fri Oct 20 14:05:11 2017

Reland MacViews: Use the CoreText Harfbuzz shaper.

Currently the OpenType shaper gets used.

The CoreText shaper gives a closer match to native Cocoa UI, it's what
the renderer uses on Mac, and it's needed to render Emoji flags
properly on Mac.

Reviewed in http://crrev.com/c/724583.
Reland extends a workaround for 10.9 to 10.10 as well.

TBR=msw@chromium.org

Bug:  739641 ,  776672 
Change-Id: Ib42b9acd39f97db000af6698b9ea167d374ac889
Reviewed-on: https://chromium-review.googlesource.com/730251
Commit-Queue: Trent Apted <tapted@chromium.org>
Reviewed-by: Trent Apted <tapted@chromium.org>
Cr-Commit-Position: refs/heads/master@{#510425}
[modify] https://crrev.com/bc00f85ea66ad1630735d808923aac9858446955/ui/gfx/harfbuzz_font_skia.cc
[modify] https://crrev.com/bc00f85ea66ad1630735d808923aac9858446955/ui/gfx/render_text_harfbuzz.cc
[modify] https://crrev.com/bc00f85ea66ad1630735d808923aac9858446955/ui/gfx/render_text_unittest.cc

Comment 7 by tapted@chromium.org, Oct 22 2017

Status: Started (was: Assigned)
Flags render on Mac now, but there's still https://chromium-review.googlesource.com/c/chromium/src/+/720581 to fix the selection/cursor glitches on all platforms when the flag glyph isn't found.
Project Member

Comment 8 by bugdroid1@chromium.org, Oct 27 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/f32989ec0a22f152873fcfac2a9001201aecd32e

commit f32989ec0a22f152873fcfac2a9001201aecd32e
Author: Trent Apted <tapted@chromium.org>
Date: Fri Oct 27 05:37:34 2017

RenderText: Fix cursor bounds drawing and selection for unicode regional indicators

AKA: "Emoji Flags". A Regional Indicator in utf-16 is 8 bytes. This
consists two, 4-byte utf-16 surrogate pairs. E.g. a British flag encodes
a special letter "G" in s[0],s[1] and a special "B" in s[2] and s[3].

A flag is shown when the chosen font has the "ligature" for the particular
regional indicator, but that's not always the case.

Currently, when a corresponding flag is not found (e.g. on Windows):
 - navigating forwards puts the cursor in the "middle" of the pairs,
   rather than outside. (navigating backwards works OK).
 - trying to select the placeholder glyphs causes a DCHECK in GetGraphemeBounds().

The unicode spec specifies that when paired this way, cursor navigation
should skip over the entire 8 bytes. RenderText obeys this logically (using
base::i18n::BreakIterator, which uses ICU, which implements the rules).
However, visually, gfx::RenderText calculates the cursor bounds by only
considering the glyph bounds of the first glyph. This causes the cursor
to be drawn in the middle of the "GB" even though it is logically after
the "B". Fix by using IndexOfAdjacentGrapheme to navigate in both directions.

We also need to ensure TextRunHarfBuzz::GetGraphemeBounds() is
aware of unicode surrogate pairs. Currently, it assumes a substring
length >1 in a cluster should have cursor "stops", but it needs to
count codepoints. not length.

Bug:  739641 
Change-Id: I9beb4674a43ec4850ea2cde77d20a3d009352614
Reviewed-on: https://chromium-review.googlesource.com/720581
Commit-Queue: Trent Apted <tapted@chromium.org>
Reviewed-by: Michael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#512096}
[modify] https://crrev.com/f32989ec0a22f152873fcfac2a9001201aecd32e/ui/gfx/render_text.cc
[modify] https://crrev.com/f32989ec0a22f152873fcfac2a9001201aecd32e/ui/gfx/render_text.h
[modify] https://crrev.com/f32989ec0a22f152873fcfac2a9001201aecd32e/ui/gfx/render_text_harfbuzz.cc
[modify] https://crrev.com/f32989ec0a22f152873fcfac2a9001201aecd32e/ui/gfx/render_text_harfbuzz.h
[modify] https://crrev.com/f32989ec0a22f152873fcfac2a9001201aecd32e/ui/gfx/render_text_mac.h
[modify] https://crrev.com/f32989ec0a22f152873fcfac2a9001201aecd32e/ui/gfx/render_text_mac.mm
[modify] https://crrev.com/f32989ec0a22f152873fcfac2a9001201aecd32e/ui/gfx/render_text_unittest.cc
[modify] https://crrev.com/f32989ec0a22f152873fcfac2a9001201aecd32e/ui/views/controls/label_unittest.cc

Comment 9 by tapted@chromium.org, Oct 30 2017

Status: Fixed (was: Started)
Fixed. Now we just need Microsoft to finish putting all these emoji into Segoe UI. The display is currently consistent with Edge. (Editing in Edge, however, is awful -- both in the location bar and in their renderer, in different ways).

Sign in to add a comment