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

Switch to Harfbuzz #83

Open
shuding opened this issue Jul 27, 2022 · 5 comments
Open

Switch to Harfbuzz #83

shuding opened this issue Jul 27, 2022 · 5 comments
Assignees
Labels

Comments

@shuding
Copy link
Member

shuding commented Jul 27, 2022

Satori currently relies on OpenType.js to parse font tables and generate the glyphs. I’m considering switching to Harfbuzz in the future because it supports a couple of more complex scripts and OpenType features. It can also improve the performance a bit as it’s a WASM port.

Pretty low priority at the moment as we need to improve the typography algorithm first.

@shuding shuding self-assigned this Jul 27, 2022
@shuding shuding added the backlog label Aug 3, 2022
@shuding
Copy link
Member Author

shuding commented Aug 22, 2022

Looks like the correct way to go in the future:

CleanShot 2022-08-22 at 16 31 43@2x

https://twitter.com/KhaledGhetas/status/1548752758282534913

@jlarmstrongiv
Copy link

jlarmstrongiv commented Oct 11, 2022

@shuding how would you workaround the limitations of Harfbuzz, such as line breaking?

@devongovett
Copy link

You could also try fontkit, which is a pure JS implementation supporting complex scripts. It powers pdfkit.

There's also textkit for handling higher level text layout (eg line wrapping, font substitution, etc.). That's used by react-pdf.

I'd highly recommend looking into some of these libraries and how they do text layout, because it is extremely complicated (especially with non-English text). Back when react-pdf was investigating this, I wrote this comment explaining the whole text layout process - maybe it's helpful to you. foliojs/pdfkit#783 (comment)

@shuding
Copy link
Member Author

shuding commented Oct 11, 2022

Thanks again for the pointers @devongovett! I actually looked into fontkit before picking opentype.js (because it's smaller, seems like a wrong choice lol), and actually read a lot of your comments from everywhere (thank you again!), and I understand the complexibility of this. Hence the first phase of this project is to support only basic text layout and font features.

Anyways, this is definitely our top priority!

@LuciNyan
Copy link
Contributor

@shuding how would you workaround the limitations of Harfbuzz, such as line breaking?

Thank you for sharing this!

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

No branches or pull requests

4 participants