fontations icon indicating copy to clipboard operation
fontations copied to clipboard

feat: get best names

Open ollimeier opened this issue 5 months ago • 4 comments

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 :)

ollimeier avatar Jul 24 '25 11:07 ollimeier

I appreciate any feedback.

ollimeier avatar Jul 28 '25 07:07 ollimeier

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

ollimeier avatar Aug 18 '25 08:08 ollimeier

I believe this would resolve https://github.com/googlefonts/fontations/issues/870

valadaptive avatar Aug 24 '25 03:08 valadaptive

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.

dfrg avatar Aug 28 '25 12:08 dfrg