Skip to content

Fix font priority for languages using Han characters#5930

Merged
Alkarex merged 2 commits intoFreshRSS:edgefrom
kasimircash:fix-font-priority
Dec 10, 2023
Merged

Fix font priority for languages using Han characters#5930
Alkarex merged 2 commits intoFreshRSS:edgefrom
kasimircash:fix-font-priority

Conversation

@kasimircash
Copy link
Copy Markdown
Contributor

Closes #5670

Changes proposed in this pull request:

The presence of the simplified Chinese fonts 'PingFang SC' and 'Microsoft YaHei' in several theme's font-family lists means that if they are installed on a users system they will be favoured over other fonts for displaying text in other languages that use 'Han characters' such as Japanese and traditional Chinese leading to broken text in those languages.

By removing 'PingFang SC' and 'Microsoft YaHei' from the font-family list of these themes we allow the browser to use the HTML lang attribute to display text in a font that is correct for the language if one is present on the users system.

We now simply leverage browser behaviour to provide a much fuller and more robust check for default language fonts.

How to test the feature manually:

  1. Enter Display page of Configuration.
    image

  2. From language menu select '日本語' then click submit button to display Japanese.
    image

  3. From language menu select '简体中文' then click submit button to display simplified Chinese.
    image

  4. From language menu select '正體中文' then click submit button to display traditional Chinese.
    image

Pull request checklist:

  • clear commit messages
  • code manually tested
  • unit tests written (optional if too hard)
  • documentation updated

@Frenzie
Copy link
Copy Markdown
Member

Frenzie commented Dec 6, 2023

Cross-ref to #1541.

Copy link
Copy Markdown
Member

@Frenzie Frenzie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me in theory, but it does leave me a little confused about what to do if one wanted to use a custom font for both.

@kasimircash
Copy link
Copy Markdown
Contributor Author

@Frenzie

That's a very good point and I did explore the topic of setting custom fonts for individual languages, the issue being that fonts that use Han character glyphs don't play nicely in a single list so separation is necessary. So, if a theme wanted to use custom fonts the lang() selector could be used as follows to achieve that separation:

body:lang(ja) {
	font-family: "Osaka", "Meiryo", sans-serif;
}
body:lang(zh-cn) {
	font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
}
body:lang(zh-tw) {
	font-family: "PingFang TC", "Microsoft JhengHei", sans-serif;
}

I didn't go ahead with something like that as it seemed to be somewhat outside the main issue of not rendering Japanese with a Chinese font.

@kasimircash
Copy link
Copy Markdown
Contributor Author

@Frenzie

I've now signed the commits. Could you re-review, please?

@kasimircash kasimircash requested a review from Frenzie December 6, 2023 18:19
@Alkarex Alkarex added this to the 1.23.0 milestone Dec 6, 2023
@Alkarex Alkarex added UI 🎨 User Interfaces I18n 🌍 Translations labels Dec 6, 2023
@Alkarex Alkarex merged commit ea6b8b7 into FreshRSS:edge Dec 10, 2023
@kasimircash kasimircash deleted the fix-font-priority branch December 10, 2023 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

I18n 🌍 Translations UI 🎨 User Interfaces

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chinese fonts are prioritized when displaying Japanese

3 participants