CJK fonts aren't found when running inside a Flatpak sandbox

Open
#2,313 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust

Research direction

Start with cjk_candidates and FONT_ROOTS in crates/render/src/fonts.rs, then inspect how the existing font paths are selected. Reproduce in a Flatpak with a CJK locale and host Noto Sans CJK installed. Done when CJK interface text and map labels render in the sandbox; check any font lookup tests around those paths.

Written by the indexing model from the issue text.

Description

When RustGIS runs inside a Flatpak sandbox, an interface in Chinese, Japanese or Korean draws as empty boxes, and CJK map labels are left out. This happens even though the host has Noto Sans CJK installed.

Why: in a Flatpak, /usr/share/fonts is the runtime's own folder, and the freedesktop runtime has no CJK font. The host's fonts are mounted elsewhere:

  • /run/host/fonts: the system's fonts, e.g. /run/host/fonts/opentype/noto/NotoSansCJK-Regular.ttc
  • /run/host/user-fonts: the user's ~/.local/share/fonts
  • /run/host/local-fonts: /usr/local/share/fonts

RustGIS looks for CJK faces at fixed paths under /usr/share/fonts (cjk_candidates in crates/render/src/fonts.rs), so it doesn't find them there. Toolkits that go through fontconfig pick these folders up from the runtime's fonts.conf, but RustGIS reads font files directly, which is fine everywhere else.

Suggestion: could the CJK lookup, and FONT_ROOTS, also try the same relative paths under /run/host/fonts, /run/host/user-fonts and $XDG_DATA_HOME/fonts? Searching those roots for the known file names, rather than only the fixed full paths, would also cover distributions that keep Noto CJK in a different subfolder.

To reproduce (RustGIS 0.7.0):

flatpak install flatpark org.rustgis.RustGIS
flatpak run --env=LANG=zh_CN.UTF-8 org.rustgis.RustGIS

For now the package page suggests --env=RUSTGIS_LANGUAGE=en to CJK users. On our side this is tracked in flatpark/flatpark#1309. Once a release with the change is out, the package picks it up automatically and needs no change of its own.

Dominant language
Rust
Stars
1.9k
Forks
268
Avg merge
11h 1m
Merged PRs (30d)
942

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from opengeos/RustGIS

All issues in opengeos/RustGIS

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.