Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Svg without viewBox does not match theme #3714

Closed
2 tasks done
mondy opened this issue Mar 10, 2023 · 1 comment
Closed
2 tasks done

Svg without viewBox does not match theme #3714

mondy opened this issue Mar 10, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@mondy
Copy link

mondy commented Mar 10, 2023

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

I tried to add a new icon.
However, the theme was not reflected.
I asked a question in the fyne channel on slack.
As a conclusion, I found that the theme is not reflected if there is no viewBox attribute in the svg tag.
Would it be possible to apply the theme to svg files that do not have a viewBox attribute?

How to reproduce

Execute the following code.

Screenshots

image

Example code

package main

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/theme"
	"fyne.io/fyne/v2/widget"
)

func main() {
	ok := `<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0, 0, 32, 32"><circle cx="16" cy="16" r="14" /></svg>`
	ng := `<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32"><circle cx="16" cy="16" r="14" /></svg>`

	app := app.New()
	win := app.NewWindow("")
	win.SetContent(container.NewGridWrap(
		fyne.NewSize(200, 200),
		widget.NewIcon(theme.NewThemedResource(fyne.NewStaticResource("ok_themed.svg", []byte(ok)))),
		widget.NewIcon(theme.NewThemedResource(fyne.NewStaticResource("ng_themed.svg", []byte(ng)))),
		widget.NewIcon(fyne.NewStaticResource("ok_unthemed.svg", []byte(ok))),
		widget.NewIcon(fyne.NewStaticResource("ng_unthemed.svg", []byte(ng))),
	))
	win.ShowAndRun()
}

Fyne version

v2.3.1

Go compiler version

go version go1.20.2 windows/amd64

Operating system and version

Windows10

Additional Information

No response

@mondy mondy added the unverified A bug that has been reported but not verified label Mar 10, 2023
@Jacalz Jacalz changed the title Adding a new icon does not reflect the theme. Svg without viewBox does not match theme Mar 10, 2023
@andydotxyz andydotxyz added bug Something isn't working and removed unverified A bug that has been reported but not verified labels Mar 10, 2023
@andydotxyz andydotxyz added this to the Fixes (v2.3.x) milestone Mar 10, 2023
andydotxyz pushed a commit to andydotxyz/fyne that referenced this issue Mar 13, 2023
@andydotxyz
Copy link
Member

Fixed for v2.3.2 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants