fyne does not render text from SVG files.
jimorc opened this issue · comments
Jim Orcheson commented
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 created an SVG image containing text using Inkscape. I have bundled the image into a simple program to display the image, but no image is displayed. If I create an image with text and other objects, the objects are displayed but the text is not.
Here is the content of bundled.go as generated using the instructions below:
var resourceTextSvg = &fyne.StaticResource{
StaticName: "text.svg",
StaticContent: []byte(
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n<!-- Created with Inkscape (http://www.inkscape.org/) -->\n\n<svg\n width=\"210mm\"\n height=\"297mm\"\n viewBox=\"0 0 210 297\"\n version=\"1.1\"\n id=\"svg1\"\n inkscape:version=\"1.3.2 (091e20e, 2023-11-25)\"\n sodipodi:docname=\"text.svg\"\n xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"\n xmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:svg=\"http://www.w3.org/2000/svg\">\n <sodipodi:namedview\n id=\"namedview1\"\n pagecolor=\"#505050\"\n bordercolor=\"#eeeeee\"\n borderopacity=\"1\"\n inkscape:showpageshadow=\"0\"\n inkscape:pageopacity=\"0\"\n inkscape:pagecheckerboard=\"0\"\n inkscape:deskcolor=\"#505050\"\n inkscape:document-units=\"mm\"\n inkscape:zoom=\"0.2102413\"\n inkscape:cx=\"394.78447\"\n inkscape:cy=\"561.25984\"\n inkscape:window-width=\"1312\"\n inkscape:window-height=\"449\"\n inkscape:window-x=\"0\"\n inkscape:window-y=\"25\"\n inkscape:window-maximized=\"0\"\n inkscape:current-layer=\"layer1\" />\n <defs\n id=\"defs1\" />\n <g\n inkscape:label=\"Layer 1\"\n inkscape:groupmode=\"layer\"\n id=\"layer1\">\n <text\n xml:space=\"preserve\"\n style=\"font-size:43.4281px;fill:#00ff00;stroke-width:5.4285\"\n x=\"28.561747\"\n y=\"86.570786\"\n id=\"text1\"\n transform=\"scale(0.95191966,1.0505088)\"><tspan\n sodipodi:role=\"line\"\n id=\"tspan1\"\n style=\"stroke-width:5.4285\"\n x=\"28.561747\"\n y=\"86.570786\">A bunch</tspan><tspan\n sodipodi:role=\"line\"\n style=\"stroke-width:5.4285\"\n x=\"28.561747\"\n y=\"140.85587\"\n id=\"tspan2\">of text</tspan></text>\n </g>\n</svg>\n"),
}
How to reproduce
- Create an SVG image containing text using Inkscape.
- Save file to program source directory as text.svg
- fyne bundle -o bundled.go $GOPATH/source-dir/text.svg
- go run .
Screenshots
Here is the image as created in Inkscape:
Using the program in the example code, below, this is what is displayed:
Example code
package main
import (
"fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/canvas"
)
func main() {
myApp := app.New()
mainWin := myApp.NewWindow("image test")
image := canvas.NewImageFromResource(resourceTextSvg)
mainWin.SetContent(image)
mainWin.Resize(fyne.NewSize(300, 300))
mainWin.ShowAndRun()
}
Fyne version
2.4.4
Go compiler version
1.22.1 darwin/arm64
Operating system and version
macOS 14.4.1
Additional Information
No response
Andy Williams commented
You're right our SVG parser does not yet handle text.
This is a duplicate of #685