-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not working in browser #19
Comments
brotli is looking for process.argv[1], which won't be defined in the browser. As a work around, if you're using browserify:
|
I can't make it work in browser either. Compiled it with browserify, fixed the errors in the compiled file. But after the compiled js file is loaded in browser (without errors) I still can't access neither fontkit or require function thus the example from Readme.md doesn't work. Could someone please point me out how to correctly compile and use fontkit in browsers? |
I got it to work . I created a file compile.js with the below content. |
The result fonkit.js is 1.1 MB or 840KB minified. Does anyone know how to reduce the size? |
The huge part is WOFF2 support (Emscripten compile). You can make a custom build using only the font formats you need to support. var fontkit = require('fontkit/base');
fontkit.registerFormat(require('fontkit/src/TTFFont')); You can see all the formats supported in the default configuration. |
Remember that the example in the readme is an offline/server-side node example. If you're bundling, make sure to use the correct syntax: bundlers don't magically create "for the web" bundles, you need to tell them what to do. In the case of browserify, you need to use the --standalone flag, and you probably need to tell it to shim the global nodejs |
Output generated with
browserify index.js -o out.js
when ran in browser throws the following error:
Uncaught TypeError: Cannot read property 'replace' of undefined
Using the github source.
The text was updated successfully, but these errors were encountered: