victrme / Bonjourr

Minimalist & lightweight startpage inspired by iOS
https://bonjourr.fr
GNU General Public License v3.0
880 stars 104 forks source link

VER 19 Chinese font loading problem #308

Closed william-song-shy closed 6 months ago

william-song-shy commented 6 months ago

Describe the bug If lauguage is Chinese, using font without Chinese supporting (such as Space Mono) will take long time requesting for non-existing chinese-simplified font file. The latin font will request after it fails. It takes a long time to load the fonts, so it also takes a long time to display the page.

To Reproduce Steps to reproduce the behavior:

  1. Change lauguage to Chinese.
  2. Start a new page.

Expected behavior Latin font file should load first. Also maybe the non-existing chinese font file should be ignored.

Screenshots 图片

Device (please complete the following information):

victrme commented 6 months ago

Hi @william-song-shy ! Can you detail the steps you take to reproduce the error ? I do see some weird behavior that needs to be fixed, but not your issue.

william-song-shy commented 6 months ago

Hi @william-song-shy ! Can you detail the steps you take to reproduce the error ? I do see some weird behavior that needs to be fixed, but not your issue.

I created a example config. I only changed the font part from the default config. I can reproduce the problem using it.

victrme commented 6 months ago

Indeed, it is always doing this when importing settings. The obvious fix is to replace "Space Mono" by an empty string "" for now.

Since this update, Bonjourr gets its fonts the "dumb" way by requesting a certain filename to cdn.jsdelivr.net. When importing, it doesn't verify what font subset is available and simply does:

zh_CN + Space Mono = space-mono@latest/chinese-simplified-400-normal.woff2.

william-song-shy commented 6 months ago

Indeed, it is always doing this when importing settings. The obvious fix is to replace "Space Mono" by an empty string "" for now.

Since this update, Bonjourr gets its fonts the "dumb" way by requesting a certain filename to cdn.jsdelivr.net. When importing, it doesn't verify what font subset is available and simply does:

zh_CN + Space Mono = space-mono@latest/chinese-simplified-400-normal.woff2.

But these font files are loaded one by one, and the Latin file is loaded after the Chinese file failed. I belive the problem can be solved if you load the Latin file first or load all the font files together.

victrme commented 6 months ago

I forgot to mention that this a bug! To fix it, we need to check if the subset is valid before fetching the file.

The goal is to only load the file needed for performance reasons, so Latin will only be fetched if something fails.

william-song-shy commented 6 months ago

I think that's the way to solve it! Will you fix it in next version?

victrme commented 6 months ago

Not 100% sure, but it should be included in the next update !

william-song-shy commented 6 months ago

I understand that the improvement "Font autocomplete only shows fonts available for your language". So maybe the problem is caused by the upgrade :smile:

victrme commented 6 months ago

All fixed, update coming pretty soon 👍