This repository was archived by the owner on Jun 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 359
This repository was archived by the owner on Jun 25, 2020. It is now read-only.
How to add a Google Font? #240
Copy link
Copy link
Open
Description
Hi, I am trying to convert a recharts chart svg to a png and I am using a google font for the labels:
<svg id="donut-1" cx="50%" cy="50%" class="recharts-surface" width="450" height="550" viewBox="0 0 450 550" version="1.1">
<defs>
<clipPath id="donut-2-clip">
<rect x="5" y="5" height="523" width="440"></rect>
</clipPath>
</defs>
<g class="recharts-layer recharts-pie">
<g class="recharts-layer">
<g class="recharts-layer recharts-pie-sector">
<path name="Batterieentladung" fill="#196900" stroke="#fff" cx="225" cy="266.5" color="#196900" class="recharts-sector" d="M 365,266.5
A 140,140,0,
0,0,
220.77833953308004,126.56366596590416
L 225,266.5 Z"></path>
</g>
<g class="recharts-layer recharts-pie-sector">
<path name="Direktverbrauch" fill="#ffc003" stroke="#fff" cx="225" cy="266.5" color="#ffc003" class="recharts-sector" d="M 220.77833953308004,126.56366596590416
A 140,140,0,
0,0,
88.29532939191193,296.6965732150875
L 225,266.5 Z"></path>
</g>
<g class="recharts-layer recharts-pie-sector">
<path name="Netzbezug" fill="#595959" stroke="#fff" cx="225" cy="266.5" color="#595959" class="recharts-sector" d="M 88.29532939191193,296.6965732150875
A 140,140,0,
0,0,
365,266.50000000000006
L 225,266.5 Z"></path>
</g>
</g>
<g class="recharts-layer recharts-pie-labels">
<g class="recharts-layer">
<text x="273.74547098786616" y="216.26177692064437" fill="white" text-anchor="middle" dominant-baseline="central" font-size="14" style="font-family: 'Open Sans';">1274 kWh/a</text>
</g>
<g class="recharts-layer">
<text x="169.77011852757943" y="223.4923240276532" fill="white" text-anchor="middle" dominant-baseline="central" font-size="14" style="font-family: 'Open Sans';">1399 kWh/a</text>
</g>
<g class="recharts-layer">
<text x="232.59396236219658" y="336.0868646774773" fill="white" text-anchor="middle" dominant-baseline="central" font-size="14" style="font-family: 'Open Sans';">2327 kWh/a</text></g></g></g></svg>When I am saving the svg to an png, the font is not included, means I have a Times New Roman kind of font included. I already tried the fonts option like this:
const donutOneUri = await svgConverter.svgAsPngUri(
document.getElementById("donut-1"),
{
fonts: [
{
text: "Open+Sans",
url:
"https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800",
format: "woff"
}
]
}
);That was not working.
Thank you for your help!
Metadata
Metadata
Assignees
Labels
No labels