Comment #3 on issue 12705 by
gm...@chromium.org: canvaskit-wasm doesn not support measureText
https://bugs.chromium.org/p/skia/issues/detail?id=12705#c3First off I wanted to thank you for this library. My initial goal was to use it as a replacement for node-canvas (
https://www.npmjs.com/package/canvas) (canvas in node). The problem with node canvas it's it's a native plugin which ends up causing problems for me (for example it doesn't work out-of-the-box on an M1 Mac)
I'd love to help make it drop in replacement for node-canvas if possible. On top of measureText, I noticed textAlign and textBaseline are not yet supported either. I thought about trying to implement them myself but I'm really not familiar with Skia.
Another issue I'm running into is the way fonts *seem* to managed. In the browser I use CSS to load a font. CSS lets me associate a name with the font. Example:
@font-face {
font-family: "lesson-font";
src: url("fonts/KlokanTechNotoSansCJK-Bold.otf");
}
So now I can reference that font as "lesson-font". It didn't appear that similar functionality (this indirection) was part of the current canvaskit-wasm implementation. That's problematic because I don't know the name of the font. "foo.ttf" might internally have the name "bar-font" and short of parsing the font file myself I have no way to know the name of a user supplied font. It's possible I just didn't get how it works.
On more thing, the Image implementation via canvas.decoderImage returns an Image that has the functions width and height, instead of getters. Meaning someImage.width() instead of someImage.width. That's another place where you have existing code that uses img.width and img.height but it breaks cause of the difference.
That's one place I could easily help out (I guess I'll punch up a CL)
In any case, if there's any way to help out more please reach out. Like I said, I don't know Skia so I suspect you'd spend more time answering my questions than it would take to write the solution I'm totally up for helping out if I can.