Use aligned toolbar icons and updated app icon.#32095
Open
iccir wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR summary
Toolbar Icon Alignment
Previously, toolbar icons were generated directly from the Font Awesome 4.7 font and exported to SVG, PDF, 24x24 PNG, and 48x48 PNG files. This approach had a few issues. Most notably, the icons were not vertically aligned. This was especially noticeable with the "home" and "subplot" icons on newer versions of macOS:
If we zoom in and measure, there is a 19px padding on the top of the house and only a 10px-10.5px padding on the bottom:
Other icons are better, but still slightly too low. Additionally, all icons have slightly-blurry edges as scaling has occurred and straight lines are no longer on pixel boundaries:
This is not a macOS-only problem - all backends suffer these alignment issues as the source SVGs/PNGs/PDFs are misaligned. Here's qtagg:
To solve this: I took the original icons, scaled to a target of 48x48px, and redrew them to fit on pixel boundaries. The resulting icons are both vertically aligned and sharper:
App Icon
The app icon used by various backends was using an (older?) version of the matplotlib logo:
I generated a new one based on the current logo:
Additionally,
matplotlib.pngandmatplotlib_large.pngwere 24px and 48px respectively, matching the toolbar icons. I'm not sure why 24px was chosen. As far as I can tell, Windows historically used 32px as a "standard" size and 48px for "large".I changed
matplotlib.pngto be a 256px. This seems to be the maximum size for Windows and Linux when targetting high-resolution displays.I also generated a 32px icon with slightly more contrast to use as a smaller variant:
Here's a chart showing the file names, old size, and new size. I'm fairly sure that I updated all code paths where these files were used. I can try another approach if we need to maintain the old sizes for compatibility reasons.
make_icons.py
The
tools/make_icons.pyscript now loads each SVG frommpl-data/imagesand converts it to PNGs and a PDF. PNG conversion is performed via Inkscape and optipng - the same dependencies that the documentation uses. PDF conversion is handled by pikepdf.Due to the use of optipng and by-hand-SVG-optimization, the content size of the mpl-data directory went from ~141k to ~79k.
AI Disclosure
make_icons.pyscript. I fully understand all lines of said script and was capable of coding it without any AI guidance._backend_gtk.py. This is the one file that I'm not confident in as I'm not sure how to test my changes. Any guidance is appreciated!PR checklist
Questions:
mpl-data/imagesto store both the input SVG files and the output files. I'd like for the input SVG files to have more comments that would get stripped when copied tompl-data/images. Is there a location where input assets could be stored that's notmpl-data/images? I'll need such a location for [ENH]: macOS backend should match system app icons #31895.