From 253b4cecae0729330ec04fab93972db86ee1b203 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 18 Jan 2023 23:28:25 -0700 Subject: [PATCH] [hb-view] Simplify palette format --- util/font-options.hh | 2 +- util/helper-cairo.hh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/util/font-options.hh b/util/font-options.hh index 5f99a37ef..5d569968c 100644 --- a/util/font-options.hh +++ b/util/font-options.hh @@ -292,7 +292,7 @@ font_options_t::add_options (option_parser_t *parser) {"font-slant", 0, 0, G_OPTION_ARG_DOUBLE, &this->slant, "Set synthetic slant (default: 0)", "slant ratio; eg. 0.2"}, {"font-palette", 0, 0, G_OPTION_ARG_INT, &this->palette, "Set font palette (default: 0)", "index"}, - {"custom-palette", 0, 0, G_OPTION_ARG_STRING, &this->custom_palette, "Custom palette", "palette"}, + {"custom-palette", 0, 0, G_OPTION_ARG_STRING, &this->custom_palette, "Custom palette", "comma-separated colors"}, {"font-funcs", 0, 0, G_OPTION_ARG_STRING, &this->font_funcs, text, "impl"}, {"sub-font", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &this->sub_font, "Create a sub-font (default: false)", "boolean"}, diff --git a/util/helper-cairo.hh b/util/helper-cairo.hh index d25372240..293077a6e 100644 --- a/util/helper-cairo.hh +++ b/util/helper-cairo.hh @@ -131,9 +131,9 @@ helper_cairo_create_scaled_font (const font_options_t *font_opts) char **entries = g_strsplit (font_opts->custom_palette, ",", -1); for (unsigned int i = 0; entries[i]; i++) { - unsigned int idx, fr, fg, fb, fa; - if (sscanf (entries[i], "%u:%2x%2x%2x%2x", &idx, &fr, &fg, &fb, &fa) == 5) - cairo_font_options_set_custom_palette_color (font_options, idx, fr / 255., fg / 255., fb / 255., fa / 255.); + unsigned int fr, fg, fb, fa; + if (sscanf (entries[i], "%2x%2x%2x%2x", &fr, &fg, &fb, &fa) == 4) + cairo_font_options_set_custom_palette_color (font_options, i, fr / 255., fg / 255., fb / 255., fa / 255.); } g_strfreev (entries); }