Comments (5)
I believe I ran into this when attempting to render a PDF with Futura PT using pdfmake. Is there any known workaround? I guess I could convert to TTF, but I'm unsure if the font license allows that.
/Users/kblomster/Code/redacted/api/node_modules/fontkit/index.js:13405
for (var i = 0; i < subrs.length; i++) {
^
TypeError: Cannot read property 'length' of null
at CFFSubset.subsetSubrs (/Users/kblomster/Code/redacted/api/node_modules/fontkit/index.js:13405:30)
at CFFSubset.createCIDFontdict (/Users/kblomster/Code/redacted/api/node_modules/fontkit/index.js:13498:30)
at CFFSubset.encode (/Users/kblomster/Code/redacted/api/node_modules/fontkit/index.js:13548:12)
at /Users/kblomster/Code/redacted/api/node_modules/fontkit/index.js:13027:13
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
from fontkit.
I tried adding a simple if (!subrs) return res;
in CFFSubset.js after line 35, and that appears to "work" in that it prevents the error above and appears to render my PDF, but I have absolutely no idea if this is actually a viable solution or not. Maybe it helps someone else?
from fontkit.
another option is to change the function signature to have a default argument that causes the for loop to immediately exit:
subsetSubrs(subrs = [], used) {
...
}
This introduces less code, but also avoids an early return and early returns are great for ensuring code is fast (in that vein, an early return if (!subrs) return [];
rather than allocating a res
symbol would be even faster)
from fontkit.
If that solution doesn't introduce problems, I can send a pull request for it. After looking at the code I think it won't break things, since the requested subset does not necessarily need to use any subrs anyway (I think?), but I certainly can't claim to understand the actual mechanics of subsetting a CFF font in any detail.
Getting this fixed would be nice for me.
from fontkit.
The original issue which I opened against the old coffee script source no longer exists, as there is now a check for Subrs in subsetFontdict()
.
However, the corresponding line in createCIDFontdict()
is missing this check and that seems to be the cause of your issue, looking at the stack trace. Presumably that's because you have a CID font, while I had a Type 1-equivalent font.
The advantage of adding the missing null check vs. the proposed fix above is that it won't unnecessarily create an empty Subrs dictionary in the subset font. No Subrs dictionary is needed at all.
from fontkit.
Related Issues (20)
- Issue in migrating from 1.8.0 to 2.0.0 HOT 1
- Filling gaps in one font with glyphs from another to create a hybrid font HOT 3
- Missing Non Unicode characters from fontkit object HOT 1
- Feature Request: expose getKerning(left, right) to users HOT 2
- Missing instructions on how to build fontkit for brwoser HOT 2
- .advanceWidth triggers RangeError: Offset is outside the bounds of the DataView HOT 2
- Bad glyphs code points produce by layout function with Arabic font HOT 1
- TypeError when encoding subset of font with set variation
- Modify and save/write a font HOT 1
- font.layout crashing on esoteric unicode character
- Implementation question: availableFeatures HOT 1
- Support glyph path fill rule (non-zero winding / even-odd crossing / etc)
- Handle avar table version 2
- Exntend font.layout accept Array of Glyphs and return a GlyphRun? HOT 1
- .getImageForSize(100) returns "null" using "Apple Color Emoji.ttc" HOT 2
- when i use fontkit to genetate the subset of ttf file,but can not open the subset file,shows โnot a valid font fileโ HOT 3
- [Performance] WOFF font format for CJK languages is 5x slower in Chrome and Unresponsive in Firefox HOT 1
- seac-like endchar compatibility syntax not handled HOT 1
- Cannot use Fontkit on CodeSandbox.io HOT 3
- How to extract individual TTF from a font collection (TTC) file?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fontkit.