-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
How to specify encoding for SVG background rendering? #1873
Comments
Sorry, only now I've realized that I can use unicode numbers. This works properly:
Do I have to transform my DB text content before rendering? Or is there any way to specify the encoding at rendering time, like
I tried that in Cytoscape but it does not work: (Note: jsfiddle's result html has |
<text>
containing Umlaute breaks rendering
Sorry again. Now I've tried ISO encoding, and it works!
https://jsfiddle.net/jri_/hrxp965e/2/ What puzzles me is that source entered/rendered at the JSFiddle site is apparently encoded in |
There are browser differences too. This works in Safari, and Firefox, but not in Chrome:
|
If it's working in some browsers and not others, then it's a bug in the way that the particular browser draws an svg image to canvas. Browsers seem to have differences in how they render svg to canvas as compared to how they render svg in the html dom. A few years ago, even basic svg in the dom had many bugs and differences between the browsers. Maybe it's a bit better now, but unreliable browser support for svg is one of the reasons cyjs uses canvas. There's not much that can be done on the cyjs end to remedy that. So it's probably best to file bugs in the issue trackers for the offending browsers. This is the most reliable way of using svg data uri images that we've found:
This way you can explicitly specify the encoding --- in both the url and the svg itself just in case the browser ignores one --- and |
It seems to work in this case: https://jsfiddle.net/hrxp965e/4/ |
Indeed, not using Base64 encoding and encode with This way it works in all my browsers (Safari, Firefox, Chrome) even without specifying This was a very helpful hint! This issue can be closed. You're right, we should file browser bug reports. |
Rendering SVG node background images does work in principle (the white background and the text "Node" are rendered as SVG
<rect>
and<text>
respectively):https://jsfiddle.net/u7asnwdp/6/
But if a SVG
<text>
element contains an Umlaut (e.g. ä ö ü) SVG rendering breaks completely (here the red background is a result of Cytoscape style'background-color': 'red'
):https://jsfiddle.net/jri_/hrxp965e/
Apparently this is an error in the Cytoscape SVG rendering code.
That pure SVG (without Cytoscape involved) has no problem with rendering Umlaute is shown here:
https://jsfiddle.net/jri_/26cr7q1e/1/
The text was updated successfully, but these errors were encountered: