From 61719a835089ea2c2cda36702f630c9343b029c7 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 20 Jan 2023 15:52:09 -0700 Subject: [PATCH] [hb-view] Support specifying color indices again --- src/hb-number.cc | 1 - util/helper-cairo.hh | 16 ++++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/hb-number.cc b/src/hb-number.cc index 6e4f3f7eb..c52b284e1 100644 --- a/src/hb-number.cc +++ b/src/hb-number.cc @@ -24,7 +24,6 @@ */ #include "hb.hh" -#include "hb-machinery.hh" #include "hb-number.hh" #include "hb-number-parser.hh" diff --git a/util/helper-cairo.hh b/util/helper-cairo.hh index aa3905ce1..c62413150 100644 --- a/util/helper-cairo.hh +++ b/util/helper-cairo.hh @@ -130,12 +130,24 @@ helper_cairo_create_scaled_font (const font_options_t *font_opts, if (view_opts->custom_palette) { char **entries = g_strsplit (view_opts->custom_palette, ",", -1); + unsigned idx = 0; for (unsigned i = 0; entries[i]; i++) { + const char *p = strchr (entries[i], '='); + if (!p) + p = entries[i]; + else + { + sscanf (entries[i], "%u", &idx); + p++; + } + unsigned fr, fg, fb, fa; fr = fg = fb = fa = 0; - if (parse_color (entries[i], fr, fg,fb, fa)) - cairo_font_options_set_custom_palette_color (font_options, i, fr / 255., fg / 255., fb / 255., fa / 255.); + if (parse_color (p, fr, fg,fb, fa)) + cairo_font_options_set_custom_palette_color (font_options, idx, fr / 255., fg / 255., fb / 255., fa / 255.); + + idx++; } g_strfreev (entries); }