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

Writing slow (30+ seconds) for certain fonts (CJK, Noto Chinese) #682

Closed
Balearica opened this issue Mar 5, 2024 · 2 comments
Closed

Writing slow (30+ seconds) for certain fonts (CJK, Noto Chinese) #682

Balearica opened this issue Mar 5, 2024 · 2 comments

Comments

@Balearica
Copy link
Contributor

For most fonts, Opentype.js can write a font file using font.download() or font.toArrayBuffer() in a fraction of a second. However, certain fonts that include many characters are subject to extreme runtimes.

This occurs with both Simplified Chinese variants of the Noto family. Using NotoSansSC-Regular.ttf (available here), running font.toArrayBuffer() from the console after loading in the example site took 36 seconds. Similarly, trying to write NotoSerifSC-Regular.otf (available here) running font.toArrayBuffer() took 33 seconds.

Not all CJK fonts are this slow--I tested a couple others from Google Fonts that took 4-5 seconds. However, as I've never experienced anything like this with fonts that only support Latin characters, I'm guessing it's related to the number of glyphs in these fonts.

I will investigate more myself and try and fix in a PR.

Your Environment

  • Version used: 3fce140
    • Latest commit as of the time of this writing
  • Font used: Noto Sans Simplified Chinese, Noto Serif Simplified Chinese
  • Browser Name and version: Chrome
  • Operating System and version (desktop or mobile): Windows 10
@Balearica
Copy link
Contributor Author

This ended up being due to excessive re-allocation of memory by using d = d.concat(...) rather than push. This is fixed in the PR linked above.

@Connum
Copy link
Contributor

Connum commented Apr 15, 2024

Closed via #683

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

No branches or pull requests

2 participants