API: Access to installed fonts / opentype.js Font Object
81 5
andreasbernhofer 6 days ago
Hey, is there an easy way for an extension to get access to all fonts (the indexDB only has the ones installed by the user, not the default ones) either as `ArrayBuffer` or better as an `Font` instance of the opentype.js you are using to parse the fonts internally?
eric 6 days ago
A short answer is no. Only user uploaded fonts are available now.
andreasbernhofer 5 days ago
@eric Thank you. In case you plan to extend the official api in any way, I suggest that you also expose libraries used, like opentype.js. In my case I can include opentype.js together with the extension, so it's not a problem - but wasteful. May I ask a related question? What would be the best way to use additional libraries within an extension? Since all scripts of an extension get executed within their own anonymous function context, I have to attach the library to a global element, so I can use it from any other script of the extension. I think that maybe `easyeda.extension.instances.myextensionid.opentype = opentype` might be a good way to expose it, because it is my unique scope and it will also get deleted when my extension is unloaded, correct? 🤔
eric 4 days ago
Since `opentype` is in global namespace, you can use it directly.
andreasbernhofer 4 days ago
@eric ooops, I missed that 🙈 I'm also using paper.js in the extension and I was looking for the best way to load it, so I just assumed I had to do the same for opentype.js. I'm glat that I don't have to. But since I also have to load paper.js (which exposes `paper`) the same question applys. I don't want to load `paper` globally because, in theory, EasyEDA or another extension could also do that and may reuire a different version or etc. I'd like to stay in my own namespace if possible. I think that's what extions should do...
eric 4 days ago
I understand your needs. A module system is required but easyeda has not provided. EasyEDA should improve it so that you can import scripts just like `require.js` or es module.
Login or Register to add a comment
你现在访问的是EasyEDA海外版,使用建立访问速度更快的国内版 https://lceda.cn(需要重新注册)
如果需要转移工程请在个人中心 - 工程 - 工程高级设置 - 下载工程,下载后在https://lceda.cn/editor 打开保存即可。
有问题联系QQ 3001956291 不再提醒
svg-battery svg-battery-wifi svg-books svg-more svg-paste svg-pencil svg-plant svg-ruler svg-share svg-user svg-logo-cn svg-double-arrow
We use cookies to offer you a better experience. Detailed information on the use of cookies on this website is provided in our Privacy Policy. By using this site, you consent to the use of our cookies.