[paint] Resolve colors

We don't need to pass the index/alpha pairs to
client callbacks, and can just resolve the colors
internally.

Update test results.
diff --git a/src/OT/glyf/glyf.hh b/src/OT/glyf/glyf.hh
index 084a73c..74e4735 100644
--- a/src/OT/glyf/glyf.hh
+++ b/src/OT/glyf/glyf.hh
@@ -344,7 +344,7 @@
     funcs->push_root_transform (data, &ctx);
 
     funcs->push_clip_glyph (data, gid, &ctx);
-    funcs->color (data, 0xffff, 1., &ctx);
+    funcs->color (data, hb_paint_get_color (&ctx, 0xffff, 1.), &ctx);
     funcs->pop_clip (data, &ctx);
 
     funcs->pop_root_transform (data, &ctx);
diff --git a/src/hb-ot-cff1-table.cc b/src/hb-ot-cff1-table.cc
index 61e2cb1..fa93c3d 100644
--- a/src/hb-ot-cff1-table.cc
+++ b/src/hb-ot-cff1-table.cc
@@ -560,10 +560,11 @@
   ctx.font = font;
   ctx.palette = 0;
   ctx.foreground = foreground;
+
   funcs->push_root_transform (data, &ctx);
 
   funcs->push_clip_glyph (data, glyph, &ctx);
-  funcs->color (data, 0xffff, 1., &ctx);
+  funcs->color (data, hb_paint_get_color (&ctx, 0xffff, 1.), &ctx);
   funcs->pop_clip (data, &ctx);
 
   funcs->pop_root_transform (data, &ctx);
diff --git a/src/hb-ot-cff2-table.cc b/src/hb-ot-cff2-table.cc
index 9916938..af5e302 100644
--- a/src/hb-ot-cff2-table.cc
+++ b/src/hb-ot-cff2-table.cc
@@ -154,7 +154,7 @@
   funcs->push_root_transform (data, &ctx);
 
   funcs->push_clip_glyph (data, glyph, &ctx);
-  funcs->color (data, 0xffff, 1., &ctx);
+  funcs->color (data, hb_paint_get_color (&ctx, 0xffff, 1.), &ctx);
   funcs->pop_clip (data, &ctx);
 
   funcs->pop_root_transform (data, &ctx);
diff --git a/src/hb-ot-color-colr-table.cc b/src/hb-ot-color-colr-table.cc
index 99b0d92..05de5b2 100644
--- a/src/hb-ot-color-colr-table.cc
+++ b/src/hb-ot-color-colr-table.cc
@@ -51,9 +51,9 @@
                                hb_color_stop_t *color_stops)
 {
   if (color_line->is_variable)
-    return reinterpret_cast<const OT::ColorLine<OT::Variable> *>(color_line->base)->get_color_stops (start, count, color_stops, color_line->c->instancer);
+    return reinterpret_cast<const OT::ColorLine<OT::Variable> *>(color_line->base)->get_color_stops (&color_line->c->ctx, start, count, color_stops, color_line->c->instancer);
   else
-    return reinterpret_cast<const OT::ColorLine<OT::NoVariable> *>(color_line->base)->get_color_stops (start, count, color_stops, color_line->c->instancer);
+    return reinterpret_cast<const OT::ColorLine<OT::NoVariable> *>(color_line->base)->get_color_stops (&color_line->c->ctx, start, count, color_stops, color_line->c->instancer);
 }
 
 /**
diff --git a/src/hb-ot-color-colr-table.hh b/src/hb-ot-color-colr-table.hh
index 29404eb..f84e576 100644
--- a/src/hb-ot-color-colr-table.hh
+++ b/src/hb-ot-color-colr-table.hh
@@ -241,10 +241,11 @@
     value.paint_glyph (c, varIdxBase);
   }
 
-  void get_color_stop (hb_color_stop_t *c,
+  void get_color_stop (hb_paint_context_t *ctx,
+                       hb_color_stop_t *c,
 		       const VarStoreInstancer &instancer) const
   {
-    value.get_color_stop (c, varIdxBase, instancer);
+    value.get_color_stop (ctx, c, varIdxBase, instancer);
   }
 
   hb_paint_extend_t get_extend () const
@@ -293,10 +294,11 @@
     value.paint_glyph (c, varIdxBase);
   }
 
-  void get_color_stop (hb_color_stop_t *c,
+  void get_color_stop (hb_paint_context_t *ctx,
+                       hb_color_stop_t *c,
 		       const VarStoreInstancer &instancer) const
   {
-    value.get_color_stop (c, VarIdx::NO_VARIATION, instancer);
+    value.get_color_stop (ctx, c, VarIdx::NO_VARIATION, instancer);
   }
 
   hb_paint_extend_t get_extend () const
@@ -331,13 +333,15 @@
     return_trace (c->check_struct (this));
   }
 
-  void get_color_stop (hb_color_stop_t *out,
+  void get_color_stop (hb_paint_context_t *ctx,
+                       hb_color_stop_t *out,
 		       uint32_t varIdx,
 		       const VarStoreInstancer &instancer) const
   {
     out->offset = stopOffset.to_float(instancer (varIdx, 0));
-    out->color_index = paletteIndex;
-    out->alpha = alpha.to_float(instancer (varIdx, 1));
+    out->color = hb_paint_get_color (ctx,
+                                     paletteIndex,
+                                     alpha.to_float (instancer (varIdx, 1)));
   }
 
   F2DOT14	stopOffset;
@@ -393,7 +397,8 @@
 
   /* get up to count stops from start */
   unsigned int
-  get_color_stops (unsigned int start,
+  get_color_stops (hb_paint_context_t *ctx,
+                   unsigned int start,
 		   unsigned int *count,
 		   hb_color_stop_t *color_stops,
 		   const VarStoreInstancer &instancer) const
@@ -404,8 +409,7 @@
     {
       unsigned int i;
       for (i = 0; i < *count && start + i < len; i++)
-        stops[start + i].get_color_stop (&color_stops[i],
-					 instancer);
+        stops[start + i].get_color_stop (ctx, &color_stops[i], instancer);
       *count = i;
     }
 
@@ -555,8 +559,9 @@
   void paint_glyph (hb_ot_paint_context_t *c, uint32_t varIdxBase) const
   {
     c->funcs->color (c->data,
-                     paletteIndex,
-                     alpha.to_float (c->instancer (varIdxBase, 0)),
+                     hb_paint_get_color (&c->ctx,
+                                         paletteIndex,
+                                         alpha.to_float (c->instancer (varIdxBase, 0))),
                      &c->ctx);
   }
 
@@ -1992,7 +1997,7 @@
 			   .sub_array (record->firstLayerIdx, record->numLayers))
       {
         c.funcs->push_clip_glyph (c.data, r.glyphId, &c.ctx);
-        c.funcs->color (c.data, r.colorIdx, 1., &c.ctx);
+        c.funcs->color (c.data, hb_paint_get_color (&c.ctx, r.colorIdx, 1.), &c.ctx);
         c.funcs->pop_clip (c.data, &c.ctx);
       }
 
diff --git a/src/hb-paint.cc b/src/hb-paint.cc
index b7d09ab..ede2c8e 100644
--- a/src/hb-paint.cc
+++ b/src/hb-paint.cc
@@ -74,8 +74,7 @@
 
 static void
 hb_paint_color_nil (hb_paint_funcs_t *funcs, void *paint_data,
-                    unsigned int color_index,
-                    float alpha,
+                    hb_color_t color,
                     const hb_paint_context_t *ctx,
                     void *user_data) {}
 
@@ -489,8 +488,7 @@
  * hb_paint_color:
  * @funcs: paint functions
  * @paint_data: associated data passed by the caller
- * @color_index: Index of a color in the color palette
- * @alpha: Alpha to apply in addition
+ * @color: The color to use
  * @ctx: the paint context
  *
  * Perform a "color" paint operation.
@@ -499,11 +497,10 @@
  */
 void
 hb_paint_color (hb_paint_funcs_t *funcs, void *paint_data,
-                unsigned int color_index,
-                float alpha,
+                hb_color_t color,
                 const hb_paint_context_t *ctx)
 {
-  funcs->color (paint_data, color_index, alpha, ctx);
+  funcs->color (paint_data, color, ctx);
 }
 
 /**
diff --git a/src/hb-paint.h b/src/hb-paint.h
index ccbc33b..bfeaba2 100644
--- a/src/hb-paint.h
+++ b/src/hb-paint.h
@@ -46,7 +46,7 @@
  *
  * The callbacks also assume that the caller uses
  * hb_ot_color_palette_get_colors() to obtain colors
- * from one of the fonts color palettes. If the font does
+ * from the color palette that is selected. If the font does
  * not have color palettes, the color index will always
  * be 0xFFFF, indicating the use of the foreground color.
  *
@@ -240,27 +240,18 @@
  * hb_paint_color_func_t:
  * @funcs: paint functions object
  * @paint_data: The data accompanying the paint functions in hb_font_paint_glyph()
- * @color_index: Index of a color in the fonts selected color palette
- * @alpha: alpha to apply in addition
- * @ctx: the paint context
+ * @color: The color to use
+ * @ctx: The paint context
  * @user_data: User data pointer passed to hb_paint_funcs_set_color_func()
  *
  * A virtual method for the #hb_paint_funcs_t to paint a
  * color everywhere within the current clip.
  *
- * The @color_index can be either an index into one of the fonts
- * color palettes, or the special value 0xFFFF, which indicates that
- * the foreground color should be used.
- *
- * In either case, the @alpha value should be applied in addition
- * (i.e. multiplied with) the alpha value found in the color.
- *
  * Since: REPLACEME
  */
 typedef void (*hb_paint_color_func_t) (hb_paint_funcs_t *funcs,
                                        void *paint_data,
-                                       unsigned int color_index,
-                                       float alpha,
+                                       hb_color_t color,
                                        const hb_paint_context_t *ctx,
                                        void *user_data);
 
@@ -321,27 +312,18 @@
 /**
  * hb_color_stop_t:
  * @offset: the offset of the color stop
- * @color_index: either a color palette index or the special value 0xFFFF
- * @alpha: alpha to apply
+ * @color: the color
  *
  * Information about a color stop on a color line.
  *
  * Color lines typically have offsets ranging between 0 and 1,
  * but that is not required.
  *
- * The @color_index can be either an index into one of the fonts
- * color palettes, or the special value 0xFFFF, which indicates that
- * the foreground color should be used.
- *
- * in either case, the @alpha value should be applied in addition
- * (i.e. multiplied with) the alpha value found in the color.
- *
  * Since: REPLACEME
  */
 typedef struct {
   float offset;
-  unsigned int color_index;
-  float alpha;
+  hb_color_t color;
 } hb_color_stop_t;
 
 HB_EXTERN unsigned int
@@ -789,8 +771,7 @@
 
 HB_EXTERN void
 hb_paint_color (hb_paint_funcs_t *funcs, void *paint_data,
-                unsigned int color_index,
-                float alpha,
+                hb_color_t color,
                 const hb_paint_context_t *ctx);
 
 HB_EXTERN void
diff --git a/src/hb-paint.hh b/src/hb-paint.hh
index 4412d81..458aca7 100644
--- a/src/hb-paint.hh
+++ b/src/hb-paint.hh
@@ -98,11 +98,10 @@
   { func.pop_clip (this, paint_data, ctx,
                    !user_data ? nullptr : user_data->pop_clip); }
   void color (void *paint_data,
-              unsigned int color_index,
-              float alpha,
+              hb_color_t color,
               const hb_paint_context_t *ctx)
   { func.color (this, paint_data,
-                color_index, alpha,
+                color,
                 ctx,
                 !user_data ? nullptr : user_data->color); }
   void image (void *paint_data,
@@ -197,4 +196,26 @@
 };
 DECLARE_NULL_INSTANCE (hb_paint_funcs_t);
 
+static inline hb_color_t
+hb_paint_get_color (const hb_paint_context_t *ctx,
+                    unsigned int color_index,
+                    float alpha)
+{
+  hb_color_t color = ctx->foreground;
+
+  if (color_index != 0xffff)
+  {
+    unsigned int clen = 1;
+    hb_face_t *face = hb_font_get_face (ctx->font);
+
+    hb_ot_color_palette_get_colors (face, ctx->palette, color_index, &clen, &color);
+  }
+
+  return HB_COLOR (hb_color_get_blue (color),
+                   hb_color_get_green (color),
+                   hb_color_get_red (color),
+                   hb_color_get_alpha (color) * alpha);
+}
+
+
 #endif /* HB_PAINT_HH */
diff --git a/test/api/results/hand-20-0-10 b/test/api/results/hand-20-0-10
index dc022ef..e6e82f4 100644
--- a/test/api/results/hand-20-0-10
+++ b/test/api/results/hand-20-0-10
@@ -7,10 +7,10 @@
             p0 280.000000 440.000000 radius 0.000000
             p1 280.000000 440.000000 radius 467.000000
             colors
-              0.000000 16 1.000000
-              0.448792 15 1.000000
-              0.808594 14 1.000000
-              1.000000 12 1.000000
+              0.000000 186 141 104 255
+              0.448792 183 138 103 255
+              0.808594 173 130 100 255
+              1.000000 164 123 98 255
         end transform
       end clip
     end transform
@@ -23,29 +23,29 @@
           p1 1019.000000 -27.000000
           p2 231.000000 -815.000000
           colors
-            0.000000 12 1.000000
-            1.000000 12 1.000000
+            0.000000 164 123 98 255
+            1.000000 164 123 98 255
       end clip
     end transform
   pop group mode 3
   push group
     start transform 51.200001 0.000000 -0.000000 51.200001 0.000000 0.000000
       start clip glyph 15
-        solid 9 1.000000
+        solid 145 103 77 255
       end clip
     end transform
   pop group mode 3
   push group
     start transform 51.200001 0.000000 -0.000000 51.200001 0.000000 0.000000
       start clip glyph 16
-        solid 0 1.000000
+        solid 30 136 229 255
       end clip
     end transform
   pop group mode 3
   push group
     start transform 51.200001 0.000000 -0.000000 51.200001 0.000000 0.000000
       start clip glyph 21
-        solid 9 1.000000
+        solid 145 103 77 255
       end clip
     end transform
   pop group mode 3
@@ -58,15 +58,15 @@
             p1 180.000000 -106.000000
             p2 -212.000000 1265.000000
             colors
-              0.000000 5 1.000000
-              1.000000 1 1.000000
+              0.000000 100 181 246 255
+              1.000000 33 150 243 255
         end clip
       end transform
     pop group mode 3
     push group
       start transform 51.200001 0.000000 -0.000000 51.200001 0.000000 0.000000
         start clip glyph 18
-          solid 2 0.200012
+          solid 66 66 66 51
         end clip
       end transform
     pop group mode 3
@@ -79,10 +79,10 @@
             p0 588.000000 198.000000 radius 0.000000
             p1 588.000000 198.000000 radius 342.000000
             colors
-              0.000000 16 1.000000
-              0.448792 15 1.000000
-              0.808594 14 1.000000
-              1.000000 12 1.000000
+              0.000000 186 141 104 255
+              0.448792 183 138 103 255
+              0.808594 173 130 100 255
+              1.000000 164 123 98 255
         end transform
       end clip
     end transform
@@ -90,7 +90,7 @@
   push group
     start transform 51.200001 0.000000 -0.000000 51.200001 0.000000 0.000000
       start clip glyph 20
-        solid 9 1.000000
+        solid 145 103 77 255
       end clip
     end transform
   pop group mode 3
diff --git a/test/api/results/hand-20-0.2-10 b/test/api/results/hand-20-0.2-10
index 536cd0c..a285ded 100644
--- a/test/api/results/hand-20-0.2-10
+++ b/test/api/results/hand-20-0.2-10
@@ -7,10 +7,10 @@
             p0 280.000000 440.000000 radius 0.000000
             p1 280.000000 440.000000 radius 467.000000
             colors
-              0.000000 16 1.000000
-              0.448792 15 1.000000
-              0.808594 14 1.000000
-              1.000000 12 1.000000
+              0.000000 186 141 104 255
+              0.448792 183 138 103 255
+              0.808594 173 130 100 255
+              1.000000 164 123 98 255
         end transform
       end clip
     end transform
@@ -23,29 +23,29 @@
           p1 1019.000000 -27.000000
           p2 231.000000 -815.000000
           colors
-            0.000000 12 1.000000
-            1.000000 12 1.000000
+            0.000000 164 123 98 255
+            1.000000 164 123 98 255
       end clip
     end transform
   pop group mode 3
   push group
     start transform 51.200001 0.000000 -10.240000 51.200001 0.000000 0.000000
       start clip glyph 15
-        solid 9 1.000000
+        solid 145 103 77 255
       end clip
     end transform
   pop group mode 3
   push group
     start transform 51.200001 0.000000 -10.240000 51.200001 0.000000 0.000000
       start clip glyph 16
-        solid 0 1.000000
+        solid 30 136 229 255
       end clip
     end transform
   pop group mode 3
   push group
     start transform 51.200001 0.000000 -10.240000 51.200001 0.000000 0.000000
       start clip glyph 21
-        solid 9 1.000000
+        solid 145 103 77 255
       end clip
     end transform
   pop group mode 3
@@ -58,15 +58,15 @@
             p1 180.000000 -106.000000
             p2 -212.000000 1265.000000
             colors
-              0.000000 5 1.000000
-              1.000000 1 1.000000
+              0.000000 100 181 246 255
+              1.000000 33 150 243 255
         end clip
       end transform
     pop group mode 3
     push group
       start transform 51.200001 0.000000 -10.240000 51.200001 0.000000 0.000000
         start clip glyph 18
-          solid 2 0.200012
+          solid 66 66 66 51
         end clip
       end transform
     pop group mode 3
@@ -79,10 +79,10 @@
             p0 588.000000 198.000000 radius 0.000000
             p1 588.000000 198.000000 radius 342.000000
             colors
-              0.000000 16 1.000000
-              0.448792 15 1.000000
-              0.808594 14 1.000000
-              1.000000 12 1.000000
+              0.000000 186 141 104 255
+              0.448792 183 138 103 255
+              0.808594 173 130 100 255
+              1.000000 164 123 98 255
         end transform
       end clip
     end transform
@@ -90,7 +90,7 @@
   push group
     start transform 51.200001 0.000000 -10.240000 51.200001 0.000000 0.000000
       start clip glyph 20
-        solid 9 1.000000
+        solid 145 103 77 255
       end clip
     end transform
   pop group mode 3
diff --git a/test/api/results/test-20-0-10 b/test/api/results/test-20-0-10
index 1c34a13..332c00a 100644
--- a/test/api/results/test-20-0-10
+++ b/test/api/results/test-20-0-10
@@ -5,10 +5,10 @@
         center 500.000000 600.000000
         angles 0.000000 6.283185
         colors
-          0.250000 7 1.000000
-          0.416687 4 1.000000
-          0.583313 0 1.000000
-          0.750000 8 1.000000
+          0.250000 250 240 230 255
+          0.416687 0 0 255 255
+          0.583313 255 0 0 255
+          0.750000 47 79 79 255
     end clip
   end transform
 end transform
diff --git a/test/api/results/test-20-0-106 b/test/api/results/test-20-0-106
index 323940a..9f59e4c 100644
--- a/test/api/results/test-20-0-106
+++ b/test/api/results/test-20-0-106
@@ -2,7 +2,7 @@
   push group
     start transform 50.000000 0.000000 -0.000000 50.000000 0.000000 0.000000
       start clip glyph 3
-        solid 4 0.500000
+        solid 0 0 255 127
       end clip
     end transform
     push group
@@ -11,7 +11,7 @@
           start transform 0.000000 0.000000 0.000000 0.000000 -1000.000000 -1000.000000
             start transform 50.000000 0.000000 -0.000000 50.000000 0.000000 0.000000
               start clip glyph 3
-                solid 1 0.700012
+                solid 255 165 0 178
               end clip
             end transform
           end transform
diff --git a/test/api/results/test-20-0-116 b/test/api/results/test-20-0-116
index 6c7ffd3..fdc4f99 100644
--- a/test/api/results/test-20-0-116
+++ b/test/api/results/test-20-0-116
@@ -2,14 +2,14 @@
   push group
     start transform 50.000000 0.000000 -0.000000 50.000000 0.000000 0.000000
       start clip glyph 3
-        solid 4 0.500000
+        solid 0 0 255 127
       end clip
     end transform
     push group
       start transform 1.000000 0.000000 0.000000 1.000000 200.000000 200.000000
         start transform 50.000000 0.000000 -0.000000 50.000000 0.000000 0.000000
           start clip glyph 3
-            solid 1 0.700012
+            solid 255 165 0 178
           end clip
         end transform
       end transform
diff --git a/test/api/results/test-20-0-123 b/test/api/results/test-20-0-123
index 296c3ee..40d40f8 100644
--- a/test/api/results/test-20-0-123
+++ b/test/api/results/test-20-0-123
@@ -2,7 +2,7 @@
   push group
     start transform 50.000000 0.000000 -0.000000 50.000000 0.000000 0.000000
       start clip glyph 3
-        solid 10 1.000000
+        solid 0 0 0 255
       end clip
     end transform
   pop group mode 3
@@ -13,7 +13,7 @@
           start transform 0.000000 0.000000 0.000000 0.000000 -333.000000 -667.000000
             start transform 50.000000 0.000000 -0.000000 50.000000 0.000000 0.000000
               start clip glyph 2
-                solid 12 1.000000
+                solid 255 220 1 255
               end clip
             end transform
           end transform
@@ -25,7 +25,7 @@
             start transform 0.000000 0.000000 0.000000 0.000000 -667.000000 -333.000000
               start transform 50.000000 0.000000 -0.000000 50.000000 0.000000 0.000000
                 start clip glyph 2
-                  solid 11 1.000000
+                  solid 104 199 232 255
                 end clip
               end transform
             end transform
diff --git a/test/api/results/test-20-0-165 b/test/api/results/test-20-0-165
index cea5dd9..8ce1363 100644
--- a/test/api/results/test-20-0-165
+++ b/test/api/results/test-20-0-165
@@ -6,9 +6,9 @@
         p1 2300.000000 950.000000
         p2 -1000.000000 250.000000
         colors
-          0.000000 0 1.000000
-          0.500000 4 1.000000
-          1.000000 2 1.000000
+          0.000000 255 0 0 255
+          0.500000 0 0 255 255
+          1.000000 255 255 0 255
     end clip
   end transform
 end transform
diff --git a/test/api/results/test-20-0-175 b/test/api/results/test-20-0-175
index 83dac5e..4488375 100644
--- a/test/api/results/test-20-0-175
+++ b/test/api/results/test-20-0-175
@@ -3,7 +3,7 @@
     start transform 1.000000 0.000000 0.000000 1.000000 150.000000 0.000000
       start transform 50.000000 0.000000 -0.000000 50.000000 0.000000 0.000000
         start clip glyph 174
-          solid 3 1.000000
+          solid 0 128 0 255
         end clip
       end transform
     end transform
@@ -17,8 +17,8 @@
             p1 500.000000 950.000000
             p2 600.000000 250.000000
             colors
-              0.000000 0 1.000000
-              1.000000 4 1.000000
+              0.000000 255 0 0 255
+              1.000000 0 0 255 255
         end clip
       end transform
     end transform
diff --git a/test/api/results/test-20-0-6 b/test/api/results/test-20-0-6
index c165e62..8fe765a 100644
--- a/test/api/results/test-20-0-6
+++ b/test/api/results/test-20-0-6
@@ -6,8 +6,8 @@
         p1 900.000000 250.000000
         p2 100.000000 300.000000
         colors
-          0.000000 0 1.000000
-          1.000000 4 1.000000
+          0.000000 255 0 0 255
+          1.000000 0 0 255 255
     end clip
   end transform
 end transform
diff --git a/test/api/results/test-20-0-92 b/test/api/results/test-20-0-92
index 51d5b2f..7c7916d 100644
--- a/test/api/results/test-20-0-92
+++ b/test/api/results/test-20-0-92
@@ -5,9 +5,9 @@
         p0 166.000000 768.000000 radius 0.000000
         p1 166.000000 768.000000 radius 256.000000
         colors
-          0.000000 3 1.000000
-          0.500000 9 1.000000
-          1.000000 0 1.000000
+          0.000000 0 128 0 255
+          0.500000 255 255 255 255
+          1.000000 255 0 0 255
     end clip
   end transform
 end transform
diff --git a/test/api/test-ot-color.c b/test/api/test-ot-color.c
index a63ecc9..737a020 100644
--- a/test/api/test-ot-color.c
+++ b/test/api/test-ot-color.c
@@ -546,14 +546,17 @@
 static void
 paint_color (hb_paint_funcs_t *funcs,
              void *paint_data,
-             unsigned int color_index,
-             float alpha,
+             hb_color_t color,
              const hb_paint_context_t *ctx,
              void *user_data)
 {
   paint_data_t *data = user_data;
 
-  print (data, "solid %u %f", color_index, alpha);
+  print (data, "solid %d %d %d %d",
+         hb_color_get_red (color),
+         hb_color_get_green (color),
+         hb_color_get_blue (color),
+         hb_color_get_alpha (color));
 }
 
 static void
@@ -587,7 +590,12 @@
   print (data, "colors");
   data->level += 1;
   for (unsigned int i = 0; i < len; i++)
-    print (data, "%f %u %f", stops[i].offset, stops[i].color_index, stops[i].alpha);
+    print (data, "%f %d %d %d %d",
+           stops[i].offset,
+           hb_color_get_red (stops[i].color),
+           hb_color_get_green (stops[i].color),
+           hb_color_get_blue (stops[i].color),
+           hb_color_get_alpha (stops[i].color));
   data->level -= 1;
 }
 
@@ -746,7 +754,7 @@
    */
   if (getenv ("GENERATE_DATA"))
     {
-      g_print ("%s\n", data.string->str);
+      g_print ("%s", data.string->str);
       exit (0);
     }
 
diff --git a/util/hb-cairo-utils.c b/util/hb-cairo-utils.c
index f3eb694..10e18e1 100644
--- a/util/hb-cairo-utils.c
+++ b/util/hb-cairo-utils.c
@@ -259,8 +259,11 @@
   cairo_pattern_set_extend (pattern, cairo_extend (hb_color_line_get_extend (color_line)));
   for (unsigned int i = 0; i < len; i++)
     {
-      float r, g, b, a;
-      hb_cairo_get_font_color (ctx, stops[i].color_index, stops[i].alpha, &r, &g, &b, &a);
+      double r, g, b, a;
+      r = hb_color_get_red (stops[i].color) / 255.;
+      g = hb_color_get_green (stops[i].color) / 255.;
+      b = hb_color_get_blue (stops[i].color) / 255.;
+      a = hb_color_get_alpha (stops[i].color) / 255.;
       cairo_pattern_add_color_stop_rgba (pattern, stops[i].offset, r, g, b, a);
     }
 
@@ -307,8 +310,11 @@
 
   for (unsigned int i = 0; i < len; i++)
     {
-      float r, g, b, a;
-      hb_cairo_get_font_color (ctx, stops[i].color_index, stops[i].alpha, &r, &g, &b, &a);
+      double r, g, b, a;
+      r = hb_color_get_red (stops[i].color) / 255.;
+      g = hb_color_get_green (stops[i].color) / 255.;
+      b = hb_color_get_blue (stops[i].color) / 255.;
+      a = hb_color_get_alpha (stops[i].color) / 255.;
       cairo_pattern_add_color_stop_rgba (pattern, stops[i].offset, r, g, b, a);
     }
 
@@ -486,7 +492,10 @@
           color_t c;
           if (start_angle > 0)
             {
-              hb_cairo_get_font_color (ctx, stops[0].color_index, stops[0].alpha, &c.r, &c.g, &c.b, &c.a);
+              c.r = hb_color_get_red (stops[0].color) / 255.;
+              c.g = hb_color_get_green (stops[0].color) / 255.;
+              c.b = hb_color_get_blue (stops[0].color) / 255.;
+              c.a = hb_color_get_alpha (stops[0].color) / 255.;
               add_sweep_gradient_patches1 (cx, cy, radius,
                                            0.,          &c,
                                            start_angle, &c,
@@ -494,7 +503,10 @@
             }
           if (end_angle < 2 * M_PI)
             {
-              hb_cairo_get_font_color (ctx, stops[n_stops-1].color_index, stops[n_stops-1].alpha, &c.r, &c.g, &c.b, &c.a);
+              c.r = hb_color_get_red (stops[n_stops - 1].color) / 255.;
+              c.g = hb_color_get_green (stops[n_stops - 1].color) / 255.;
+              c.b = hb_color_get_blue (stops[n_stops - 1].color) / 255.;
+              c.a = hb_color_get_alpha (stops[n_stops - 1].color) / 255.;
               add_sweep_gradient_patches1 (cx, cy, radius,
                                            end_angle, &c,
                                            2 * M_PI,  &c,
@@ -530,7 +542,10 @@
   for (unsigned i = 0; i < n_stops; i++)
     {
       angles[i] = start_angle + stops[i].offset * (end_angle - start_angle);
-      hb_cairo_get_font_color (ctx, stops[i].color_index, stops[i].alpha, &colors[i].r, &colors[i].g, &colors[i].b, &colors[i].a);
+      colors[i].r = hb_color_get_red (stops[i].color) / 255.;
+      colors[i].g = hb_color_get_green (stops[i].color) / 255.;
+      colors[i].b = hb_color_get_blue (stops[i].color) / 255.;
+      colors[i].a = hb_color_get_alpha (stops[i].color) / 255.;
     }
 
   if (extend == CAIRO_EXTEND_PAD)
diff --git a/util/helper-cairo-user.hh b/util/helper-cairo-user.hh
index 00ca3cc..cc680f7 100644
--- a/util/helper-cairo-user.hh
+++ b/util/helper-cairo-user.hh
@@ -209,16 +209,17 @@
 static void
 paint_color (hb_paint_funcs_t *funcs,
              void *paint_data,
-             unsigned int color_index,
-             float alpha,
+             hb_color_t color,
              const hb_paint_context_t *ctx,
              void *user_data)
 {
   cairo_t *cr = (cairo_t *)paint_data;
-  float r, g, b, a;
 
-  hb_cairo_get_font_color (ctx, color_index, alpha, &r, &g, &b, &a);
-  cairo_set_source_rgba (cr, (double)r, (double)g, (double)b, (double)a);
+  cairo_set_source_rgba (cr,
+                         hb_color_get_red (color) / 255.,
+                         hb_color_get_green (color) / 255.,
+                         hb_color_get_blue (color) / 255.,
+                         hb_color_get_alpha (color) / 255.);
   cairo_paint (cr);
 }