question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Svg font does not support <use> in Safari

See original GitHub issue

nanoemoji --color_format=picosvg

The svg file:

<svg width="200" height="200" viewBox="0 0 200 200" version="1.1" xmlns="http://www.w3.org/2000/svg">
    <circle fill="#F49924" cx="100" cy="100" r="100" />
    <ellipse fill="#7E4418" cx="59.545" cy="71.818" rx="15" ry="21.818" />
    <ellipse fill="#7E4418" cx="140.455" cy="71.818" rx="15" ry="21.818" />
</svg>

TTX file:

 <SVG>
    <svgDoc endGlyphID="2" startGlyphID="2">
      <![CDATA[<svg xmlns="http://www.w3.org/2000/svg" version="1.1"><defs/><g id="glyph2" transform="matrix(6 0 0 6 0 -950)"><path d="M200,100 A100 100 0 1 1 0,100 A100 100 0 1 1 200,100 Z" fill="#F49924"/><path d="M74.545,71.818 A15 21.818 0 1 1 44.545,71.818 A15 21.818 0 1 1 74.545,71.818 Z" fill="#7E4418" id="glyph2::1"/><use href="#glyph2::1" x="80.91"/></g></svg>]]>
    </svgDoc>
  </SVG>

I think Safari does not support <use href="#glyph2::1" x="80.91"/>, so the ellipse on the right is missing.

image

Expect:

image

Keynote

image

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
litherumcommented, Apr 12, 2021

I haven’t debugged this, so I don’t know if there are multiple problems with this content, but I can say right off the bat that you need to add the xlink namespace, and qualify the href attribute, as per the SVG 1.1 spec. Try this:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
    <defs/>
    <g id="glyph2" transform="matrix(6 0 0 6 37.5 -950)">
        <path d="M200,100 A100 100 0 1 1 0,100 A100 100 0 1 1 200,100 Z" fill="#F49924"/>
        <path d="M74.545,71.818 A15 21.818 0 1 1 44.545,71.818 A15 21.818 0 1 1 74.545,71.818 Z" fill="#7E4418" id="glyph2::1"/>
        <use xlink:href="#glyph2::1" x="80.91"/>
    </g>
</svg>

You can see an example of this working correctly in the SVG 1.1 spec: https://www.w3.org/TR/SVG11/images/struct/Use01.svg

So I have to conclude that <use> elements are currently not supported in Safari when they are present in an svg document embedded in OT-SVG font.

We do support <use> elements in OT-SVG.

1reaction
yisiblcommented, Apr 9, 2021

Well, that’s ok, but the position is wrong. I think we still need to use picosvg to adjust the position.(Safari) image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Displaying custom fonts in SVG for iOS Chrome and Safari
- Then, go to menu option Type and select Create Outlines. This way we do not have to rely on calling fonts because...
Read more >
Browser Compatibility of SVG fonts on Safari 11 - LambdaTest
SVG fonts is Fully Supported on Safari 11, which means that any user who'd be accessing your page through Safari 11 can see...
Read more >
Using Fonts in SVG - Vecta.io
Cons: SVG fonts are only supported in certain browsers such as Safari and Android. It is not supported in Chrome and Firefox. This...
Read more >
SVG fonts | Can I use... Support tables for HTML5, CSS3, etc
Method of using fonts defined as SVG shapes. Removed from SVG 2.0 and considered as a deprecated feature with support being removed from...
Read more >
Svg font does not support gradientTransform in Safari #268
From the Twitter conversation, as far as I understand, there's a problem in Safari's OT-SVG implementation whereby it assumes that a matrix is ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found