djrrb / Bungee

A chromatic signage typeface for vertical and horizontal setting.
https://djr.com/bungee
SIL Open Font License 1.1
330 stars 42 forks source link

COLRv0: remove duplicate CPAL palette to work around FireFox bug #79

Closed anthrotype closed 1 year ago

anthrotype commented 1 year ago

In the current COLRv0 fonts, the CPAL palette index=4 and index=5 are duplicates (i.e. contain the same colors). I don't see why that would be a problem, besides being a waste of bytes.

However, for some strange reasons, these duplicate palettes somehow make FireFox (v104.0.1, as well as FF Nightly 106.0a1 (2022-09-01)) display the colors incorrectly, see the screenshot below. As far as I can tell, this particular combination of greys is not taken from any of the available CPAL palettes inside Bungee Color; it's as if FireFox is making things up, or simply giving up altogether, who knows..

Screen Shot 2022-09-02 at 12 19 12

Now, if I dump the fonts with ttx, remove the duplicate palette and then re-compile the fonts with ttx, then FireFox is happy again and shows the default red/white palette (at index=0). Whereas the additional or customized color palettes are not supported by FireFox yet, but only work in Chrome or Safari (see https://bugzilla.mozilla.org/show_bug.cgi?id=1461588).

Screen Shot 2022-09-02 at 12 19 25

This PR removes the duplicate palette so that the COLRv0 font works in FireFox as well as the rest of the browsers.

/cc @jfkthame from Mozilla as he may be interested to take a look too

anthrotype commented 1 year ago

This is the diff between the existing fonts and the modified ones from this PR (you can see I simply removed palette 5 and re-number the index of the following ones, going from 9 to 8 total palettes)

$ diff -Naur /Users/clupo/Github/Bungee/fonts/Bungee_Color_Fonts/COLRv0/BungeeColor-Regular_COLRv0_old.ttx /Users/clupo/Github/Bungee/fonts/Bungee_Color_Fonts/COLRv0/BungeeColor-Regular_COLRv0_new.ttx
--- /Users/clupo/Github/Bungee/fonts/Bungee_Color_Fonts/COLRv0/BungeeColor-Regular_COLRv0_old.ttx       2022-09-02 12:16:43.000000000 +0100
+++ /Users/clupo/Github/Bungee/fonts/Bungee_Color_Fonts/COLRv0/BungeeColor-Regular_COLRv0_new.ttx       2022-09-02 12:12:56.000000000 +0100
@@ -877,12 +877,12 @@
     <!-- Most of this table will be recalculated by the compiler -->
     <tableVersion value="1.0"/>
     <fontRevision value="1.0"/>
-    <checkSumAdjustment value="0x139aeb2f"/>
+    <checkSumAdjustment value="0x4c248fc1"/>
     <magicNumber value="0x5f0f3cf5"/>
     <flags value="00000000 00000001"/>
     <unitsPerEm value="1000"/>
     <created value="Tue Jun  7 11:21:57 2016"/>
-    <modified value="Wed May 25 20:16:42 2022"/>
+    <modified value="Fri Sep  2 11:06:12 2022"/>
     <xMin value="-49"/>
     <yMin value="-362"/>
     <xMax value="1393"/>
@@ -20620,18 +20620,14 @@
       <color index="1" value="#55A5FEFF"/>
     </palette>
     <palette index="5">
-      <color index="0" value="#0B5BA8FF"/>
-      <color index="1" value="#55A5FEFF"/>
-    </palette>
-    <palette index="6">
       <color index="0" value="#EFBB43FF"/>
       <color index="1" value="#EAE2B1FF"/>
     </palette>
-    <palette index="7">
+    <palette index="6">
       <color index="0" value="#FFDA99FF"/>
       <color index="1" value="#FF5140FF"/>
     </palette>
-    <palette index="8">
+    <palette index="7">
       <color index="0" value="#FFE10BFF"/>
       <color index="1" value="#FF0035FF"/>
     </palette>

According to Wakamai Fondue, the CPAL palettes currently inside Bungee Color COLRv0 font are these:

Screen Shot 2022-09-02 at 12 29 40

No idea where FireFox got those grey colors from..

djrrb commented 1 year ago

Hi Cosimo, thanks so much for finding and correcting this duplicate! Funny to see Firefox’s reaction to it.

Truly appreciate you taking the time to identify and correct this issue!