MHN
Add a comment on Hacker News →
1 of 65 comments
  1. Nice work! The other day I was doing a SVG renderer for Shiki[0] (a code syntax highlighter), but found no easy way to measure font width/height (SVG needs absolute positioning) in Node.js. The only library that does that records fonts' metadata in the package source[1].

    I ended up using puppeteer[2]. Would love to switch to `skia-canvas`, however `ctx.measureFont` doesn't seem to work correctly yet. Measuring cap `M` produces positive `actualBoundingBoxDescent`, although `M` should sit comfortably on top of baseline.

    [0]: https://shiki.matsu.io/

    [1]: https://github.com/adambisek/string-pixel-width

    [2]: https://github.com/shikijs/shiki/blob/master/packages/render...