Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add font-display: swap; for every CJK fonts #191

Open
hoah2333 opened this issue May 30, 2023 · 1 comment
Open

Add font-display: swap; for every CJK fonts #191

hoah2333 opened this issue May 30, 2023 · 1 comment
Assignees

Comments

@hoah2333
Copy link
Contributor

hoah2333 commented May 30, 2023

Is your feature request related to a problem? Please describe.
For some Chinese users, they sometimes dislike it when BHL is used in an article. This is because when they open a page that includes the BHL theme, they often find that there are no Chinese characters displayed on their screen. Instead, they see only English words and numbers. It takes several seconds, or even several minutes, for the fonts to load before they can finally read the article normally. This situation leads to complaints that the BHL theme is "so laggy."

This issue is essentially a network problem. Due to the Great Firewall of China (GFW) or some local policies, people may have difficulty connecting to github.io or fonts.googleapis.com to download the required assets.

In the following gif, I used a trick to reproduce this problem, which can be described as "fully reloading the source code."

20230530-03

Describe the solution you'd like:
I noticed that you have added font-display: swap for every English font but not for the CJK (Chinese, Japanese, Korean) fonts. Therefore, the solution is simple.

Add font-display: swap; for every CJK font. This will display the fallback font for users first and then switch to the correct font after it is loaded.

As shown in the gif below, this significantly improves the reading experience.

20230530-04

Describe alternatives you've considered:

  • Importing the fonts from Google Fonts, or
  • Separating the @font-face part from the final black-highlighter.min.css and allowing each branch to choose its own font pack. For example, the CN branch can use @import url("https://nu-scptheme.github.io/Black-Highlighter/css/font/CN-fonts.css");, and the JP branch can use @import url("https://nu-scptheme.github.io/Black-Highlighter/css/font/JP-fonts.css");. This solution can reduce the loading burden for users who will never use certain languages.

Additional context:
Test environment:
System: Windows 11 Insider Preview Build 25375
Browser: Firefox 113.0.2
Page: Advanced Information Methodology (AIM) Component (CN Version)

@Woedenaz
Copy link
Contributor

Ah, excellent, that is very good to know! It makes sense that changing it to swap would help. I like your second idea and shouldn't be too difficult. I'll work on that sometime this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants