← Back to context

Comment by hyperknot

1 year ago

Nice project! Related question, how would you recommend detecting which font is being used for names like ui-sans-serif, system-ui on a given device/browser?

That's a difficult one, you would need information about the device and operating system to infer the font.

But I imagine, if you realllly needed that info. You could go the hard route and render the font on a canvas, vectorise and perform some sort of nearest neighbour search.

  • Thanks! My idea was to just render a Lorem Ipsum paragraph and compare the calculated width-height across a know list of default fonts. Of course it wouldn't work with fixed width fonts, for that I'd need a canvas bitmap comparison.