feat: get best names
I often need the family name, subfamily name or both together as the full name. And the preferred one is often not name id 4, but 16 + 17.
This PR makes it much more easy to get the 'nice' names. I have done something similar for fonttools: https://github.com/fonttools/fonttools/blob/d2ac9cbf488acc867866297d76a9671fe992947f/Lib/fontTools/ttLib/tables/_n_a_m_e.py#L154
Note: I added write-fonts to Cargo.toml because this way I can build a demo font for the unittests.
I hope you find this handy as well. Happy to get feedback :)
I appreciate any feedback.
Just found (by accident), that other people do the same and have the same need for 'best name' – please see: https://github.com/fonttools/fontspector/blob/8f8518b6f8e3cb61cd547c95c8c9f6efcb16b544/fontspector-checkapi/src/font.rs#L468C12-L468C27
I believe this would resolve https://github.com/googlefonts/fontations/issues/870
Thanks for the patch! While something like this is desirable to assist users in accessing the common names (and to handle proper searching order, see #870), I think this approach is too opinionated both by assuming the user wants the "english or first" name and by converting to String which makes language selection impossible and forces a perhaps unnecessary allocation.
In addition, these methods should probably exist on some intermediate object rather than being added directly to MetadataProvider. Ultimately, we probably want to move this functionality to read-fonts as well and I'm not quite sure what that would look like yet.