Closed chearon closed 1 year ago
By the way, I also profiled harfbuzzjs against canvas's measureText
in Chrome and Firefox yesterday. I was surprised at how well it performed. Unsurprisingly measureText
is faster, but doing word wrapping that way necessarily involves measuring words individually. When you compare that to shaping whole paragraphs in harfbuzzjs, it is often only slower by a few milliseconds before the browser's shape cache kicks in (I measured ~10 paragraphs).
I've also experimented with shaping word-by-word like Firefox does, but that's too many shape()
calls. Calling into WASM incurs a cost. I think if whole paragraphs were shaped until enough data is collected, then switch to shaping by word, harfbuzzjs becomes a serious choice to layout text in a canvas.
Thanks, the use of TextEncoder here always felt like an overkill.
I'm seeing
createCString
as a dominator in a project I'm working on. Nodejs text encoding/decoding is slow: nodejs/node#39879. Browsers don't show much difference with this change.Here's how I profiled it in harfbuzzjs: