Skip to content

fix(#6): use manual fs shim#7

Open
petermikitsh wants to merge 1 commit intomasterfrom
cross-platform-fs-shim
Open

fix(#6): use manual fs shim#7
petermikitsh wants to merge 1 commit intomasterfrom
cross-platform-fs-shim

Conversation

@petermikitsh
Copy link
Copy Markdown
Owner

@andreinitescu

Instead of relying on browserify and transform-loader, I've added a manual fs shim.

This is technically less correct since we are losing the file contents. For example, here's a diff of node_modules/fontkit/index.js:6878 (after running through webpack):

- var trie = new UnicodeTrie(Buffer("AAH.......8KmzQDjmuTAQ==","base64"));
+ var trie = new UnicodeTrie(__webpack_require__(/*! fs */ "./docs/fsShim.js").readFileSync(__dirname + '/data.trie'));

Before:

Screen Shot 2020-12-28 at 12 51 28 PM

After:

Screen Shot 2020-12-28 at 12 50 29 PM

So the runtime behavior is changing, but it practically doesn't impact any of the ligature APIs. This change only applies to the docs site, and not the ligatures npm library.

@andreinitescu
Copy link
Copy Markdown

andreinitescu commented Dec 29, 2020

It works 👌
Do you know if this fs mock shim has any impact on rendering the glyphs with fontkit ?
I'm talking about using this API
glyph.render(ctx, size) https://github.com/foliojs/fontkit#glyphrenderctx-size
My tool also needs to draw the ligatures/glyphs.

Thanks again for your help

@petermikitsh
Copy link
Copy Markdown
Owner Author

I don't think this will impact rendering with fontkit, though this project doesn't use that fontkit feature.

You might be able to explore using the browser to natively render the glyphs. https://developer.mozilla.org/en-US/docs/Web/CSS/font-feature-settings

Example usage here:

font-feature-settings: "liga", "dlig", "calt", "ordn", "rlig";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants