From 3b643d4455947a0b71ce30761a738905efbf6351 Mon Sep 17 00:00:00 2001 From: Jorge Moraleda Date: Mon, 11 Sep 2023 20:33:29 -0400 Subject: [PATCH] Explicitly set foreground color to black in svg icons. make_icons script adds style="fill:black;" to monochromatic icons --- lib/matplotlib/mpl-data/images/back.svg | 2 +- lib/matplotlib/mpl-data/images/filesave.svg | 2 +- lib/matplotlib/mpl-data/images/forward.svg | 2 +- lib/matplotlib/mpl-data/images/help.svg | 2 +- lib/matplotlib/mpl-data/images/home.svg | 2 +- lib/matplotlib/mpl-data/images/move.svg | 2 +- .../mpl-data/images/qt4_editor_options.svg | 2 +- lib/matplotlib/mpl-data/images/subplots.svg | 2 +- .../mpl-data/images/zoom_to_rect.svg | 2 +- tools/make_icons.py | 18 ++++++++++++++---- 10 files changed, 23 insertions(+), 13 deletions(-) diff --git a/lib/matplotlib/mpl-data/images/back.svg b/lib/matplotlib/mpl-data/images/back.svg index a933ef8cdf50..0c2d653cbe8f 100644 --- a/lib/matplotlib/mpl-data/images/back.svg +++ b/lib/matplotlib/mpl-data/images/back.svg @@ -40,7 +40,7 @@ L 33.991875 44.72875 L 60.703125 44.72875 C 63.43375 44.72875 65.144375 42.444375 65.144375 39.8625 z -"/> +" style="fill:black;"/> diff --git a/lib/matplotlib/mpl-data/images/filesave.svg b/lib/matplotlib/mpl-data/images/filesave.svg index ad8372d295de..856721b6b5e2 100644 --- a/lib/matplotlib/mpl-data/images/filesave.svg +++ b/lib/matplotlib/mpl-data/images/filesave.svg @@ -62,7 +62,7 @@ C 6.855625 64.95875 8.491875 66.584375 10.5 66.584375 L 61.5 66.584375 C 63.508125 66.584375 65.144375 64.95875 65.144375 62.94 z -"/> +" style="fill:black;"/> diff --git a/lib/matplotlib/mpl-data/images/forward.svg b/lib/matplotlib/mpl-data/images/forward.svg index 1f4071360680..08b6fe174602 100644 --- a/lib/matplotlib/mpl-data/images/forward.svg +++ b/lib/matplotlib/mpl-data/images/forward.svg @@ -40,7 +40,7 @@ C 30.645 66.4675 31.866875 66.99875 33.1525 66.99875 C 34.438125 66.99875 35.691875 66.4675 36.605625 65.59625 L 61.30875 40.893125 C 62.2225 39.979375 62.71125 38.725625 62.71125 37.44 -"/> +" style="fill:black;"/> diff --git a/lib/matplotlib/mpl-data/images/help.svg b/lib/matplotlib/mpl-data/images/help.svg index 484bdbcbf659..260528d607aa 100644 --- a/lib/matplotlib/mpl-data/images/help.svg +++ b/lib/matplotlib/mpl-data/images/help.svg @@ -46,7 +46,7 @@ C 42.486563 52.0175 43.134687 51.029375 43.134687 50.19 C 43.134687 49.095625 44.537188 46.47125 46.779063 45.185625 C 50.380938 43.166875 55.279063 40.404375 55.279063 33.19 z -"/> +" style="fill:black;"/> diff --git a/lib/matplotlib/mpl-data/images/home.svg b/lib/matplotlib/mpl-data/images/home.svg index 3c4ccce3ed1f..db140d43d156 100644 --- a/lib/matplotlib/mpl-data/images/home.svg +++ b/lib/matplotlib/mpl-data/images/home.svg @@ -53,7 +53,7 @@ C 62.482813 46.47125 62.748438 46.545625 63.056562 46.545625 C 63.088437 46.545625 63.130938 46.545625 63.173438 46.545625 C 63.470938 46.51375 63.779063 46.354375 63.970313 46.13125 z -"/> +" style="fill:black;"/> diff --git a/lib/matplotlib/mpl-data/images/move.svg b/lib/matplotlib/mpl-data/images/move.svg index aa7198cf72df..f7e23ab0451c 100644 --- a/lib/matplotlib/mpl-data/images/move.svg +++ b/lib/matplotlib/mpl-data/images/move.svg @@ -67,7 +67,7 @@ C 55.433125 48.49 56.5275 49.584375 57.855625 49.584375 C 58.50375 49.584375 59.109375 49.31875 59.56625 48.861875 L 69.2775 39.150625 C 69.734375 38.69375 70 38.088125 70 37.44 -"/> +" style="fill:black;"/> diff --git a/lib/matplotlib/mpl-data/images/qt4_editor_options.svg b/lib/matplotlib/mpl-data/images/qt4_editor_options.svg index 0b46bf80923e..02adfbc4ae11 100644 --- a/lib/matplotlib/mpl-data/images/qt4_editor_options.svg +++ b/lib/matplotlib/mpl-data/images/qt4_editor_options.svg @@ -42,7 +42,7 @@ L 63.3275 27.123125 L 67.9175 31.713125 C 68.714375 32.51 70 31.93625 70 30.87375 z -"/> +" style="fill:black;"/> diff --git a/lib/matplotlib/mpl-data/images/subplots.svg b/lib/matplotlib/mpl-data/images/subplots.svg index e87d2c9b1b19..9a0fa90972ff 100644 --- a/lib/matplotlib/mpl-data/images/subplots.svg +++ b/lib/matplotlib/mpl-data/images/subplots.svg @@ -75,7 +75,7 @@ L 32.355625 18.0175 L 32.355625 22.873125 L 65.144375 22.873125 z -"/> +" style="fill:black;"/> diff --git a/lib/matplotlib/mpl-data/images/zoom_to_rect.svg b/lib/matplotlib/mpl-data/images/zoom_to_rect.svg index f4b69b23c5eb..44e59a8a4fdc 100644 --- a/lib/matplotlib/mpl-data/images/zoom_to_rect.svg +++ b/lib/matplotlib/mpl-data/images/zoom_to_rect.svg @@ -34,7 +34,7 @@ C 36.525937 59.300937 41.838437 57.664687 46.279687 54.594062 L 59.295313 67.577812 C 60.166562 68.480937 61.420313 69.012187 62.716563 69.012187 C 65.372813 69.012187 67.572187 66.812812 67.572187 64.156562 -"/> +" style="fill:black;"/> diff --git a/tools/make_icons.py b/tools/make_icons.py index 0424c0d03dad..f09d40e92256 100755 --- a/tools/make_icons.py +++ b/tools/make_icons.py @@ -36,8 +36,18 @@ def get_fontawesome(): return cached_path -def save_icon(fig, dest_dir, name): - fig.savefig(dest_dir / (name + '.svg')) +def save_icon(fig, dest_dir, name, add_black_fg_color): + if add_black_fg_color: + # Add explicit black foreground color to monochromatic svg icons + # so it can be replaced by backends to add dark theme support + svg_bytes_io = BytesIO() + fig.savefig(svg_bytes_io, format='svg') + svg = svg_bytes_io.getvalue() + before, sep, after = svg.rpartition(b'\nz\n"') + svg = before + sep + b' style="fill:black;"' + after + (dest_dir / (name + '.svg')).write_bytes(svg) + else: + fig.savefig(dest_dir / (name + '.svg')) fig.savefig(dest_dir / (name + '.pdf')) for dpi, suffix in [(24, ''), (48, '_large')]: fig.savefig(dest_dir / (name + suffix + '.png'), dpi=dpi) @@ -102,9 +112,9 @@ def make_icons(): font_path = get_fontawesome() for name, ccode in icon_defs: fig = make_icon(font_path, ccode) - save_icon(fig, args.dest_dir, name) + save_icon(fig, args.dest_dir, name, True) fig = make_matplotlib_icon() - save_icon(fig, args.dest_dir, 'matplotlib') + save_icon(fig, args.dest_dir, 'matplotlib', False) if __name__ == "__main__": pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy