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

My locale is zh_CN.UTF-8, font-manager lacks 4 cjk fonts #330

Closed
viruscamp opened this issue Jul 5, 2023 · 5 comments
Closed

My locale is zh_CN.UTF-8, font-manager lacks 4 cjk fonts #330

viruscamp opened this issue Jul 5, 2023 · 5 comments

Comments

@viruscamp
Copy link

viruscamp commented Jul 5, 2023

Describe the bug
My locale is zh_CN.UTF-8, font-manager show 239 fonts, lacks 4 cjk fonts.

LC_ALL=C font-manager shows 243 fonts,
LC_ALL=zh_CN.UTF-8 font-manager shows 239 fonts.

LC_ALL=zh_CN.UTF-8 font-manager -l shows all 243, the 4 lacks fonts are:

思源黑体 CN
思源宋体 CN
文泉驿微米黑
文泉驿等宽微米黑
....

LC_ALL=C font-manager -l shows all 243, the 4 lacks fonts are:

Source Han Sans CN
Source Han Serif CN
WenQuanYi Micro Hei
WenQuanYi Micro Hei Mono
...

System Information

  • OS: Arch
  • Desktop Environment [e.g. GNOME, XFCE, etc]
  • Font Manager version extra/font-manager 0.8.8-1 and aur/font-manager-git 0.8.8.r54.g7ba0a33e-1
  • Font Manager installation method [e.g. Distribution package, PPA, COPR, AUR, etc]
  • Additional fonts pkgs:
    adobe-source-han-sans-cn-fonts
    wqy-microhei
@viruscamp
Copy link
Author

image
image

@viruscamp
Copy link
Author

I've found the cause:
The first run was not under zh_CN.UTF-8, font-manager created db file as ~/.cache/font-manager/Fonts.sqlite, and saved the names below:

Source Han Sans CN
Source Han Serif CN
WenQuanYi Micro Hei
WenQuanYi Micro Hei Mono

After sometimes, I changed my lang to zh_CN.UTF-8, so I ran font-manager under zh_CN.UTF-8,

Let's look at src/font-manager/filters/Category.vala

public new async void update () {
    get_matching_families_and_fonts(db, families, descriptions, sql); // load from db, got Source Han Sans CN
    StringSet? available_families = get_default_application().available_families; // load from fontconfig, got 思源黑体 CN
    families.retain_all(available_families); // no Source Han Sans CN nor 思源黑体 CN
    return;
}

@JerryCasiano
Copy link
Contributor

Sorry for the late response. Haven't been active for a while.

I appreciate you taking the time to not only find this bug but actually determine the cause.

A couple ways we could resolve this. Will keep this in mind for the next version.

Most likely we'll just do with the database what we do with the Google fonts cache which is drop it after a couple days but it might also make sense to drop it whenever environment values change. We'll see.

Thanks again.

@JerryCasiano
Copy link
Contributor

@viruscamp

We now drop the Fonts table everytime we update the database.

I think this should prevent the issue you encountered.

Feel free to reopen this if it doesn't.

Thanks.

@JerryCasiano
Copy link
Contributor

While dropping the font table did seem to resolve the missing fonts situation it failed to address outdated orthographies which meant invalid sample strings on locale changes.

We now track the locale when the database was last updated and rebuild the database anytime it changes.

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

No branches or pull requests

2 participants