Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Explicitly set foreground color to black in svg icons#26731

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

jmoraleda
Copy link
Contributor

@jmoraledajmoraleda commentedSep 10, 2023
edited
Loading

Currently the monochromatic svg icons do not explicitly specify foreground color, so they appear black, which is the svg default. This PR explicitly sets the foreground color of the monochromatic icons to black.

The rationale for this change is that explicitly setting the foreground color, enables changing the color through string replacement. In particular this permits adding dark-theme support in backends that use svg icons by doing a string replacementfill:black; ->fill:white;.

@anntzer
Copy link
Contributor

anntzer commentedSep 11, 2023
edited
Loading

Ideally this change would have been made in a way that regenerating the icons with make_icons.py maintains the explicit 'style="fill:black"', but I see that backend_svg.py has a cutout for black text and explicitly saves some output by not outputting the color in that case, so I guess it's not really worth the trouble.

@QuLogic do you know if this will interfere with gtk's "symbolic" icons though?

@jmoraleda
Copy link
ContributorAuthor

I see the filter for black text inbackend_svg.py:

        if color != '#000000':            style['fill'] = color

I assume we don't want to change that.

I was not familiar withmake_icons.py. If we want to preserve its functionality intact, then we could hack the functionmake_icons in the script to make a string replacement to add to the right files after they are saved in../lib/matplotlib/mpl-data/images. We could make this change as part of this PR.

anntzer and timhoffm reacted with thumbs up emoji

@jmoraleda
Copy link
ContributorAuthor

I modified the script. It feels a little hacky since it performs a purely syntactic search and replace with no svg model underlying it, but I think it does the job.

I tested it in my system where the svg backend produces very different icon code from what is currently committed, although the icons appear visually indistinguishable. So it should definitely work on systems that produce the svg code that is currently committed.

Copy link
Member

@oscargusoscargus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Subject to a confirmation/comment about the GTK aspect.

@anntzer
Copy link
Contributor

In case this turns out to be a problem for gtk, I guess the "base" files couldnot include the explicit foreground color but just have a xml marker-comment as to where the wx backend should insert the foreground color ("\> <!-- insert color in previous tag --> ->" ...\>).

@QuLogic
Copy link
Member

From my testing, it appears that this does not break GTK3 dark mode. GTK4 dark mode is already broken because it uses some other method that hasn't been implemented by us.

@anntzer
Copy link
Contributor

@jmoraleda Can you squash? (Not compulsory.)

jmoraleda reacted with thumbs up emoji

@jmoraledajmoraledaforce-pushed theexplicit-fg-color-in-svg-icons branch fromb7b8a15 to3b643d4CompareSeptember 20, 2023 16:05
@anntzeranntzer merged commit3798de3 intomatplotlib:mainSep 20, 2023
@anntzer
Copy link
Contributor

Thanks for the PR!

@jmoraledajmoraleda deleted the explicit-fg-color-in-svg-icons branchSeptember 20, 2023 21:12
@QuLogicQuLogic added this to thev3.9.0 milestoneOct 4, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@anntzeranntzeranntzer approved these changes

@oscargusoscargusoscargus approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
v3.9.0
Development

Successfully merging this pull request may close these issues.

4 participants
@jmoraleda@anntzer@QuLogic@oscargus

[8]ページ先頭

©2009-2025 Movatter.jp