Skip to content
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

font.layout crashing on esoteric unicode character #312

Open
alecjacobson opened this issue Jun 10, 2023 · 0 comments
Open

font.layout crashing on esoteric unicode character #312

alecjacobson opened this issue Jun 10, 2023 · 0 comments

Comments

@alecjacobson
Copy link

I was stress testing a pipeline involving font.layout by running it on all characters which fontkit finds are in the set of a given font. For this Monaco.ttf.zip
font.characterSet includes the unicode 63615. When I convert to a string and call font.layout, it crashes.

Here's a minimal example:

const fontkit = require('fontkit');
const font = fontkit.openSync("Monaco.ttf");
const all_codes = Array.from(font.characterSet);
const bad_code = all_codes.slice(-5)[0];
const bad_string = String.fromCodePoint(bad_code);
font.layout(bad_string);
node_modules/restructure/dist/main.cjs:91
        const ret = this.view[key](this.pos, false);
                                  ^

RangeError: Offset is outside the bounds of the DataView
    at DataView.getInt16 (<anonymous>)
    at $8ae20583b93e4933$export$c18b354bac7948e9.<computed> [as readInt16BE] (...node_modules/restructure/dist/main.cjs:91:35)
    at $af65abf7bf65ac42$export$fffa67e515d04022.decode (...node_modules/restructure/dist/main.cjs:268:40)
    at $aa8b66bae6abe658$export$eabc71f011df675a._parseFields (...node_modules/restructure/dist/main.cjs:732:29)
    at $aa8b66bae6abe658$export$eabc71f011df675a.decode (...node_modules/restructure/dist/main.cjs:703:14)
    at $f680320fa07ef53d$export$2e2bcd8739ae039._getCBox (...node_modules/fontkit/dist/main.cjs:10906:54)
    at $f680320fa07ef53d$export$2e2bcd8739ae039._getMetrics (...node_modules/fontkit/dist/main.cjs:11074:25)
    at get advanceWidth (...node_modules/fontkit/dist/main.cjs:10764:21)
    at descriptor.get (...node_modules/fontkit/dist/main.cjs:92:29)
    at ...node_modules/fontkit/dist/main.cjs:10141:115

Node.js v18.13.0
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

No branches or pull requests

1 participant