feat: generate avatars for display name with chinese characters
- Resolves: https://help.nextcloud.com/t/the-problem-of-automatically-generating-an-avatar-for-a-chinese-user-name/177750
Summary
We are using NotoSans-Regular for generating avatars.
If the character is not supported by NotoSans-Regular the users end up with an avatar like below:
The pull request here adds another font and uses a poor regex to flip out the font when chinese characters are detected. The font actually should cover even more characters.
@danxuliu did a deep dive into the topic a while ago and wrote down everything you need to know: https://github.com/nextcloud/server/pull/25529
TODO
- [ ] Testing Testing
- [ ] Do we want to ship another font
- [ ] Extend regex to match supported characters for NotoSC font
Checklist
- Code is properly formatted
- Sign-off message is added to all commits
- [ ] Tests (unit, integration, api and/or acceptance) are included
- [ ] Screenshots before/after for front-end changes
- [ ] Documentation (manuals or wiki) has been updated or is not required
- [ ] Backports requested where applicable (ex: critical bugfixes)
@kesselb can you tell a bit about the state of the PR? 😊
@AndyScherzinger Added some context to the pull request.
I never got feedback in the forums if the suggested patch works, and therefore did not continue.
This font topic is a rather complicated one, and I have no idea if that's a sane approach.
Tested and worked fine.
As traditional Chinese users, we've been overriding fonts with Noto Sans TC to display Chinese characters properly. Here's the catch: Noto Sans SC uses some Simplified Chinese glyphs (probably GB18030 standard with "List of Commonly Used Standard Chinese Characters"), but the same character actually has different strokes in:
- Traditional Chinese (Taiwan)
- Traditional Chinese (Hong Kong/Macau)
- Japanese
- Korean
e.g.: for \u89d2
In TC:
In SC:
I recommend we just merge this commit. Since:
- This PR already fixes avatar display for most cases in Chinese characters.
- The glyph differences only affect a small number of characters.
Maybe we could handle the glyph differences with languange/location setting for CJK fonts matching later.
Trivia: Lots of websites/devices secretly use LCSCC glyphs for all Chinese text. The stroke differences are super subtle (mostly like 1-2 pen strokes!), which is why most traditional Chinese users never even notice! 😉
Hi @Phreeman33,
Many thanks for your feedback—it's much appreciated! 🙏
Thanks for taking the initiative and sending a reworked version of the PR to improve the avatar situation for users with Chinese characters.
Overrules by https://github.com/nextcloud/server/pull/51855