OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

opentype.js: Path.fromSvg() method is not a function

  • Thread starter Thread starter palmavilluan
  • Start date Start date
P

palmavilluan

Guest
I have created svg elements using the p5.js-svg library. Now I want to convert the svgs into paths so I can create glyphs with it and push the glyphs into a new font file. In the README file I found the Path.fromSVG() method which I think would do exactly what I'm trying to do.

I'm using the following script tag to load opentype.js:

Code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/opentype.js/1.3.4/opentype.min.js" integrity="sha512-Ro+jjHMdfC0ZYcLjWhxVxZtGWFbIGsfvZbVCU3EYCr/aP4dIyzHkSeuhF3wQHb43wz2UCs0M7o16+lAC3/muYA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

Current Behavior​


However, when I'm running my code I get the error that

Code:
Path.fromSVG is not a function

I have logged the Path object to the console and look at the provided prototype functions. fromSVG is not in this list.

Possible Solution​


In the opentype.js repository under /src I have found the path.js file in which I have found a fromSVG() function. So probably it doesn't work because I have linked to cdn instead of downloading opentype.js and so the path.js file isn't available in the browser.

Another possible reason could be that the fromSVG() function is still work in progress and not yet published in the opetnype.min.js 1.3.4.

Im Happy for every Help/Suggestions;)

Expected Behavior​


I was expecting that the function gives me a Path which I can use to create a new Glyph. And then push the Glyphs in to a new Font File.

<p>I have created svg elements using the p5.js-svg library. Now I want to convert the svgs into paths so I can create glyphs with it and push the glyphs into a new font file. In the README file I found the <code>Path.fromSVG()</code> method which I think would do exactly what I'm trying to do.</p>
<p>I'm using the following script tag to load opentype.js:</p>
<pre class="lang-js prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/opentype.js/1.3.4/opentype.min.js" integrity="sha512-Ro+jjHMdfC0ZYcLjWhxVxZtGWFbIGsfvZbVCU3EYCr/aP4dIyzHkSeuhF3wQHb43wz2UCs0M7o16+lAC3/muYA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
</code></pre>
<h2>Current Behavior</h2>
<p>However, when I'm running my code I get the error that</p>
<pre><code>Path.fromSVG is not a function
</code></pre>
<p>I have logged the Path object to the console and look at the provided prototype functions. <code>fromSVG</code> is not in this list.</p>
<h2>Possible Solution</h2>
<p>In the opentype.js repository under /src I have found the path.js file in which I have found a <code>fromSVG()</code> function. So probably it doesn't work because I have linked to cdn instead of downloading opentype.js and so the path.js file isn't available in the browser.</p>
<p>Another possible reason could be that the <code>fromSVG()</code> function is still work in progress and not yet published in the opetnype.min.js 1.3.4.</p>
<p>Im Happy for every Help/Suggestions;)</p>
<h2>Expected Behavior</h2>
<p>I was expecting that the function gives me a Path which I can use to create a new Glyph. And then push the Glyphs in to a new Font File.</p>
 

Latest posts

B
Replies
0
Views
1
Blundering Ecologist
B
Top