Skip to content

Commit

Permalink
Point to restructure fork and remove use of "new Function"
Browse files Browse the repository at this point in the history
  • Loading branch information
Hopding committed Dec 19, 2018
1 parent b0241e7 commit e3dcc8a
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 91 deletions.
18 changes: 15 additions & 3 deletions Makefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,25 @@ require('shelljs/make');
config.fatal = true;
config.verbose = true;

target.deps = () => {
cd('node_modules/unicode-properties');
exec('yarn');
exec('yarn make');
exec('rm -rf node_modules');
cd('../restructure');
exec('yarn');
exec('yarn prepublish');
exec('rm -rf node_modules');
cd('../..');
}

target.all = () => {
target.clean();
target.generateTrieJson();
target.rollupESM();
target.rollupESMMin();
target.rollupUMD();
target.rollupUMDMin();
// target.rollupESMMin();
// target.rollupUMD();
// target.rollupUMDMin();
};

target.generateTrieJson = () => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"dfa": "^1.0.0",
"iconv-lite": "^0.4.13",
"pako": "^1.0.6",
"restructure": "^0.5.3",
"restructure": "git+https://github.com/Hopding/restructure.git#6f9fd535c3914685a55002ef9b48e08a684b9bec",
"tiny-inflate": "^1.0.2",
"unicode-properties": "git+https://github.com/Hopding/unicode-properties.git#51a63d54730b78507206f07d19bd04186e5cffe7",
"unicode-trie": "^0.3.0"
Expand Down
1 change: 1 addition & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default {
output: {
name: 'fontkit',
format: MODULE_TYPE,
strict: false,
},
external: MODULE_TYPE === 'esm'
? ['pako'] // pdf-lib will provide pako for us
Expand Down
57 changes: 0 additions & 57 deletions src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,60 +26,3 @@ const fontkit = {
};

export default fontkit;


// import r from 'restructure';
// const fs = require('fs');
//
// var fontkit = {};
// export default fontkit;
//
// fontkit.logErrors = false;
//
// let formats = [];
// fontkit.registerFormat = function(format) {
// formats.push(format);
// };
//
// fontkit.openSync = function(filename, postscriptName) {
// let buffer = fs.readFileSync(filename);
// return fontkit.create(buffer, postscriptName);
// };
//
// fontkit.open = function(filename, postscriptName, callback) {
// if (typeof postscriptName === 'function') {
// callback = postscriptName;
// postscriptName = null;
// }
//
// fs.readFile(filename, function(err, buffer) {
// if (err) { return callback(err); }
//
// try {
// var font = fontkit.create(buffer, postscriptName);
// } catch (e) {
// return callback(e);
// }
//
// return callback(null, font);
// });
//
// return;
// };
//
// fontkit.create = function(buffer, postscriptName) {
// for (let i = 0; i < formats.length; i++) {
// let format = formats[i];
// if (format.probe(buffer)) {
// let font = new format(new r.DecodeStream(buffer));
// if (postscriptName) {
// return font.getFont(postscriptName);
// }
//
// return font;
// }
// }
//
// throw new Error('Unknown font format');
// };
//
3 changes: 1 addition & 2 deletions src/glyph/Path.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ export default class Path {
* @return {string}
*/
toFunction() {
let cmds = this.commands.map(c => ` ctx.${c.command}(${c.args.join(', ')});`);
return new Function('ctx', cmds.join('\n'));
return (ctx) => this.commands.forEach((c) => ctx[c.command].apply(ctx, c.args));
}

/**
Expand Down
34 changes: 6 additions & 28 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1037,9 +1037,9 @@ brorand@^1.0.1:
resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f"
integrity sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8=

"brotli@git+https://github.com/Hopding/brotli.js.git#0350970de946950ce47c1948913827931d88fc11":
"brotli@git+https://github.com/Hopding/brotli.js.git#2a623817f6bd8d1f7f528f69ac8ce8067b3383fb":
version "1.3.2"
resolved "git+https://github.com/Hopding/brotli.js.git#0350970de946950ce47c1948913827931d88fc11"
resolved "git+https://github.com/Hopding/brotli.js.git#2a623817f6bd8d1f7f528f69ac8ce8067b3383fb"
dependencies:
base64-js "^1.1.2"

Expand Down Expand Up @@ -3825,9 +3825,9 @@ resolve@^1.1.6, resolve@^1.3.2, resolve@^1.8.1:
dependencies:
path-parse "^1.0.6"

restructure@^0.5.3:
"restructure@git+https://github.com/Hopding/restructure.git#6f9fd535c3914685a55002ef9b48e08a684b9bec":
version "0.5.4"
resolved "https://registry.yarnpkg.com/restructure/-/restructure-0.5.4.tgz#f54e7dd563590fb34fd6bf55876109aeccb28de8"
resolved "git+https://github.com/Hopding/restructure.git#6f9fd535c3914685a55002ef9b48e08a684b9bec"
dependencies:
browserify-optional "^1.0.0"

Expand Down Expand Up @@ -3885,10 +3885,6 @@ rollup-plugin-json@^3.1.0:
dependencies:
rollup-pluginutils "^2.3.1"

rollup-plugin-local-resolve@^1.0.7:
version "1.0.7"
resolved "https://registry.yarnpkg.com/rollup-plugin-local-resolve/-/rollup-plugin-local-resolve-1.0.7.tgz#c486701716c15add2127565c2eaa101123320887"

rollup-plugin-node-builtins@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/rollup-plugin-node-builtins/-/rollup-plugin-node-builtins-2.1.2.tgz#24a1fed4a43257b6b64371d8abc6ce1ab14597e9"
Expand Down Expand Up @@ -3930,16 +3926,6 @@ rollup-plugin-terser@^3.0.0:
serialize-javascript "^1.5.0"
terser "^3.8.2"

rollup-plugin-uglify@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/rollup-plugin-uglify/-/rollup-plugin-uglify-6.0.0.tgz#15aa8919e5cdc63b7cfc9319c781788b40084ce4"
integrity sha512-XtzZd159QuOaXNvcxyBcbUCSoBsv5YYWK+7ZwUyujSmISst8avRfjWlp7cGu8T2O52OJnpEBvl+D4WLV1k1iQQ==
dependencies:
"@babel/code-frame" "^7.0.0"
jest-worker "^23.2.0"
serialize-javascript "^1.5.0"
uglify-js "^3.4.9"

rollup-plugin-visualizer@^0.9.2:
version "0.9.2"
resolved "https://registry.yarnpkg.com/rollup-plugin-visualizer/-/rollup-plugin-visualizer-0.9.2.tgz#bbc8e8e67d5aa3e6c188c5ca0fcfa57234fb9f92"
Expand Down Expand Up @@ -4428,14 +4414,6 @@ uglify-js@^2.6:
optionalDependencies:
uglify-to-browserify "~1.0.0"

uglify-js@^3.4.9:
version "3.4.9"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.4.9.tgz#af02f180c1207d76432e473ed24a28f4a782bae3"
integrity sha512-8CJsbKOtEbnJsTyv6LE6m6ZKniqMiFWmm9sRbopbkGs3gMPPfd3Fh8iIA4Ykv5MgaTbqHr4BaoGLJLZNhsrW1Q==
dependencies:
commander "~2.17.1"
source-map "~0.6.1"

uglify-to-browserify@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7"
Expand All @@ -4458,9 +4436,9 @@ unicode-match-property-value-ecmascript@^1.0.2:
resolved "https://registry.yarnpkg.com/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-1.0.2.tgz#9f1dc76926d6ccf452310564fd834ace059663d4"
integrity sha512-Rx7yODZC1L/T8XKo/2kNzVAQaRE88AaMvI1EF/Xnj3GW2wzN6fop9DDWuFAKUVFH7vozkz26DzP0qyWLKLIVPQ==

"unicode-properties@git+https://github.com/Hopding/unicode-properties.git#d97bf46ebdcef78f838f0803ec3643e608410add":
"unicode-properties@git+https://github.com/Hopding/unicode-properties.git#51a63d54730b78507206f07d19bd04186e5cffe7":
version "1.1.0"
resolved "git+https://github.com/Hopding/unicode-properties.git#d97bf46ebdcef78f838f0803ec3643e608410add"
resolved "git+https://github.com/Hopding/unicode-properties.git#51a63d54730b78507206f07d19bd04186e5cffe7"
dependencies:
base64-arraybuffer "^0.1.5"
pako "^1.0.6"
Expand Down

0 comments on commit e3dcc8a

Please sign in to comment.