Support filter by language
Can support filter by language? Include subsets in fontInfo.json, then filter subsets by component props.
Great issue for discussion!
I don't think it's documented anywhere, but I already considered internationalisation and decided not to tackle it.
Fonts supporting latin plus another writing system are currently supported if the client supports unicode-range: https://developers.google.com/fonts/docs/getting_started#specifying_script_subsets
So out of the box, you can already figure out which fonts are OK for your target language and use the existing options to display only those. But, the previewed font names are rendered in English.
This is the biggest challenge: that the font previews would need to be rendered in whatever target language.
Multi-language font previews cannot be practically bundled together, the English language npm package is already currently an astronomical 33 MB unpacked. (Which is why I offer the "lite" edition.)
So there would have to be a separate npm package for a fontpicker for each target language.
There would also need to be a translation file, mapping the English name (used by the code) to the target language in order to generate the previews.
Maybe something like:
/packages/fontpicker/translations/ja.json
{
"Noto Sans JP": "Noto Sans JP",
"Sawarabi Gothic": "さわらびゴシック",
...
}
As the example above shows (courtesy of jimakuChan), native speakers don't even necessarily prefer to use their language to describe a certain font family. So each translation would really have to be done by a native speaker, for their own community.
If anyone is seriously interested in a version of react-fontpicker for their target language, feel free to submit a PR with the translation file. After that, I can take a stab at implementing alternative language support, and then publishing a version for that language. (This could take some time, and anyone is welcome to contribute here to speed up the process.)
An easier alternative is to restrict your users to only fonts that support both Latin and your target writing system, if your users are OK with font names in English.
If anyone is interested in implementing that feature, I'm open to contributions from the community.
https://github.com/ae9is/react-fontpicker/pull/75
The easier alternative has now been implemented in #81, but leaving this issue open for a bit just in case anyone is seriously interested in adding true alternative language support!