Closed Bug 1961387 Opened 11 months ago Closed 11 months ago

Poor rendering (bad metrics) of Noto Color Emoji font in vertical writing-modes

Categories

(Core :: Layout: Text and Fonts, defect)

Firefox 137
Unspecified
Linux
defect

Tracking

()

RESOLVED FIXED
140 Branch
Tracking Status
firefox140 --- fixed

People

(Reporter: zjz, Assigned: jfkthame)

References

(Blocks 1 open bug)

Details

(Whiteboard: [writing-modes:m1])

Attachments

(9 files, 1 obsolete file)

207 bytes, text/html
Details
11.61 KB, image/png
Details
9.91 KB, image/png
Details
98.83 KB, image/png
Details
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
7.71 KB, image/png
Details
Attached file test.html (obsolete) —

emojis get much bigger height than expected.

Attached file test.html

The previous test file was corrupted. I've updated it with UTF-8 encoding.

Attachment #9479912 - Attachment is obsolete: true

This is probably dependent on what emoji font is used. Which platform are you using? Please attach a screenshot of how it looks for you. Thanks!

Flags: needinfo?(zjz)

(In reply to Jonathan Kew [:jfkthame] from comment #2)

This is probably dependent on what emoji font is used. Which platform are you using? Please attach a screenshot of how it looks for you. Thanks!

I am using deepin, which is a Linux Distro. And I've tries many local fonts by changing font-family, and the height remain wrong.
I've also confirmed that the these emojis work well in Chrome.

Flags: needinfo?(zjz)

(In reply to Jonathan Kew [:jfkthame] from comment #2)

This is probably dependent on what emoji font is used. Which platform are you using? Please attach a screenshot of how it looks for you. Thanks!

FYI, after some research, I've found the actually used font is NotoColorEmoji.ttf (no matter whatever font-family I actually set because of the missing character fallback mechanism).
Can someone reproduce this issue using Noto Color Emoji?

Interesting -- trying the example in Firefox on macOS, it looks ok with Apple Color Emoji, and also works ok with Segoe UI Emoji, but using Noto Color Emoji does render quite badly (though not quite the same as the reporter's screenshot from Linux).

So both the specific emoji font and the font backend (CoreText vs FreeType) we're using seem to be factors here.

Severity: -- → S3

It looks like we end up with excessively large metrics for both glyph advance and line height when Noto Color Emoji is used in vertical mode.

The result in the reporter's screenshot is what happens when using the (older) bitmap version of Noto Color Emoji. Note that the result varies depending on the font size; it seems the metrics aren't being scaled appropriately. (Zoom the example to 400% and it looks roughly right!)

Replacing the Noto Color Emoji bitmap font with the newer COLRv1 version gives somewhat less awful results (similar to what's shown in my screenshot from macOS), but it's still not good.

Summary: emoji characters in vertical-lr/rl writing-mode get wrong height → Poor rendering (bad metrics) of Noto Color Emoji font in vertical writing-modes
Whiteboard: [writing-modes:triage]
Blocks: writing-mode
Whiteboard: [writing-modes:triage] → [writing-modes:m1]

This fixes the bad positioning of Noto Color Emoji glyphs when using the
current (COLRv1) version of the font. GetGlyphVOrigin was incorrectly
returning zero because the 'glyf' data was empty; but the glyph will in
fact render, via the COLR codepath, and needs a valid origin to get
proper placement.

(The same issue could presumably affect an OpenType-SVG font that
similarly provides a 'vmtx' table but has empty 'glyf' records.)

I don't expect this to resolve the issue for the older bitmap (CBDT)
version of Noto Color Emoji; that will require a separate fix.

Assignee: nobody → jfkthame
Status: NEW → ASSIGNED

This fixes the problem of color-bitmap Noto Color Emoji getting incorrect
glyph advances in vertical mode. Without the scaling correction here, we
end up with a constant glyph advance regardless of the font size, just
based on the "natural" size of the bitmap glyphs rather than the size
we're actually scaling them to.

Without the scaling fix, the advance of the bitmap emoji glyph isn't
scaled according to the rendered size, and so the large glyph extends
beyond the expected rect.

Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a4ad6f718272 Don't return a vertical-origin of zero for 'empty' truetype glyphs; fall back to computing the default vertical origin, so that if there's color-glyph data it will render in the right place. r=gfx-reviewers,lsalzman https://hg.mozilla.org/integration/autoland/rev/de68ee31172f Simple reftest for Noto Color Emoji in vertical mode. r=gfx-reviewers,lsalzman https://hg.mozilla.org/integration/autoland/rev/057a31f469ac Account for scaling of color-bitmap fonts when setting up the font-unit scale factor. r=gfx-reviewers,lsalzman https://hg.mozilla.org/integration/autoland/rev/ea30c0eca521 Add a reftest with larger glyphs, for CBDT version of Noto Color Emoji. r=gfx-reviewers,lsalzman
Regressions: 1965123
Pushed by chorotan@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/66e788b91a78 Revert "Bug 1961387 - Add a reftest with larger glyphs, for CBDT version of Noto Color Emoji. r=gfx-reviewers,lsalzman" for causing crashes (bug 1965123)
Status: RESOLVED → REOPENED
Flags: needinfo?(jfkthame)
Resolution: FIXED → ---
Target Milestone: 140 Branch → ---
Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/1c1f408004e1 Don't return a vertical-origin of zero for 'empty' truetype glyphs; fall back to computing the default vertical origin, so that if there's color-glyph data it will render in the right place. r=gfx-reviewers,lsalzman https://hg.mozilla.org/integration/autoland/rev/eafaeb768277 Simple reftest for Noto Color Emoji in vertical mode. r=gfx-reviewers,lsalzman https://hg.mozilla.org/integration/autoland/rev/a884b6f401c3 Account for scaling of color-bitmap fonts when setting up the font-unit scale factor. r=gfx-reviewers,lsalzman https://hg.mozilla.org/integration/autoland/rev/6e6b5ae23a5c Add a reftest with larger glyphs, for CBDT version of Noto Color Emoji. r=gfx-reviewers,lsalzman
QA Whiteboard: [qa-triage-done-c141/b140][qa-ver-opt-c141/b140]
Attached image Emoji after the fix

I reproduced the initial issue using an old Nightly build from 2025-04-18 on Ubuntu 22.04, verified that the testcase from comment 1 looks much better using latest Nightly 141.0a1 and Firefox beta 140.0b5 across platforms (Ubuntu 22.04, macOS 13 and Windows 11). Though on Ubuntu (most evident) compared to Chrome the testcase still looks a bit off, see the attached image where I compare how the testcase looks in Chrome vs Firefox (Chrome / Nightly / Beta).
Jonathan, do you think this is alright or there can be done something more to improve the result here?

I think we can just call this fixed. The difference vs Chrome shown in comment 20 is largely a case of using different default fonts for the ASCII digits, so the renderings aren't really comparable.

Flags: needinfo?(jfkthame)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: