opentypejs / opentype.js

Read and write OpenType fonts using JavaScript.
https://opentype.js.org/
MIT License
4.45k stars 475 forks source link

Support searching or filtering by glyph name #663

Open ahaoboy opened 9 months ago

ahaoboy commented 9 months ago

You can quickly find the desired glyph within a font by searching or filtering through its glyph names.

[...font.glyphs].filter(i=>i.name.includes('close')).map(i=>i.index)
Connum commented 9 months ago

So what is the issue or question? Do you want a wrapper function for comfortability?

ahaoboy commented 9 months ago

So what is the issue or question? Do you want a wrapper function for comfortability?

Something like this image

Connum commented 9 months ago

Oh, so you're talking about the glyph inspector demo page. Sure, that shouldn't be too hard to implement

ahaoboy commented 9 months ago

This is a demo build by https://github.com/ahaoboy/opentype.js/tree/search, I'm not sure if there are any issues with this implementation, but this is the simplest way I can think of, and it seems to work fine.

https://opentype-js.vercel.app/docs/glyph-inspector.html image