server icon indicating copy to clipboard operation
server copied to clipboard

feat: generate avatars for display name with chinese characters

Open kesselb opened this issue 2 years ago • 2 comments

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

image

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

kesselb avatar Dec 30 '23 18:12 kesselb

@kesselb can you tell a bit about the state of the PR? 😊

AndyScherzinger avatar May 23 '24 05:05 AndyScherzinger

@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.

kesselb avatar May 23 '24 14:05 kesselb

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:

  1. Traditional Chinese (Taiwan)
  2. Traditional Chinese (Hong Kong/Macau)
  3. Japanese
  4. Korean

e.g.: for \u89d2 In TC: 角-TC In SC: 角-SC

I recommend we just merge this commit. Since:

  1. This PR already fixes avatar display for most cases in Chinese characters.
  2. 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! 😉

Phreeman33 avatar Mar 16 '25 06:03 Phreeman33

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.

kesselb avatar Apr 03 '25 12:04 kesselb

Overrules by https://github.com/nextcloud/server/pull/51855

skjnldsv avatar Apr 04 '25 10:04 skjnldsv