SVG textPath with linear gradient is damaged in Safari - ios

The textPath is damaged when I fill linear gradient.
How to fix it?
Thanks.
[[the broken image]]: https://i.stack.imgur.com/200t3.png
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.dev/svgjs" width="1000" height="1000">
<g font-size="42.5" font-weight="800">
<path d="M 400, 400
m -100, 0
a 100, 100 0 1,0 200, 0
a 100, 100 0 1,0 -200, 0" fill="transparent" stroke="black" id="SvgjsPath1000"></path>
<circle r="4" cx="400" cy="400" fill="#000000"></circle>
<text stroke-width="10" svgjs:data="{"leading":"1.3"}">
<textPath xlink:href="#SvgjsPath1000" fill="transparent" stroke="#ffffff" svgjs:data="{"leading":"1.3"}">
<tspan alignment-baseline="middle">RRRRRRRRRRRRRRRRRRRRR</tspan>
</textPath>
</text>
<text svgjs:data="{"leading":"1.3"}">
<textPath xlink:href="#SvgjsPath1000" fill="url("#SvgjsLinearGradient1001")" svgjs:data="{"leading":"1.3"}">
<tspan alignment-baseline="middle">RRRRRRRRRRRRRRRRRRRRR</tspan>
</textPath>
</text>
</g>
<defs>
<linearGradient x1="0%" y1="0%" x2="100%" y2="0%" id="SvgjsLinearGradient1001">
<stop offset="0" style="stop-color:#007cf0"></stop>
<stop offset="1" style="stop-color:#ff0080"></stop>
</linearGradient>
</defs>
</svg>

Apparently, a safari specific rendering bug when applying gradients to <textPath> elements.
I could also reproduce this issue with a simplified example (testing in iOS safari):
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<defs>
<linearGradient id="myGradient" gradientTransform="rotate(90)">
<stop offset="5%" stop-color="gold" />
<stop offset="95%" stop-color="red" />
</linearGradient>
</defs>
<path
id="MyPath"
fill="none"
stroke="red"
d="M10,90 Q90,90 90,45 Q90,10 50,10 Q10,10 10,40 Q10,70 45,70 Q70,70 75,50" />
<text>
<textPath fill="url('#myGradient')" href="#MyPath">Quick brown fox jumps over the lazy dog.</textPath>
</text>
</svg>
Workaround: create a <mask> containing the text path:
body {
background: #ccc
}
svg {
width: 50%;
border: 1px solid #000
}
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.dev/svgjs" viewBox="250 250 300 300">
<defs>
<linearGradient x1="0%" y1="0%" x2="100%" y2="0%" id="SvgjsLinearGradient1001">
<stop offset="0" style="stop-color:#007cf0"></stop>
<stop offset="1" style="stop-color:#ff0080"></stop>
</linearGradient>
<mask id="mask" x="0" y="0" width="200%" height="200%">
<rect fill="#000" x="0" y="0" width="200%" height="200%" />
<text>
<textPath class="textPath" font-size="42.5" font-weight="800" href="#SvgjsPath1000" dominant-baseline="middle" fill="#fff">
RRRRRRRRRRRRRRRRRRRRR
</textPath>
</text>
</mask>
</defs>
<g>
<path d="M 300 400 a 100 100 0 1 0 200 0 a 100 100 0 1 0 -200 0 z" fill="transparent" stroke="black" id="SvgjsPath1000" />
<circle r="4" cx="400" cy="400" fill="#000000" />
<text>
<textPath class="textPath" font-size="42.5" font-weight="800" href="#SvgjsPath1000" dominant-baseline="middle" fill="transparent" stroke="#fff" stroke-width="10">
RRRRRRRRRRRRRRRRRRRRR
</textPath>
</text>
<rect mask="url(#mask)" fill="url(#SvgjsLinearGradient1001)" x="0" y="0" width="200%" height="200%" />
</g>
</svg>

Related

Failed to position text in SVG on iPhone with Itext 7.1.14

I added an SVG chart to a PDF with Itext 7.1.14.
On Windows and Android, it worked normally.
However, on the iPhone or Macbook, the text is upside down and everything is on top, on the left side.
What can I do to resolve this?
Compare:
Image 1 - On Windows and Android
Image 2 - On iPhone
Code to generate the chart with Google Charts:
google.charts.load('current', { 'packages': ['corechart'] });
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable(participantesGrafico);
var view = new google.visualization.DataView(data);
view.setColumns([0, 1,
{
calc: "stringify",
sourceColumn: 1,
type: "string",
role: "annotation"
},
2]);
//let fonte = 'bebas';
let fonte = 'Arial';
var options = {
title: "MÉDIAS",
width: 700,
height: 50 * participantes.length,
bar: { groupWidth: "80%" },
legend: { position: "none" },
chartArea: {
top: 20,
bottom: 20,
left: 100,
right: 20
},
hAxis: { textStyle: { fontName: fonte }, titleTextStyle: { fontName: fonte } },
vAxis: { textStyle: { fontName: fonte }, titleTextStyle: { fontName: fonte } },
titleTextStyle: { fontName: fonte },
tooltip: { textStyle: { fontName: fonte } },
fontName: fonte,
};
var chart = new google.visualization.BarChart(document.getElementById("graficoMedias"));
chart.draw(view, options);
}
Get in SVG. From SVG to String:
var grafico1 = document.getElementById('graficoMedias').getElementsByTagName('svg')[0].outerHTML;
SVG generated by Google Chart:
<svg width="700" height="200" aria-label="A chart." style="overflow: hidden;"><defs id="_ABSTRACT_RENDERER_ID_0"><clipPath id="_ABSTRACT_RENDERER_ID_1"><rect x="100" y="20" width="580" height="160"></rect></clipPath><filter id="_ABSTRACT_RENDERER_ID_2"><feGaussianBlur in="SourceAlpha" stdDeviation="2"></feGaussianBlur><feOffset dx="1" dy="1"></feOffset><feComponentTransfer><feFuncA type="linear" slope="0.1"></feFuncA></feComponentTransfer><feMerge><feMergeNode></feMergeNode><feMergeNode in="SourceGraphic"></feMergeNode></feMerge></filter></defs><rect x="0" y="0" width="700" height="200" stroke="none" stroke-width="0" fill="#ffffff"></rect><g><text text-anchor="start" x="100" y="14.2" font-family="Arial" font-size="12" font-weight="bold" stroke="none" stroke-width="0" fill="#000000">MÉDIAS</text><rect x="100" y="4" width="580" height="12" stroke="none" stroke-width="0" fill-opacity="0" fill="#ffffff"></rect></g><g><rect x="100" y="20" width="580" height="160" stroke="none" stroke-width="0" fill-opacity="0" fill="#ffffff"></rect><g clip-path="url(https://localhost:44322/Evento/Evento/976#_ABSTRACT_RENDERER_ID_1)"><g><rect x="100" y="20" width="1" height="160" stroke="none" stroke-width="0" fill="#cccccc"></rect><rect x="216" y="20" width="1" height="160" stroke="none" stroke-width="0" fill="#cccccc"></rect><rect x="332" y="20" width="1" height="160" stroke="none" stroke-width="0" fill="#cccccc"></rect><rect x="447" y="20" width="1" height="160" stroke="none" stroke-width="0" fill="#cccccc"></rect><rect x="563" y="20" width="1" height="160" stroke="none" stroke-width="0" fill="#cccccc"></rect><rect x="679" y="20" width="1" height="160" stroke="none" stroke-width="0" fill="#cccccc"></rect><rect x="158" y="20" width="1" height="160" stroke="none" stroke-width="0" fill="#ebebeb"></rect><rect x="274" y="20" width="1" height="160" stroke="none" stroke-width="0" fill="#ebebeb"></rect><rect x="390" y="20" width="1" height="160" stroke="none" stroke-width="0" fill="#ebebeb"></rect><rect x="505" y="20" width="1" height="160" stroke="none" stroke-width="0" fill="#ebebeb"></rect><rect x="621" y="20" width="1" height="160" stroke="none" stroke-width="0" fill="#ebebeb"></rect></g><g><rect x="101" y="24" width="216" height="32" stroke="#3f51b5" stroke-width="1" fill="#3f51b5"></rect><rect x="101" y="64" width="303" height="32" stroke="#3f51b5" stroke-width="1" fill="#3f51b5"></rect><rect x="101" y="104" width="506" height="32" stroke="#3f51b5" stroke-width="1" fill="#3f51b5"></rect><rect x="101" y="144" width="419" height="32" stroke="#3f51b5" stroke-width="1" fill="#3f51b5"></rect></g><g><rect x="100" y="20" width="1" height="160" stroke="none" stroke-width="0" fill="#333333"></rect></g><g><rect x="317" y="40" width="0" height="1" stroke="none" stroke-width="0" fill="#999999"></rect><rect x="404" y="80" width="0" height="1" stroke="none" stroke-width="0" fill="#999999"></rect><rect x="607" y="120" width="0" height="1" stroke="none" stroke-width="0" fill="#999999"></rect><rect x="520" y="160" width="0" height="1" stroke="none" stroke-width="0" fill="#999999"></rect></g></g><g></g><g><g><text text-anchor="middle" x="100.5" y="194.2" font-family="Arial" font-size="12" stroke="none" stroke-width="0" fill="#444444">0</text></g><g><text text-anchor="middle" x="216.3" y="194.2" font-family="Arial" font-size="12" stroke="none" stroke-width="0" fill="#444444">2</text></g><g><text text-anchor="middle" x="332.1" y="194.2" font-family="Arial" font-size="12" stroke="none" stroke-width="0" fill="#444444">4</text></g><g><text text-anchor="middle" x="447.9" y="194.2" font-family="Arial" font-size="12" stroke="none" stroke-width="0" fill="#444444">6</text></g><g><text text-anchor="middle" x="563.7" y="194.2" font-family="Arial" font-size="12" stroke="none" stroke-width="0" fill="#444444">8</text></g><g><text text-anchor="middle" x="679.5" y="194.2" font-family="Arial" font-size="12" stroke="none" stroke-width="0" fill="#444444">10</text></g><g><text text-anchor="end" x="88" y="44.575" font-family="Arial" font-size="12" stroke="none" stroke-width="0" fill="#222222">Chromium</text></g><g><text text-anchor="end" x="88" y="84.325" font-family="Arial" font-size="12" stroke="none" stroke-width="0" fill="#222222">Edge</text></g><g><text text-anchor="end" x="88" y="124.075" font-family="Arial" font-size="12" stroke="none" stroke-width="0" fill="#222222">Firefox</text></g><g><text text-anchor="end" x="88" y="163.825" font-family="Arial" font-size="12" stroke="none" stroke-width="0" fill="#222222">Opera</text></g></g><g><g><g><text text-anchor="end" x="313" y="44.2" font-family="Arial" font-size="12" stroke="none" stroke-width="0" fill="#ffffff">3.74</text><rect x="290" y="34" width="23" height="12" stroke="none" stroke-width="0" fill-opacity="0" fill="#ffffff"></rect></g></g><g><g><text text-anchor="end" x="400" y="84.2" font-family="Arial" font-size="12" stroke="none" stroke-width="0" fill="#ffffff">5.25</text><rect x="377" y="74" width="23" height="12" stroke="none" stroke-width="0" fill-opacity="0" fill="#ffffff"></rect></g></g><g><g><text text-anchor="end" x="603" y="124.2" font-family="Arial" font-size="12" stroke="none" stroke-width="0" fill="#ffffff">8.75</text><rect x="580" y="114" width="23" height="12" stroke="none" stroke-width="0" fill-opacity="0" fill="#ffffff"></rect></g></g><g><g><text text-anchor="end" x="516" y="164.2" font-family="Arial" font-size="12" stroke="none" stroke-width="0" fill="#ffffff">7.25</text><rect x="493" y="154" width="23" height="12" stroke="none" stroke-width="0" fill-opacity="0" fill="#ffffff"></rect></g></g></g></g><g></g></svg>
C# code:
byte[] b = Encoding.UTF8.GetBytes(grafico1);
MemoryStream ms2 = new MemoryStream(b);
Image i = SvgConverter.ConvertToImage(ms2, document.GetPdfDocument());
document.Add(i);

.Net Core change Swashbuckle favicon from custom html

I am trying to customize the favicon for our .net core api and set it to an image within our project structure. I am not able to get it to load though and have tried a few things that have not worked. This is how I am using my custom html for Swashbuckle in Startup.cs (Located in a folder called Swagger):
app.UseSwaggerUI(c =>
{
c.IndexStream = () => GetType().GetTypeInfo().Assembly
.GetManifestResourceStream("MyProject.Swagger.index.html");
});
Attempt #1:
Add the use of StaticFiles to my Startup.cs Configure method like so:
app.UseStaticFiles();
Then I placed the the logo.png (Set as Copy Always) inside the wwwroot folder under an Images folder and tried to reference it in the html like this. (I have also tried to reference it from an Images folder in the same directory as the html).
<link rel="icon" type="image/png" href="~/Images/logo.png" />
No dice and there is now no favicon in the tab.
Attempt #2.
Overwrite the favicon via Javascript inside the html file.
var link = document.querySelector("link[rel*='icon']") || document.createElement('link');
link.type = 'image/png';
link.rel = 'icon';
link.href = '~/Images/logo.png';
document.getElementsByTagName('head')[0].appendChild(link);
No dice, the swagger favicon still exists.
Has anybody successfully been able to replace the favicon using Swashbuckle?
The version of Swashbuckle I am using is Swashbuckle.AspNetCore 2.4.0
This is the html file I am using based on the default file from here https://github.com/domaindrivendev/Swashbuckle.AspNetCore/blob/master/src/Swashbuckle.AspNetCore.SwaggerUI/index.html
<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>%(DocumentTitle)</title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="./swagger-ui.css">
<link rel="icon" type="image/png" href="~/Images/logo.png" />
<style>
html {
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
margin: 0;
background: #fafafa;
}
hgroup.main {
display: none;
}
.swagger-ui .topbar {
background-color: #00CCCC;
}
</style>
%(HeadContent)
</head>
<body>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" style="position:absolute;width:0;height:0">
<defs>
<symbol viewBox="0 0 20 20" id="unlocked">
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V6h2v-.801C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8z"></path>
</symbol>
<symbol viewBox="0 0 20 20" id="locked">
<path d="M15.8 8H14V5.6C14 2.703 12.665 1 10 1 7.334 1 6 2.703 6 5.6V8H4c-.553 0-1 .646-1 1.199V17c0 .549.428 1.139.951 1.307l1.197.387C5.672 18.861 6.55 19 7.1 19h5.8c.549 0 1.428-.139 1.951-.307l1.196-.387c.524-.167.953-.757.953-1.306V9.199C17 8.646 16.352 8 15.8 8zM12 8H8V5.199C8 3.754 8.797 3 10 3c1.203 0 2 .754 2 2.199V8z" />
</symbol>
<symbol viewBox="0 0 20 20" id="close">
<path d="M14.348 14.849c-.469.469-1.229.469-1.697 0L10 11.819l-2.651 3.029c-.469.469-1.229.469-1.697 0-.469-.469-.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-.469-.469-.469-1.228 0-1.697.469-.469 1.228-.469 1.697 0L10 8.183l2.651-3.031c.469-.469 1.228-.469 1.697 0 .469.469.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c.469.469.469 1.229 0 1.698z" />
</symbol>
<symbol viewBox="0 0 20 20" id="large-arrow">
<path d="M13.25 10L6.109 2.58c-.268-.27-.268-.707 0-.979.268-.27.701-.27.969 0l7.83 7.908c.268.271.268.709 0 .979l-7.83 7.908c-.268.271-.701.27-.969 0-.268-.269-.268-.707 0-.979L13.25 10z" />
</symbol>
<symbol viewBox="0 0 20 20" id="large-arrow-down">
<path d="M17.418 6.109c.272-.268.709-.268.979 0s.271.701 0 .969l-7.908 7.83c-.27.268-.707.268-.979 0l-7.908-7.83c-.27-.268-.27-.701 0-.969.271-.268.709-.268.979 0L10 13.25l7.418-7.141z" />
</symbol>
<symbol viewBox="0 0 24 24" id="jump-to">
<path d="M19 7v4H5.83l3.58-3.59L8 6l-6 6 6 6 1.41-1.41L5.83 13H21V7z" />
</symbol>
<symbol viewBox="0 0 24 24" id="expand">
<path d="M10 18h4v-2h-4v2zM3 6v2h18V6H3zm3 7h12v-2H6v2z" />
</symbol>
</defs>
</svg>
<div id="swagger-ui"></div>
<!-- Workaround for https://github.com/swagger-api/swagger-editor/issues/1371 -->
<script>
if (window.navigator.userAgent.indexOf("Edge") > -1) {
console.log("Removing native Edge fetch in favor of swagger-ui's polyfill")
window.fetch = undefined;
}
</script>
<script src="./swagger-ui-bundle.js"></script>
<script src="./swagger-ui-standalone-preset.js"></script>
<script>
window.onload = function () {
var configObject = JSON.parse('%(ConfigObject)');
var oauthConfigObject = JSON.parse('%(OAuthConfigObject)');
// Apply mandatory parameters
configObject.dom_id = "#swagger-ui";
configObject.presets = [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset];
configObject.layout = "StandaloneLayout";
// If oauth2RedirectUrl isn't specified, use the built-in default
if (!configObject.hasOwnProperty("oauth2RedirectUrl"))
configObject.oauth2RedirectUrl = window.location.href.replace("index.html", "oauth2-redirect.html");
// Build a system
const ui = SwaggerUIBundle(configObject);
// Apply OAuth config
ui.initOAuth(oauthConfigObject);
//Custom scripting
document.getElementsByClassName("link")[0].innerHTML = "Application Name";
document.getElementsByClassName("link")[0].removeAttribute("href");
}
</script>
</body>
I ran into a similar problem. However, I utilized the Index located here:
https://github.com/domaindrivendev/Swashbuckle.AspNetCore/tree/master/test/WebSites/CustomUIIndex/Swagger
From here, I was able to change the logo with the following:
<div id="header">
<section class="swagger-ui swagger-container" data-reactroot="">
<div class="topbar">
<div class="wrapper">
<div class="topbar-wrapper">
<a class="link">
<img alt="Swagger UI" src="/Swagger/UI/Logo.jpg" />
<span style="font-size:medium; color:black;text-wrap:none;text-align:right" >YourTitle</span>
</a>
</div>
</div>
</div>
</section>
</div>

svg animate not working on ios

here is my svg animation...its working everywhere but ios (safari or chrome)
<svg width="44" height="44" viewBox="0 0 44 44" xmlns="http://www.w3.org/2000/svg" stroke="#519ecb">
<g fill="none" fill-rule="evenodd" stroke-width="2">
<circle cx="22" cy="22" r="1">
<animate attributeName="r" begin="0s" dur="2.5s" values="1; 20" calcMode="spline" keyTimes="0; 1" keySplines="0.165, 0.84, 0.44, 1"/>
<animate attributeName="stroke-opacity" begin="0s" dur="2.5s" values="1; 0" calcMode="spline" keyTimes="0; 1" keySplines="0.3, 0.61, 0.355, 1" />
</circle>
<circle cx="22" cy="22" r="1">
<animate attributeName="r" begin="-0.9s" dur="2.5s" values="1; 20" calcMode="spline" keyTimes="0; 1" keySplines="0.165, 0.84, 0.44, 1" />
<animate attributeName="stroke-opacity" begin="-0.9s" dur="2.5s" values="1; 0" calcMode="spline" keyTimes="0; 1" keySplines="0.3, 0.61, 0.355, 1" />
</circle>
</g>
</svg>
each animate tag has repeatCount="indefinite" attr but I couldnt write here on code view because of stackoverflow post rules...Its very hard to ask something here...

SVG transparency not preserved on iOS (iPad/iPhone)

I have an SVG that doesn't seem to work with iOS devices.
I've tried in both chrome and safari only the SVG appears as a solid blue block colour and doesn't preserve the different layers and their opacity levels...
https://jsfiddle.net/2fLuspdm/
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 1920 3840" style="enable-background:new 0 0 1920 3840;" xml:space="preserve">
<style type="text/css">
.st0{opacity:6.000000e-02;fill:#609FD0;enable-background:new ;}
</style>
<polygon class="st0" points="1920,2614 1920,3641 1470,3005.1 "/>
<polygon class="st0" points="1920,1612.4 1210,780 1920,0.4 "/>
<polyline class="st0" points="0,0 650,0 0,1184.3 1,0 "/>
<polygon class="st0" points="0,898.4 960,1457 0,2778.4 "/>
<polygon class="st0" points="0,3837.4 0,2654 1040,3840 "/>
<polygon class="st0" points="1920,2926 1424,2239 1920,1046 "/>
<polygon class="st0" points="829,3840 1920,2926 1936,3840 "/>
<polygon class="st0" points="0,2530 0,1760 960,2909 "/>
<polygon class="st0" points="1920,0.4 1920,622 40,0.4 "/>
<polygon class="st0" points="1920,1634.5 1920,2404.5 1150,1435.5 "/>
</svg>
Simply compute the exponential (not sure if it's valid SVG syntax, but Safari doesn't like it).
<style type="text/css">
.st0{opacity:.06; fill:#609FD0; enable-background:new ;}
</style>

reference SVG cursor from the same document

I want to use a custom cursor in my SVG file.
The cursor is defined in the same SVG file as the rest of my document:
<defs>
<g id="cursor-symbol">
<circle fill-opacity="0.8" fill="white" r="10.0" cx="10.0" cy="10.0" stroke="black" stroke-width="2.0" stroke-opacity="1"/>
<line y2="20.0" x1="10.0" x2="0.0" transform="rotate(45.0, 10.0, 10.0)" y1="10.0"/>
</g>
</defs>
Then I tried to use that cursor, but can't find out how to reference it:
<rect cursor="url(#cursor-symbol)" x="0" y="0" width="100" height="100" />
The attribute value seems to be invalid.
I also created a cursor element and tried with that:
<defs>
<g id="cursor-symbol">
<circle fill-opacity="0.8" fill="white" r="10.0" cx="10.0" cy="10.0" stroke="black" stroke-width="2.0" stroke-opacity="1"/>
<line y2="20.0" x1="10.0" x2="0.0" transform="rotate(45.0, 10.0, 10.0)" y1="10.0"/>
</g>
<cursor id="cursor" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#cursor-symbol"/>
</defs>
...
<rect cursor="url(#cursor)" x="0" y="0" width="100" height="100" />
but to no avail.
How to I reference such a cursor that is defined in the same document?

Resources