COLR color font stopped working on OSX High Sierra

RESOLVED FIXED in Firefox 62

Status

()

defect
P2
normal
RESOLVED FIXED
a year ago
10 months ago

People

(Reporter: roel, Assigned: jfkthame)

Tracking

(Depends on 1 bug)

56 Branch
mozilla62
All
macOS
Points:
---
Dependency tree / graph

Firefox Tracking Flags

(firefox62 fixed)

Details

Attachments

(1 attachment)

(Reporter)

Description

a year ago
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.89 Safari/537.36 OPR/49.0.2725.39

Steps to reproduce:

Use a COLR/CPAL color font in Firefox. A simple test font can be found here:https://pixelambacht.nl/demo/color-font-test.html (it should show a green checkmark under "Microsoft COLR/CPAL") and a JavaScript check can be found here: https://pixelambacht.nl/chromacheck

Works on OSX Sierra, Not in High Sierra for any version above 56 (didn't test below).

This is mosty likely because Apple introduced native COLR/CPAL support in High Sierra, which might clash with Firefox' internal support.


Actual results:

The font is rendered in "black and white". COLR information is ignored.


Expected results:

The font should be loaded and a green checkmark should be shown on the first page, and the ChromaCheck page should show a green message saying COLR/CPAL is supported.

Updated

a year ago
Component: Untriaged → Layout: Text
OS: Unspecified → Mac OS X
Product: Firefox → Core
Hardware: Unspecified → x86
(Assignee)

Comment 1

a year ago
Markus, can you confirm this? (I'm not currently on 10.13, but offhand I don't see why a change in Apple's support should have affected how we render these fonts.)
Flags: needinfo?(mstange)
(Assignee)

Comment 2

11 months ago
I can confirm that 'COLR'-format fonts seem to be broken in Firefox on macOS 10.13; they just render solid black glyphs.
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(mstange)
Priority: -- → P3
(Assignee)

Comment 3

11 months ago
I checked that we're calling gfxFont::RenderColorGlyph as expected, and this in turn calls aDrawTarget->FillGlyphs() for each of the component layers that make up the color glyph, passing the correct color value from the font's palette. But the end result is that we render a solid black glyph.

I believe this used to work on 10.12, and works on 10.10 (which we're running in CI), such that our basic color-font reftests aren't failing; but if we had CI running 10.13 we'd be seeing the failure there. I don't know why the DrawTarget::FillGlyphs() calls are no longer resulting in the correct colors; AFAICS this seems to be an issue on the Graphics side.
Component: Layout: Text → Graphics: Text
Priority: P3 → P2
Hardware: x86 → All
(Assignee)

Updated

11 months ago
Depends on: 1456856
(Reporter)

Comment 4

11 months ago
Some observations:

I can get https://pixelambacht.nl/demo/color-font-test.html to work if I set the CPAL table version to 1 instead of 0:

<CPAL>
  <version value="1"/>
  <numPaletteEntries value="2"/>
  <palette index="0">
    ...
  </palette>
</CPAL>

Strangely, the COLR font used in ChromaCheck is still at CPAL table version 0, but *does* work. This was caused by compiling the font with an updated version of TTX/FontTools. Please see this commit: https://github.com/RoelN/ChromaCheck/commit/77aeaff9d76657e5caa19cd0a6ce258fa0d4abcc and specifically the changes to the COLR font: https://github.com/RoelN/ChromaCheck/commit/77aeaff9d76657e5caa19cd0a6ce258fa0d4abcc#diff-f8a43ab0d0093a27df0dc88f20498f37

I don't get why these changes suddenly made ChromaCheck's COLR font work in Firefox again, though.
(Reporter)

Comment 5

11 months ago
(Recompiling the https://pixelambacht.nl/demo/color-font-test.html font with the new TTX/FontTools, but CPAL table version back to the original version of 0, still results in a broken COLR font)
(Assignee)

Comment 6

11 months ago
Interesting, thanks. Does the CPAL-version-1 font work in Safari?
(Assignee)

Comment 7

11 months ago
It appears that on HighSierra, when Core Text renders glyphs from a font with COLR/CPAL tables, it ignores any color we've set in the context and uses the colors from the font's palette; but when we render the individual glyphs that make up the layers of a composite, full-color glyphs, those individual-layer glyphs do not themselves have an inherent color (as the layer colors are associated with the "parent" composite glyph, which we don't directly ask Core Text to paint), and it just paints them black. So it looks like the easiest fix will be for us to disable our painting of the individual component glyphs on 10.13, and let Core Text do it for us.
Attachment #8981466 - Flags: review?(lsalzman)
(Assignee)

Updated

11 months ago
Assignee: nobody → jfkthame
Status: NEW → ASSIGNED
(Assignee)

Comment 8

11 months ago
Try build with this patch: https://treeherder.mozilla.org/#/jobs?repo=try&revision=e85469f9f3dd7a5f0787dc66eed5dc28c3130f74. This  renders COLR glyphs successfully on 10.13 for me locally; we can't reftest it on treeherder because we don't have HighSierra test machines.

(We already have COLR-font reftests that would be failing because of this issue if our testing infrastructure were updated.)
Attachment #8981466 - Flags: review?(lsalzman) → review+

Comment 9

11 months ago
Pushed by jkew@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/c03dea03efa7
Rely on native Core Text support for COLR/CPAL fonts on High Sierra. r=lsalzman

Comment 10

11 months ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/c03dea03efa7
Status: ASSIGNED → RESOLVED
Last Resolved: 11 months ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla62
(Reporter)

Comment 11

11 months ago
That was quick! Thanks for the great work!

I wonder if this will also fix https://bugzilla.mozilla.org/show_bug.cgi?id=1465324?
(Assignee)

Comment 12

11 months ago
(In reply to Roel Nieskens from comment #11)
> That was quick! Thanks for the great work!
> 
> I wonder if this will also fix
> https://bugzilla.mozilla.org/show_bug.cgi?id=1465324?

I don't believe so, unfortunately; that'll require further investigation.
QA Whiteboard: [good first verify]
You need to log in before you can comment on or make changes to this bug.