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

fix #1196: Can't set an app/window icon to be an svg #2579

Closed
wants to merge 10 commits into from

Conversation

ChandanChainani
Copy link
Contributor

@ChandanChainani ChandanChainani commented Oct 23, 2021

Description:

Fixes #(issue)

Checklist:

  • Tests included.
  • Lint and formatter run with no errors.
  • Tests all pass.

Where applicable:

  • Public APIs match existing style.
  • Any breaking changes have a deprecation path or have been discussed.
  • Updated the vendor folder (using go mod vendor).

window SetIcon fail for svg with format not supported error

Fyne error:  Failed to decode image for window icon
2020/07/17 19:59:06   Cause: image: unknown format
2020/07/17 19:59:06   At: /home/dylan/go/src/fyne.io/fyne/internal/driver/glfw/window.go:224
@ChandanChainani ChandanChainani changed the title Develop Can't set an app/window icon to be an svg Oct 23, 2021
@ChandanChainani
Copy link
Contributor Author

ChandanChainani commented Oct 23, 2021

@andydotxyz @Jacalz could you take a look?

Copy link
Member

@Jacalz Jacalz left a comment

Choose a reason for hiding this comment

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

Were all of these cache changes really necessary? Wouldn't it just have been possible to do what we did for png images before?

@ChandanChainani
Copy link
Contributor Author

ChandanChainani commented Oct 23, 2021

Were all of these cache changes really necessary? Wouldn't it just have been possible to do what we did for png images before?

@Jacalz If you are referring to changes that already exists it was possible but it would have required to test the same condition again if the image path is provided or resource and then get the name that can be used to get image from cache, Wouldn't it be good if we can just get the name from one single place and use it in start to test if image exists in cache and return on start if exists.

variable, function and file name are only changed in cache to refer generic use case for eg: png and svg.

As we already know that when user is calling canvas.NewImageFromFile path would be provided to function so we can directly load the image which would reduce the condition of checking it File path is provided and then load the image.

canvas/image.go Outdated
@@ -52,7 +52,6 @@ type Image struct {
baseObject

// one of the following sources will provide our image data
File string // Load the image from a file
Copy link
Member

Choose a reason for hiding this comment

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

You have to add this back. You are removing a field which is part of the public API and would thus break all applications making use of it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Jacalz should I revert back to old or just add back the File attribute

@ChandanChainani ChandanChainani changed the title Can't set an app/window icon to be an svg fix #1196: Can't set an app/window icon to be an svg Oct 23, 2021
Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

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

The changes to the image load try to access SVG data for any type of image, this does not seem right.
I would propose separating out changes to how image loading work from the code you've added to render images from SVG into window icons...

@ChandanChainani
Copy link
Contributor Author

ChandanChainani commented Oct 25, 2021

@andydotxyz Can you guide me how should I handle the cache section and where the window icon rendering related code?

@andydotxyz
Copy link
Member

@andydotxyz Can you guide me how should I handle the cache section and where the window icon rendering related code?

Not sure I follow. What I was suggesting is that the window icon code doesn't need changes to caching as far as I can see.
If caching should be improved that could be a different PR?

@andydotxyz
Copy link
Member

ChandanChainani requested a review from andydotxyz 38 minutes ago

Sorry I don't understand what I am reviewing now. A benchmark?

@ChandanChainani
Copy link
Contributor Author

ChandanChainani commented Oct 26, 2021

@andydotxyz I include the benchmark for svg and png as @Jacalz pointed the performance with png load problem #2570 and reverted back to the state where the image format not supported issue was resolved.

image

@ChandanChainani
Copy link
Contributor Author

@Jacalz As pointed out by you the performance issue with png without cache and told to add benchmark for it I have added the benchmark and attached the screenshot.

The issue mention has been solved by the starting commit and last commit include the benchmark.

Can you guide me what to do next?

@Jacalz
Copy link
Member

Jacalz commented Oct 27, 2021

But the benchmark isn't relevant to my concerns. It compares the speed of an svg file to the png file after your change, it doesn't really prove anything I'm afraid. It just seems to verify my point that the png is taking more time than it should.

@ChandanChainani
Copy link
Contributor Author

@Jacalz so should I try to find another way or the current implementation is good?

@Jacalz
Copy link
Member

Jacalz commented Oct 27, 2021

What I'm trying to say is that you should benchmark before and after for png, not png compared to svg in the current form. If there is a significant slowdown, which I expect it to be, a better solution will be needed. You can probably just use the old code path (that you removed) then if it isn't an svg.

@ChandanChainani
Copy link
Contributor Author

@Jacalz Can you share example which have been used in code anywhere for the case?

@andydotxyz
Copy link
Member

I think this PR is getting caught up in unnecessary details.
If the PR simply added SVG rendering where it was not previously possible then benchmarking etc would not really be required.
Would you consider going back to that level of addition and then rendering performance etc could be explored based on what we knew needed done.

I don't think that the redrawing of PNG assets (which this PR adds) is necessary, if it were not happening I am sure the benchmarking conversation would become moot.

@ChandanChainani
Copy link
Contributor Author

@andydotxyz so should I revert back to the stage where svg image rendering working with the size decided

@andydotxyz
Copy link
Member

@andydotxyz so should I revert back to the stage where svg image rendering working with the size decided

I don't think there was any previous state where the code is not re-drawing PNG and JPEG images.
If it was just adding SVG draw without overheads for existing bitmap icons I think the PR would have been approved already.

@ChandanChainani
Copy link
Contributor Author

@andydotxyz first 2 commits fix svg issue of not loading the rest of commits were some unwanted cache optimization for png and benchmark related code.

@andydotxyz
Copy link
Member

@andydotxyz first 2 commits fix svg issue of not loading the rest of commits were some unwanted cache optimization for png and benchmark related code.

I think this may be where there is a little confusion.
If you look carefully back at those commits the addition requires that the PNG/JPEG icon data is rendered into a canvas and then saved back as image data - this double-encoding is what we were trying to explain is an added overhead that we would like to avoid.

@andydotxyz
Copy link
Member

Can we pick this up to land for v2.1.2? I have started to pull it together so we probably have a week or so.

@andydotxyz
Copy link
Member

Any thoughts @ChandanChainani as this is so close I would like to get the fix in v2.1.2, but the PR is not really there yet. Will you have time to update, or should we cherry pick the ideas in here and commit separately?

@ChandanChainani
Copy link
Contributor Author

@andydotxyz I tried researching but not able to find any good way, please can you help me here and point me the direction where should I look.

@Jacalz
Copy link
Member

Jacalz commented Nov 28, 2021

@andydotxyz I tried researching but not able to find any good way, please can you help me here and point me the direction where should I look.

What we essentially have been trying to say is that if you get a png, do as before the change, but if it is an svg, you use painter.PaintImage as you changed it to do. Problem solved, no caching needed.

@ChandanChainani
Copy link
Contributor Author

Changes made to internal/driver/glfw/window.go

var (
  pix image.Image
  err error
)
imgMimeType := http.DetectContentType(icon.Content())
if strings.Contains(imgMimeType, "text/xml") {
  iconW, iconH := 256, 256
  pix = painter.PaintImage(&canvas.Image{Resource: w.icon}, nil, iconW, iconH)
} else {
  pix, _, err = image.Decode(bytes.NewReader(w.icon.Content()))
  if err != nil {
      fyne.LogError("Failed to decode image for window icon", err)
      return
  }
}

For detecting the image type used http package DetectContentType
fyne_example.go

package main

import (
	"fmt"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/canvas"
	"fyne.io/fyne/v2/theme"
)

func main() {
	iconSvg := `
	<?xml version="1.0" encoding="UTF-8" standalone="no"?>
	<svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" id="svg8" version="1.1" viewBox="0 0 162.66043 162.66041" height="162.66042mm" width="162.66042mm">
		<defs id="defs2" />
		<metadata id="metadata5">
			<rdf:RDF>
				<cc:Work rdf:about="">
					<dc:format>image/svg+xml</dc:format>
					<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
					<dc:title></dc:title>
				</cc:Work>
			</rdf:RDF>
		</metadata>
		<g transform="translate(-23.669792,-44.087498)" id="layer1">
			<path id="path908" d="M 90.544758,103.59879 C 84.139139,100.3697 80.658278,94.92492 79.628782,86.523956 79.439996,84.98343 79.336706,77.160016 79.336224,64.365102 L 79.33543,44.587498 h 25.66459 25.66457 V 65.19034 c 0,22.535986 -0.0268,23.006232 -1.56843,27.48814 -1.0591,3.07914 -2.21152,4.90028 -4.64928,7.34712 -1.64274,1.64886 -2.65924,2.40418 -4.53994,3.37343 l -2.42328,1.24888 H 105.05477 92.625878 Z" style="opacity:1;fill:#c87137;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" />
			<path id="path910" d="m 79.32427,186.23968 c 0,-16.80538 0.06646,-20.45838 0.415152,-22.82031 1.170454,-7.92823 4.590355,-13.05541 10.794131,-16.18275 l 2.08116,-1.04912 h 12.428907 12.42889 l 2.42328,1.23711 c 1.93692,0.98882 2.87645,1.69242 4.68125,3.50573 2.6535,2.66599 4.05745,5.20434 5.21363,9.42624 l 0.72078,2.63196 0.0812,21.62969 0.0812,21.62968 h -25.67478 -25.6748 z" style="opacity:1;fill:#c87137;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" />
			<g id="text914" style="font-style:normal;font-weight:normal;font-size:50.79999924px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332" />
			<path id="rect916" d="M 24.169792,44.587498 H 185.83021 V 206.24791 H 24.169792 Z" style="opacity:1;fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal" />
			<g id="text4731" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:35.27777863px;line-height:1.25;font-family:'GM Global Sans';-inkscape-font-specification:'GM Global Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.25;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" aria-label="Remaining
	Tip
	Dresses">
				<path id="path4739" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:35.27777863px;font-family:'GM Global Sans';-inkscape-font-specification:'GM Global Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.25;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 36.64766,76.663814 q 0,-2.046112 -1.375833,-3.139723 -1.340556,-1.093611 -3.880556,-1.093611 -0.811389,0 -1.5875,0.03528 -0.740833,0 -1.093611,0.03528 v 8.466666 q 0.352778,0 1.058333,0.03528 0.740833,0 1.481667,0 2.575278,0 3.986389,-1.128889 1.411111,-1.164166 1.411111,-3.210277 z M 37.635438,93.738258 30.438771,83.437147 H 28.71016 V 93.738258 H 25.464604 V 69.961036 q 0.776111,-0.03528 2.54,-0.105834 1.763889,-0.07055 3.668889,-0.07055 1.905,0 3.421945,0.388055 1.552222,0.388056 2.645833,1.199445 1.093611,0.776111 1.693333,2.010833 0.599723,1.234722 0.599723,2.892778 0,1.516944 -0.493889,2.716389 -0.458611,1.164167 -1.340556,2.010833 -0.846666,0.811389 -1.975555,1.340556 -1.128889,0.493889 -2.434167,0.670278 0.246944,0.3175 0.811389,1.023055 0.564444,0.705556 1.128889,1.516945 l 5.926667,8.184444 z" />
				<path id="path4741" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:35.27777863px;font-family:'GM Global Sans';-inkscape-font-specification:'GM Global Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.25;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 54.742404,82.978536 q 0.03528,-2.257778 -1.023056,-3.457222 -1.023055,-1.234723 -2.892778,-1.234723 -1.763888,0 -2.963333,1.234723 -1.164167,1.234722 -1.411111,3.457222 z m 3.245555,0.141111 q 0,1.093611 -0.105833,2.081389 H 46.416848 q -0.03528,3.210278 1.27,4.7625 1.340556,1.552222 4.1275,1.552222 1.305278,0 2.575278,-0.246944 1.305278,-0.246945 2.610556,-0.705556 l 0.423333,2.434167 q -1.446389,0.529167 -2.963333,0.776111 -1.516945,0.282222 -3.033889,0.282222 -4.092223,0 -6.208889,-2.187222 -2.081389,-2.2225 -2.081389,-6.808611 0,-1.940278 0.529166,-3.633611 0.529167,-1.693334 1.552223,-2.928056 1.058333,-1.234722 2.504722,-1.905 1.481667,-0.705556 3.316111,-0.705556 1.799167,0 3.104445,0.564445 1.340555,0.564444 2.187222,1.552222 0.846667,0.987778 1.234722,2.293056 0.423333,1.305278 0.423333,2.822222 z" />
				<path id="path4743" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:35.27777863px;font-family:'GM Global Sans';-inkscape-font-specification:'GM Global Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.25;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="M 84.439679,93.738258 V 82.484647 q 0,-1.975556 -0.635,-2.963333 -0.599722,-1.023056 -2.2225,-1.023056 -0.9525,0 -1.834444,0.493889 -0.881945,0.458611 -1.5875,1.375833 -0.670278,0.917223 -1.093611,2.2225 -0.388056,1.27 -0.388056,2.822223 v 8.325555 H 73.538846 V 82.484647 q 0,-0.917222 -0.141111,-1.622778 -0.105834,-0.705555 -0.423334,-1.234722 -0.282222,-0.529167 -0.846666,-0.811389 -0.564445,-0.3175 -1.446389,-0.3175 -0.987778,0 -1.905,0.529167 -0.881945,0.493889 -1.552223,1.446389 -0.670277,0.917222 -1.058333,2.187222 -0.388056,1.27 -0.388056,2.751667 v 8.325555 h -3.175 V 76.205202 h 3.069167 q 0,0.881945 -0.07055,1.940278 -0.07056,1.023056 -0.176389,1.763889 l 0.03528,0.03528 q 0.776112,-1.869722 2.398889,-2.963333 1.622778,-1.093612 3.704167,-1.093612 1.305278,0 2.2225,0.388056 0.9525,0.388056 1.481667,1.023056 0.564444,0.599722 0.811389,1.27 0.246944,0.670277 0.3175,1.305277 0.3175,-0.705555 0.811389,-1.375833 0.493889,-0.670278 1.234722,-1.27 0.740833,-0.599722 1.728611,-0.9525 1.023056,-0.388056 2.2225,-0.388056 2.54,0 3.880556,1.411112 1.340555,1.411111 1.340555,4.339166 V 93.73826 Z" />
				<path id="path4745" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:35.27777863px;font-family:'GM Global Sans';-inkscape-font-specification:'GM Global Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.25;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 102.78082,85.518536 q -2.08139,0 -3.527782,0.282222 -1.446389,0.246945 -2.293055,0.705556 -0.846667,0.458611 -1.234723,1.058333 -0.352777,0.599722 -0.352777,1.305278 0,1.164167 0.740833,1.940278 0.740833,0.740833 1.940278,0.740833 1.023055,0 1.905,-0.458611 0.881946,-0.458611 1.516946,-1.27 0.635,-0.811389 0.9525,-1.763889 0.35278,-0.987778 0.35278,-2.010833 z m 0.17639,8.219722 q 0,-1.234722 0.0353,-2.010833 0.0353,-0.811389 0.14111,-1.481667 h -0.0705 q -0.67028,1.658056 -2.25778,2.751667 -1.587499,1.058333 -3.704166,1.058333 -2.187222,0 -3.527778,-1.305277 -1.340556,-1.305278 -1.340556,-3.421945 0,-2.8575 2.751667,-4.445 2.786945,-1.5875 7.796393,-1.5875 v -0.9525 q 0,-2.046111 -0.84667,-2.998611 -0.84667,-0.987778 -2.857501,-0.987778 -1.199444,0 -2.645833,0.352778 -1.411111,0.3175 -2.681111,0.881944 L 93.18526,77.122425 q 1.446389,-0.564445 3.069167,-0.881945 1.622778,-0.352778 3.175,-0.352778 1.834443,0 3.069163,0.423334 1.27,0.388055 2.01084,1.199444 0.77611,0.776111 1.09361,1.905 0.35278,1.093611 0.35278,2.575278 v 6.702778 q 0,1.27 0.0353,2.610556 0.0353,1.340555 0.0706,2.434166 z" />
				<path id="path4747" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:35.27777863px;font-family:'GM Global Sans';-inkscape-font-specification:'GM Global Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.25;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="M 112.00541,93.738258 V 76.205202 h 3.175 v 17.533056 z m 3.70416,-23.071667 q 0,0.846667 -0.635,1.446389 -0.59972,0.599722 -1.48166,0.599722 -0.88195,0 -1.51695,-0.564444 -0.59972,-0.599722 -0.59972,-1.481667 0,-0.881944 0.59972,-1.481667 0.635,-0.599722 1.51695,-0.599722 0.88194,0 1.48166,0.599722 0.635,0.599723 0.635,1.481667 z" />
				<path id="path4749" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:35.27777863px;font-family:'GM Global Sans';-inkscape-font-specification:'GM Global Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.25;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="M 132.31714,93.738258 V 82.449369 q 0,-1.975555 -0.67028,-2.963333 -0.67028,-0.987778 -2.32833,-0.987778 -1.05833,0 -1.97556,0.529167 -0.91722,0.493889 -1.5875,1.446389 -0.67027,0.917222 -1.05833,2.187222 -0.35278,1.234722 -0.35278,2.681111 v 8.396111 h -3.175 V 76.205202 h 3.06917 q 0,0.917223 -0.0706,1.940278 -0.0705,1.023056 -0.21166,1.763889 h 0.0705 q 0.77611,-1.869722 2.36361,-2.928055 1.62278,-1.093612 3.81,-1.093612 1.44639,0 2.46945,0.423334 1.05833,0.423333 1.65805,1.199444 0.635,0.740834 0.88195,1.763889 0.28222,0.987778 0.28222,2.2225 v 12.241389 z" />
				<path id="path4751" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:35.27777863px;font-family:'GM Global Sans';-inkscape-font-specification:'GM Global Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.25;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="M 141.42652,93.738258 V 76.205202 h 3.175 v 17.533056 z m 3.70416,-23.071667 q 0,0.846667 -0.635,1.446389 -0.59972,0.599722 -1.48166,0.599722 -0.88195,0 -1.51695,-0.564444 -0.59972,-0.599722 -0.59972,-1.481667 0,-0.881944 0.59972,-1.481667 0.635,-0.599722 1.51695,-0.599722 0.88194,0 1.48166,0.599722 0.635,0.599723 0.635,1.481667 z" />
				<path id="path4753" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:35.27777863px;font-family:'GM Global Sans';-inkscape-font-specification:'GM Global Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.25;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="M 161.73825,93.738258 V 82.449369 q 0,-1.975555 -0.67028,-2.963333 -0.67027,-0.987778 -2.32833,-0.987778 -1.05833,0 -1.97555,0.529167 -0.91723,0.493889 -1.5875,1.446389 -0.67028,0.917222 -1.05834,2.187222 -0.35278,1.234722 -0.35278,2.681111 v 8.396111 h -3.175 V 76.205202 h 3.06917 q 0,0.917223 -0.0705,1.940278 -0.0706,1.023056 -0.21167,1.763889 h 0.0705 q 0.77612,-1.869722 2.36362,-2.928055 1.62277,-1.093612 3.81,-1.093612 1.44638,0 2.46944,0.423334 1.05833,0.423333 1.65806,1.199444 0.635,0.740834 0.88194,1.763889 0.28222,0.987778 0.28222,2.2225 v 12.241389 z" />
				<path id="path4755" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:35.27777863px;font-family:'GM Global Sans';-inkscape-font-specification:'GM Global Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.25;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 181.39569,78.815758 q -0.77612,-0.176389 -1.55223,-0.246944 -0.77611,-0.105834 -1.5875,-0.105834 -1.27,0 -2.29305,0.423334 -1.02306,0.388055 -1.76389,1.234722 -0.70556,0.846666 -1.09361,2.187222 -0.38806,1.340556 -0.38806,3.210278 0,2.892778 0.9525,4.409722 0.9525,1.516945 2.89278,1.516945 1.16417,0 2.04611,-0.599722 0.91722,-0.599723 1.51695,-1.587501 0.635,-1.023055 0.9525,-2.2225 0.3175,-1.199444 0.3175,-2.398889 z m 3.13972,15.733889 q 0,2.046111 -0.59972,3.563056 -0.56445,1.552222 -1.69334,2.575277 -1.12889,1.02306 -2.78694,1.51695 -1.65806,0.52916 -3.84528,0.52916 -1.41111,0 -2.71639,-0.17639 -1.30528,-0.14111 -2.43417,-0.42333 l 0.35278,-2.928056 q 1.12889,0.388056 2.46945,0.599722 1.34055,0.211664 2.64583,0.211664 2.78694,0 4.1275,-1.269997 1.34056,-1.234722 1.34056,-3.915834 v -1.5875 q 0,-0.987777 0.0353,-1.693333 0.0706,-0.705555 0.21167,-1.340556 l -0.0706,-0.03528 q -0.70555,1.799166 -2.25777,2.8575 -1.51695,1.023055 -3.45723,1.023055 -3.13972,0 -4.83305,-2.081389 -1.65806,-2.116666 -1.65806,-6.173611 0,-2.293055 0.635,-4.1275 0.635,-1.834444 1.83445,-3.104444 1.19944,-1.305278 2.89278,-1.975556 1.72861,-0.670278 3.88055,-0.670278 1.48167,0 2.96333,0.141111 1.48167,0.105834 2.96334,0.352778 z" />
				<path id="path4757" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:35.27777863px;font-family:'GM Global Sans';-inkscape-font-specification:'GM Global Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.25;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 92.583885,116.73937 v 21.09611 H 89.33833 v -21.09611 h -6.843889 v -2.71639 h 16.968611 v 2.71639 z" />
				<path id="path4759" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:35.27777863px;font-family:'GM Global Sans';-inkscape-font-specification:'GM Global Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.25;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 102.29024,137.83548 v -17.53305 h 3.175 v 17.53305 z m 3.70416,-23.07167 q 0,0.84667 -0.635,1.44639 -0.59972,0.59973 -1.48166,0.59973 -0.88195,0 -1.51695,-0.56445 -0.59972,-0.59972 -0.59972,-1.48167 0,-0.88194 0.59972,-1.48166 0.635,-0.59972 1.51695,-0.59972 0.88194,0 1.48166,0.59972 0.635,0.59972 0.635,1.48166 z" />
				<path id="path4761" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:35.27777863px;font-family:'GM Global Sans';-inkscape-font-specification:'GM Global Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.25;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 123.30752,128.52215 q 0,-2.89278 -0.98777,-4.40972 -0.9525,-1.51695 -2.89278,-1.51695 -1.12889,0 -2.04611,0.59972 -0.91723,0.59973 -1.51695,1.62278 -0.59972,0.98778 -0.91722,2.18722 -0.3175,1.16417 -0.3175,2.36361 v 5.78556 q 1.37583,0.42333 3.10444,0.42333 1.27,0 2.29306,-0.38805 1.02306,-0.42334 1.76389,-1.27 0.74083,-0.84667 1.12889,-2.18722 0.38805,-1.37584 0.38805,-3.21028 z m 3.31611,-0.28222 q 0,4.65666 -2.39888,7.23194 -2.36362,2.57528 -6.63223,2.57528 -0.88194,0 -1.5875,-0.0353 -0.67027,-0.0353 -1.37583,-0.17639 v 8.71361 h -3.175 v -26.24666 h 3.06917 q 0,0.88194 -0.0706,1.905 -0.0705,0.98777 -0.21167,1.65805 l 0.0706,0.0353 q 0.74083,-1.83445 2.25778,-2.8575 1.55222,-1.05833 3.63361,-1.05833 3.06917,0 4.72722,2.15194 1.69333,2.11667 1.69333,6.10306 z" />
				<path id="path4763" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:35.27777863px;font-family:'GM Global Sans';-inkscape-font-specification:'GM Global Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.25;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 65.455274,169.97354 q 0,-4.58611 -2.257778,-6.94972 -2.2225,-2.36362 -6.808612,-2.36362 -0.776111,0 -1.940277,0.0353 -1.164167,0.0353 -1.622778,0.0706 v 18.34444 q 0.635,0.10584 1.481666,0.17639 0.881945,0.0353 1.658056,0.0353 2.116667,0 3.845278,-0.56445 1.763889,-0.56444 2.998611,-1.69333 1.27,-1.16417 1.940278,-2.92805 0.705556,-1.79917 0.705556,-4.16278 z m 3.421944,-0.21167 q 0,2.99861 -0.9525,5.32695 -0.9525,2.29305 -2.751667,3.88055 -1.763889,1.55222 -4.198055,2.32833 -2.434167,0.77612 -5.362223,0.77612 -1.27,0 -3.245555,-0.0706 -1.975556,-0.0706 -2.786945,-0.0706 V 158.1554 q 1.940278,-0.0353 3.739445,-0.0705 1.799166,-0.0706 3.386666,-0.0706 2.892778,0 5.150556,0.70556 2.257778,0.67027 3.81,2.11666 1.5875,1.44639 2.398889,3.66889 0.811389,2.2225 0.811389,5.25639 z" />
				<path id="path4765" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:35.27777863px;font-family:'GM Global Sans';-inkscape-font-specification:'GM Global Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.25;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 82.132293,167.22187 q -2.751667,-0.49389 -4.1275,1.44639 -1.340556,1.94028 -1.340556,6.20889 v 7.05555 h -3.175 v -17.53305 h 3.069167 q 0,0.91722 -0.105833,2.04611 -0.07056,1.09361 -0.282223,2.11667 h 0.07056 q 0.282222,-0.98778 0.776111,-1.83445 0.493889,-0.84666 1.234722,-1.48166 0.740834,-0.635 1.728612,-0.9525 1.023055,-0.35278 2.293055,-0.21167 z" />
				<path id="path4767" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:35.27777863px;font-family:'GM Global Sans';-inkscape-font-specification:'GM Global Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.25;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 95.601237,171.17298 q 0.03528,-2.25778 -1.023056,-3.45722 -1.023055,-1.23472 -2.892778,-1.23472 -1.763888,0 -2.963333,1.23472 -1.164167,1.23472 -1.411111,3.45722 z m 3.245556,0.14111 q 0,1.09361 -0.105834,2.08139 H 87.275681 q -0.03528,3.21028 1.27,4.7625 1.340556,1.55222 4.1275,1.55222 1.305278,0 2.575278,-0.24694 1.305278,-0.24694 2.610556,-0.70556 l 0.423333,2.43417 q -1.446389,0.52917 -2.963333,0.77611 -1.516945,0.28222 -3.033889,0.28222 -4.092223,0 -6.208889,-2.18722 -2.081389,-2.2225 -2.081389,-6.80861 0,-1.94028 0.529166,-3.63361 0.529167,-1.69333 1.552223,-2.92806 1.058333,-1.23472 2.504722,-1.905 1.481667,-0.70555 3.316111,-0.70555 1.799167,0 3.104445,0.56444 1.340555,0.56445 2.187222,1.55223 0.846667,0.98777 1.234722,2.29305 0.423334,1.30528 0.423334,2.82222 z" />
				<path id="path4769" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:35.27777863px;font-family:'GM Global Sans';-inkscape-font-specification:'GM Global Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.25;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 113.7274,176.88798 q 0,1.12889 -0.49389,2.11667 -0.45861,0.9525 -1.37583,1.69333 -0.91722,0.74084 -2.29306,1.16417 -1.34055,0.38805 -3.06916,0.38805 -1.09361,0 -2.18723,-0.14111 -1.09361,-0.10583 -1.94027,-0.3175 l 0.24694,-2.82222 q 0.88195,0.3175 1.97556,0.52917 1.12889,0.21166 2.15194,0.21166 1.79917,0 2.75167,-0.67027 0.9525,-0.67028 0.9525,-1.905 0,-0.88195 -0.56445,-1.44639 -0.52916,-0.56445 -1.69333,-0.98778 -1.12889,-0.45861 -2.11667,-0.81139 -0.98777,-0.35278 -1.86972,-0.88194 -0.84667,-0.52917 -1.41111,-1.44639 -0.56444,-0.9525 -0.56444,-2.39889 0,-2.2225 1.79916,-3.63361 1.79917,-1.44639 5.11528,-1.44639 0.88194,0 1.76389,0.10583 0.88194,0.0706 1.62278,0.21167 l -0.21167,2.64583 q -0.77611,-0.24694 -1.69333,-0.38805 -0.91723,-0.14111 -1.76389,-0.14111 -1.65806,0 -2.54,0.635 -0.84667,0.635 -0.84667,1.72861 0,0.88194 0.52917,1.44639 0.56444,0.52916 1.72861,0.98777 1.16417,0.45861 2.11667,0.81139 0.98777,0.35278 1.86972,0.91722 0.88194,0.52917 1.44639,1.48167 0.56444,0.91722 0.56444,2.36361 z" />
				<path id="path4771" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:35.27777863px;font-family:'GM Global Sans';-inkscape-font-specification:'GM Global Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.25;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 128.74802,176.88798 q 0,1.12889 -0.49389,2.11667 -0.45861,0.9525 -1.37583,1.69333 -0.91722,0.74084 -2.29305,1.16417 -1.34056,0.38805 -3.06917,0.38805 -1.09361,0 -2.18722,-0.14111 -1.09361,-0.10583 -1.94028,-0.3175 l 0.24694,-2.82222 q 0.88195,0.3175 1.97556,0.52917 1.12889,0.21166 2.15194,0.21166 1.79917,0 2.75167,-0.67027 0.9525,-0.67028 0.9525,-1.905 0,-0.88195 -0.56444,-1.44639 -0.52917,-0.56445 -1.69334,-0.98778 -1.12889,-0.45861 -2.11666,-0.81139 -0.98778,-0.35278 -1.86973,-0.88194 -0.84666,-0.52917 -1.41111,-1.44639 -0.56444,-0.9525 -0.56444,-2.39889 0,-2.2225 1.79916,-3.63361 1.79917,-1.44639 5.11528,-1.44639 0.88195,0 1.76389,0.10583 0.88195,0.0706 1.62278,0.21167 l -0.21167,2.64583 q -0.77611,-0.24694 -1.69333,-0.38805 -0.91722,-0.14111 -1.76389,-0.14111 -1.65806,0 -2.54,0.635 -0.84667,0.635 -0.84667,1.72861 0,0.88194 0.52917,1.44639 0.56444,0.52916 1.72861,0.98777 1.16417,0.45861 2.11667,0.81139 0.98778,0.35278 1.86972,0.91722 0.88194,0.52917 1.44639,1.48167 0.56444,0.91722 0.56444,2.36361 z" />
				<path id="path4773" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:35.27777863px;font-family:'GM Global Sans';-inkscape-font-specification:'GM Global Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.25;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 143.55697,171.17298 q 0.0353,-2.25778 -1.02305,-3.45722 -1.02306,-1.23472 -2.89278,-1.23472 -1.76389,0 -2.96334,1.23472 -1.16416,1.23472 -1.41111,3.45722 z m 3.24556,0.14111 q 0,1.09361 -0.10584,2.08139 h -11.46527 q -0.0353,3.21028 1.27,4.7625 1.34055,1.55222 4.1275,1.55222 1.30527,0 2.57527,-0.24694 1.30528,-0.24694 2.61056,-0.70556 l 0.42333,2.43417 q -1.44639,0.52917 -2.96333,0.77611 -1.51695,0.28222 -3.03389,0.28222 -4.09222,0 -6.20889,-2.18722 -2.08139,-2.2225 -2.08139,-6.80861 0,-1.94028 0.52917,-3.63361 0.52917,-1.69333 1.55222,-2.92806 1.05833,-1.23472 2.50472,-1.905 1.48167,-0.70555 3.31611,-0.70555 1.79917,0 3.10445,0.56444 1.34055,0.56445 2.18722,1.55223 0.84667,0.98777 1.23472,2.29305 0.42334,1.30528 0.42334,2.82222 z" />
				<path id="path4775" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:35.27777863px;font-family:'GM Global Sans';-inkscape-font-specification:'GM Global Sans, Normal';font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-feature-settings:normal;text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:1.25;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="m 161.68314,176.88798 q 0,1.12889 -0.49389,2.11667 -0.45861,0.9525 -1.37584,1.69333 -0.91722,0.74084 -2.29305,1.16417 -1.34056,0.38805 -3.06917,0.38805 -1.09361,0 -2.18722,-0.14111 -1.09361,-0.10583 -1.94028,-0.3175 l 0.24694,-2.82222 q 0.88195,0.3175 1.97556,0.52917 1.12889,0.21166 2.15195,0.21166 1.79916,0 2.75166,-0.67027 0.9525,-0.67028 0.9525,-1.905 0,-0.88195 -0.56444,-1.44639 -0.52917,-0.56445 -1.69334,-0.98778 -1.12888,-0.45861 -2.11666,-0.81139 -0.98778,-0.35278 -1.86973,-0.88194 -0.84666,-0.52917 -1.41111,-1.44639 -0.56444,-0.9525 -0.56444,-2.39889 0,-2.2225 1.79917,-3.63361 1.79916,-1.44639 5.11527,-1.44639 0.88195,0 1.76389,0.10583 0.88195,0.0706 1.62278,0.21167 l -0.21167,2.64583 q -0.77611,-0.24694 -1.69333,-0.38805 -0.91722,-0.14111 -1.76389,-0.14111 -1.65805,0 -2.54,0.635 -0.84666,0.635 -0.84666,1.72861 0,0.88194 0.52916,1.44639 0.56445,0.52916 1.72861,0.98777 1.16417,0.45861 2.11667,0.81139 0.98778,0.35278 1.86972,0.91722 0.88195,0.52917 1.44639,1.48167 0.56445,0.91722 0.56445,2.36361 z" /> </g>
		</g>
	</svg>
	`
	// fyneLogo := theme.FyneLogo()
	// iconResource := fyne.NewStaticResource("icon.svg", []byte(iconSvg))

	iconResource := theme.FyneLogo()
	fyneLogo := fyne.NewStaticResource("icon.svg", []byte(iconSvg))

	myApp := app.New()
	myApp.SetIcon(iconResource)
	w := myApp.NewWindow("Icon")
	image := canvas.NewImageFromResource(iconResource)
	image.FillMode = canvas.ImageFillOriginal
	w.SetContent(image)
	w.SetIcon(fyneLogo)
	w.ShowAndRun()
}

image
image

After adding condition getting error but the icon is visible in window as shown in the screenshot with just painter.PaintImage I don't get any error message.

@Jacalz
Copy link
Member

Jacalz commented Nov 29, 2021

Why do you use http.DetectContentType? The simplest solution for checking if it is an svg is already included in the repository in part of the code that you removed as part of this change. I don't see any reason why the png images would suddenly fail if you they are passed the same way as they were before this change.

Btw, it is better to push up code changes and let us study them in detail and run the CI tests on them than looking at code snippets in comments.

andydotxyz added a commit that referenced this pull request Nov 29, 2021
Thanks @ChandanChainani for the inspiration.
Fixes #2579
@andydotxyz andydotxyz mentioned this pull request Nov 29, 2021
7 tasks
@andydotxyz
Copy link
Member

This conversation isn't getting anywhere fast sorry.
Any objections to landing #2670 instead? I think that is the minimal change we were looking for...

@Jacalz
Copy link
Member

Jacalz commented Nov 29, 2021

Sounds good to me 👍

@andydotxyz
Copy link
Member

Nice use of IsResourceSVG.
Not sure that the benchmark adds anything now though.
Performance has not been impacted - just added support to a new image type.

if err != nil {
fyne.LogError("Failed to decode image for window icon", err)
return
var (
Copy link
Member

Choose a reason for hiding this comment

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

I think that err has the wrong scope here - it only applies to one branch of the if

@ChandanChainani
Copy link
Contributor Author

@andydotxyz Please check new request that contains changes as suggested #2671

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants