texticon

Install via npm:

npm install texticon

texticon is a library I created for Frost to display placeholder favicons for shortcuts and search engines.

I made it because I wanted the letters in the icons to be perfectly visually centered. Fonts are not normally designed to do that.

The solution was to use TextMetrics to get a bounding box of the text on a canvas, and then translate the text so that it’s centered.

You can use full CSS font customization, and also supply a random seed, so each name always maps to the same color.