Permalink
Browse files

fix exporting to OTF/SVG closes #10

  • Loading branch information...
1 parent a7675c7 commit f6baaf2c1861ebb3ddbf6d55caa4451a1ce5dae5 @Autre31415 Autre31415 committed Sep 10, 2016
Showing with 31 additions and 9 deletions.
  1. +31 −9 renderer.js
View
@@ -27,16 +27,38 @@ function confirmClose(event) {
}
}
-saveFile = function(fname, buffer) {
- destination = dialog.showOpenDialog({
- properties: ['openDirectory'],
- title: 'Choose where to save project...',
- defaultPath: process.env.HOME
- });
- if (destination !== undefined) {
- fs.writeFile(destination + '/' + fname, buffer);
+saveFile = function(fname, buffer, ftype) {
+ ftype = ftype || 'text/plain;charset=utf-8';
+ var fblob = new Blob([buffer], {'type':ftype, 'endings':'native'});
+
+ console.log(fname);
+ console.log(fname.includes('SVG'));
+
+ if (fname.includes('SVG') || ftype == 'font/opentype') {
+ console.log('SVG or OTF');
+ var link = document.createElement('a');
+ window.URL = window.URL || window.webkitURL;
+ link.href = window.URL.createObjectURL(fblob);
+ //link.onclick = ("alert("+window.URL.createObjectURL(fblob)+");");
+ link.download = fname;
+
+ var event = document.createEvent('MouseEvents');
+ event.initEvent('click', true, false);
+ link.dispatchEvent(event);
+ return;
}
else {
- event.returnValue('Stay Open');
+ console.log('Glyphr Project File');
+ destination = dialog.showOpenDialog({
+ properties: ['openDirectory'],
+ title: 'Choose where to save project...',
+ defaultPath: process.env.HOME
+ });
+ if (destination !== undefined) {
+ fs.writeFile(destination + '/' + fname, buffer);
+ }
+ else {
+ event.returnValue('Stay Open');
+ }
}
};

0 comments on commit f6baaf2

Please sign in to comment.