Unable to Display Host Fonts When Running in Flatpak Sandbox
Check for existing issues
- [X] Completed
Describe the bug / provide steps to reproduce it
Despite fc-list showing that host fonts such as Noto Sans CJK SC are available within the Flatpak sandbox, Zed is unable to display these fonts, resulting in tofu characters.
$ fc-list
...
/run/host/fonts/opentype/noto/NotoSansCJK-Regular.ttc: Noto Sans CJK SC:style=Regular
...
Steps to Reproduce
- Install Zed from Flathub.
- Disable Flatpak sandbox escape using
flatpak override --user dev.zed.Zed --env=ZED_FLATPAK_NO_ESCAPE=1. - Launch the application and input CJK characters or emojis.
Environment
Zed: v0.159.5 (Zed) OS: Linux Wayland org.freedesktop.platform 24.08 Memory: 11.4 GiB Architecture: x86_64 GPU: Intel(R) Graphics (ADL-N) || Intel open-source Mesa driver || Mesa 24.2.5 (git-3b9fcb7e4d)
If applicable, add mockups / screenshots to help explain present your vision of the feature
No response
If applicable, attach your Zed.log file to this issue.
No response
This issue may have been fixed in the upstream repository via https://github.com/servo/font-kit/pull/256. Could you please update this module to include those changes and test it?
Hi there! 👋 We're working to clean up our issue tracker by closing older issues that might not be relevant anymore. If you are able to reproduce this issue in the latest version of Zed, please let us know by commenting on this issue, and we will keep it open. If you can't reproduce it, feel free to close the issue yourself. Otherwise, we'll close it in 7 days. Thanks for your help!
It's still valid and may be related to https://github.com/Riey/fontconfig-parser/pull/11.
@ConradIrwin or @osiewicz please can you apply the patch to be able to use user fonts in flatpak?
Which patch?
In general I don't recommend running Zed inside a sandbox, but probably happy to merge a PR if you have one.
I'm curious if this is something just needed for https://github.com/flathub/dev.zed.Zed-Preview, or if https://github.com/flathub/dev.zed.Zed has the same issue?
Zed uses the servo/font-kit library and they made a patch to fix the path where flatpak exports fonts. https://github.com/servo/font-kit/pull/256 A PR was created to sync with the zed-industries/font-kit repo but I see it has been closed. https://github.com/zed-industries/font-kit/pull/4
dev.zed.Zed & dev.zed.Zed-Preview have the same problem.
A few hours ago I made a PR to sync zed-industries/font-kit with servo/font-kit
Thanks! I merged that and sent a PR to Zed here: https://github.com/zed-industries/zed/pull/30687 Are you able to verify that this change works?
To test it I need a zed-linux-x86_64.tar.gz with the build, can you merge it and send it as cherry-pick to v0.187.x? So when the next preview comes out I can test it 😃
@tomaswarynyca There are already some release artifacts in the linked PR (due to the run-bundling label), you can find your release here: https://github.com/zed-industries/zed/actions/runs/15029158835/artifacts/3125869723 (see https://github.com/zed-industries/zed/actions/runs/15029158835/job/42245998890 for the associated run)
Thanks for the help in obtaining the .tar.gz - I did some tests and this doesn't solve the problem, font-kit cannot read the fonts in ~/.local/share/fonts when ZED_FLATPAK_NO_ESCAPE=1
The only way to get reading working was to put the fonts in ~/.fonts
I don't have much idea about Rust, is the way of concatenating paths ok? I am grateful for any ideas you may have on this problem. https://github.com/servo/font-kit/blob/30dae22490c4a44ed35c5cff236ce374c1fecf9f/src/sources/fs.rs#L220
I also just tested this, and it does not work
It seems some of the fonts are in /run/host/fonts.
You can check all discovered fonts with:
$ flatpak run --command=sh --env=ZED_FLATPAK_NO_ESCAPE=1 dev.zed.Zed
[📦 dev.zed.Zed flathub]$ fc-list
For completeness sake, here are the files I used to build the flatpak.
Details
dev.zed.Zed-dev.yaml:
# dev.zed.Zed-Preview.yaml
app-id: dev.zed.Zed-dev
runtime: org.freedesktop.Sdk
runtime-version: "24.08"
sdk: org.freedesktop.Sdk
command: zed-wrapper
separate-locales: false
finish-args:
- --device=dri
- --filesystem=home
- --share=ipc
- --share=network
- --socket=fallback-x11
- --socket=pulseaudio
- --socket=wayland
# Enable access to Flatpak host commands (Needs linter exception: https://docs.flathub.org/docs/for-app-authors/linter#exceptions)
- --talk-name=org.freedesktop.Flatpak
# Enable access to Freedesktop Secret Service & related auth services since Zed uses Git heavily
- --talk-name=org.freedesktop.secrets
- --socket=ssh-auth
- --socket=gpg-agent
# Prevent Zed from escaping the sandbox by default
- --env=ZED_FLATPAK_NO_ESCAPE=1
modules:
- shared-modules/libsecret/libsecret.json
- name: gcr
buildsystem: meson
cleanup:
- /include
- /lib/debug
- /lib/girepository-1.0
- /lib/pkgconfig
- /man
- /share/gir-1.0
- /share/doc
- /share/gtk-doc
- /share/info
- /share/man
- /share/pkgconfig
- "*.a"
- "*.la"
config-opts:
- -Dgtk_doc=false
- -Dintrospection=false
sources:
- type: archive
sha256: bad10f3c553a0e1854649ab59c5b2434da22ca1a54ae6138f1f53961567e1ab7
url: https://download.gnome.org/sources/gcr/3.41/gcr-3.41.2.tar.xz
- name: libmd
buildsystem: autotools
sources:
- type: archive
url: https://libbsd.freedesktop.org/releases/libmd-1.1.0.tar.xz
sha256: 1bd6aa42275313af3141c7cf2e5b964e8b1fd488025caf2f971f43b00776b332
x-checker-data:
type: anitya
project-id: 15525
stable-only: true
url-template: https://libbsd.freedesktop.org/releases/libmd-$version.tar.xz
cleanup:
- /lib/pkgconfig
- /share/man
- name: libbsd
buildsystem: autotools
sources:
- type: archive
url: https://libbsd.freedesktop.org/releases/libbsd-0.12.2.tar.xz
sha256: b88cc9163d0c652aaf39a99991d974ddba1c3a9711db8f1b5838af2a14731014
x-checker-data:
type: anitya
project-id: 1567
stable-only: true
url-template: https://libbsd.freedesktop.org/releases/libbsd-$version.tar.xz
cleanup:
- /lib/pkgconfig
- /share/man
- name: netcat
buildsystem: simple
build-commands:
- |
while read patch; do
echo "Applying $patch..."
patch -Np1 -i "debian/patches/$patch"
done < debian/patches/series
- make CFLAGS="$CFLAGS -I/usr/include/libbsd" LDFLAGS="$LDFLAGS -lbsd"
- install -Dm0755 nc /app/bin/nc
sources:
- type: archive
url: https://salsa.debian.org/debian/netcat-openbsd/-/archive/debian/1.229-1/netcat-openbsd-debian-1.229-1.tar.gz
sha256: 4984c52882affcc638678a887964f7ab1d21901a2c5c37a38363138370d4dbda
x-checker-data:
type: json
url: https://salsa.debian.org/api/v4/projects/20760/repository/tags
version-query:
map(select(.name | startswith("debian/"))) | first | .name
| split("debian/") | .[1]
url-query:
'"https://salsa.debian.org/debian/netcat-openbsd/-/archive/debian/"
+ $version + "/netcat-openbsd-debian-" + $version + ".tar.gz"'
- name: zed-dev
buildsystem: simple
build-commands:
- install -Dm 755 bin/* --target-directory ${FLATPAK_DEST}/bin
- install -Dm 755 lib/* --target-directory ${FLATPAK_DEST}/lib
- install -Dm 755 libexec/* --target-directory ${FLATPAK_DEST}/libexec
- install -Dm 644 share/applications/* --target-directory ${FLATPAK_DEST}/share/applications
- install -Dm 644 ${FLATPAK_ID}.metainfo.xml --target-directory ${FLATPAK_DEST}/share/metainfo
- install -Dm 644 share/icons/hicolor/512x512/apps/zed.png ${FLATPAK_DEST}/share/icons/hicolor/512x512/apps/zed-preview.png
- install -Dm 644 share/icons/hicolor/512x512/apps/zed.png ${FLATPAK_DEST}/share/icons/hicolor/512x512/apps/zed-dev.png
# Rename instances of `zed` to `${FLATPAK_ID}`
- rename zed-preview ${FLATPAK_ID} ${FLATPAK_DEST}/share/{applications/*,icons/hicolor/*/apps/*}
- rename zed-dev ${FLATPAK_ID} ${FLATPAK_DEST}/share/{applications/*,icons/hicolor/*/apps/*}
# Ensure zed-wrapper is used as the Exec command in the `.desktop` file
- desktop-file-edit --set-key="Exec" --set-value="zed-wrapper %U" ${FLATPAK_DEST}/share/applications/${FLATPAK_ID}.desktop
# Modify original `.desktop` file to use the correct icon name
- desktop-file-edit --set-icon="${FLATPAK_ID}" ${FLATPAK_DEST}/share/applications/${FLATPAK_ID}.desktop
sources:
- type: archive
url: file:///home/mona/Downloads/zed-36fdaed7f14c039b9ee46c199a3b31ef9fa66a8d-x86_64-unknown-linux-gnu.tar.gz/zed-1192ec3-linux-x86_64.tar.gz
sha256: fbaa044607948beef703a110e51b792e2b882b02c649a56b3c27a395d928c2a7
only-arches:
- x86_64
x-checker-data:
type: json
url: https://api.github.com/repos/zed-industries/zed/releases
version-query: map(select(.prerelease)) | first | .tag_name
url-query:
map(select(.prerelease)) | first | .assets[] | select(.name=="zed-linux-x86_64.tar.gz")
| .browser_download_url
is-main-source: true
- type: archive
url: https://github.com/zed-industries/zed/releases/download/v0.187.2-pre/zed-linux-aarch64.tar.gz
sha256: f1a3560364715d8e70c39ff0f125bc2126f5a2957e17e474d32a48b994e309e6
only-arches:
- aarch64
x-checker-data:
type: json
url: https://api.github.com/repos/zed-industries/zed/releases
version-query: map(select(.prerelease)) | first | .tag_name
url-query:
map(select(.prerelease)) | first | .assets[] | select(.name=="zed-linux-aarch64.tar.gz")
| .browser_download_url
is-main-source: true
- type: file
path: dev.zed.Zed-dev.metainfo.xml
- name: host-spawn
buildsystem: simple
build-commands:
- install -Dm755 host-spawn /app/bin/host-spawn
sources:
- type: file
url: https://github.com/1player/host-spawn/releases/download/v1.6.1/host-spawn-x86_64
sha256: 733746ab498e07d065cbecf80bacd447eb21846d1462e8fe23fdd9d9dc977b50
dest-filename: host-spawn
only-arches: [x86_64]
x-checker-data:
type: json
url: https://api.github.com/repos/1player/host-spawn/releases/latest
tag-query: .tag_name
version-query: .tag_name
timestamp-query: .published_at
url-query: '[.assets[] | select(.name|test(".+x86_64$"))][0] | .browser_download_url'
- type: file
url: https://github.com/1player/host-spawn/releases/download/v1.6.1/host-spawn-aarch64
sha256: 71b7744a4d0b29279523cc0f0ed1a7af5e9555510bd9e6d4685391b59faefaac
dest-filename: host-spawn
only-arches: [aarch64]
x-checker-data:
type: json
url: https://api.github.com/repos/1player/host-spawn/releases/latest
tag-query: .tag_name
version-query: .tag_name
timestamp-query: .published_at
url-query: '[.assets[] | select(.name|test(".+aarch64$"))][0] | .browser_download_url'
- name: zed-wrapper
buildsystem: meson
config-opts:
- -Deditor_binary=/app/bin/zed
- -Deditor_title=Zed
- -Dprogram_name=zed-wrapper
- -Dfirst_run_template=README.md
- -Dsdk_update_template=sdk_update.md
- -Dflagfile_prefix=flatpak-zed
- -Ddefault_loglevel=0
sources:
- type: git
commit: 3314b55ccd4ece8810715787e246f8407e20caab
url: https://github.com/flathub-infra/ide-flatpak-wrapper
- type: file
path: README.md
- type: file
path: sdk_update.md
dev.zed.Zed-dev.metainfo.xml
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop-application">
<id>dev.zed.Zed-dev</id>
<name>Zed dev</name>
<summary>High-performance code editor</summary>
<developer id="dev.zed">
<name translate="no">Zed Industries, Inc.</name>
</developer>
<description>
<p>
*NOTE*: This is the official release of Zed, packaged into a Flatpak by the community. This repackaging is not yet supported by Zed Industries, Inc.
</p>
<p>
Productive coding starts with a tool that stays out of your way. Zed blends the power of an IDE with the speed of a lightweight editor for productivity you can feel under your fingertips.
</p>
<p>Features:</p>
<ul>
<li>Performance: Efficiently uses every CPU core and your GPU for instant startup, quick file loading, and responsive keystrokes.</li>
<li>Language-aware: Maintains a syntax tree for precise highlighting, and auto-indent, with LSP support for autocompletion and refactoring.</li>
<li>Collaboration: Real-time editing and navigation for multiple developers in a shared workspace.</li>
<li>AI Integration: Integrates GitHub Copilot and GPT-4 for natural language code generation.</li>
</ul>
</description>
<launchable type="desktop-id">dev.zed.Zed-dev.desktop</launchable>
<recommends>
<control>pointing</control>
<control>keyboard</control>
<display_length compare="ge">768</display_length>
</recommends>
<screenshots>
<screenshot type="default">
<caption>Zed with a large project open, showing language server and gitblame support</caption>
<image>https://zed.dev/img/flatpak/flatpak-1.png</image>
</screenshot>
<screenshot>
<caption>Zed with a file open and a channel message thread in the right sidebar</caption>
<image>https://zed.dev/img/flatpak/flatpak-2.png</image>
</screenshot>
<screenshot>
<caption>Example of a channel's shared document</caption>
<image>https://zed.dev/img/flatpak/flatpak-3.png</image>
</screenshot>
<screenshot>
<caption>Zed's extension list</caption>
<image>https://zed.dev/img/flatpak/flatpak-4.png</image>
</screenshot>
<screenshot>
<caption>Theme switcher UI and example theme</caption>
<image>https://zed.dev/img/flatpak/flatpak-5.png</image>
</screenshot>
</screenshots>
<categories>
<category>Development</category>
<category>Utility</category>
</categories>
<developer_name>Zed Industries, Inc.</developer_name>
<url type="homepage">https://zed.dev</url>
<url type="bugtracker">https://github.com/zed-industries/zed/issues</url>
<url type="faq">https://zed.dev/faq</url>
<url type="help">https://zed.dev/docs/getting-started</url>
<url type="contact">https://zed.dev/community-links#support-and-feedback</url>
<url type="vcs-browser">https://github.com/zed-industries/zed</url>
<url type="contribute">https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md</url>
<project_group>Zed</project_group>
<releases>
<release version="v0.187.2-pre" date="2025-05-15">
<description></description>
</release>
<release version="v0.186.0-pre" date="2025-05-07">
<description/>
</release>
<release version="v0.185.4-pre" date="2025-05-02">
<description/>
</release>
<release version="v0.185.2-pre" date="2025-05-01">
<description/>
</release>
<release version="v0.185.1-pre" date="2025-05-01">
<description/>
</release>
<release version="v0.184.4-pre" date="2025-04-25">
<description/>
</release>
</releases>
<metadata_license>MIT</metadata_license>
<project_license>AGPL-3.0-or-later and Apache-2.0 and GPL-3.0-or-later</project_license>
<content_rating type="oars-1.1">
<content_attribute id="social-chat">intense</content_attribute>
<content_attribute id="social-audio">intense</content_attribute>
</content_rating>
</component>
@tomaswarynyca The code looks ok. Does the flatpak sandbox allow access to ~/.local/share/fonts?
If not, is it permitted to add more permissions to the manifest to make this work?
I add to flatpak the exact directory in filesystems permissions
➜ ~ flatpak override --user --filesystem=~/.local/share/fonts dev.zed.Zed-Preview
Accessing via sh I can see the fonts, but Zed can't load them
➜ ~ flatpak run --command=sh --env=ZED_FLATPAK_NO_ESCAPE=1 dev.zed.Zed-Preview
[📦 dev.zed.Zed-Preview ~]$ ls ~/.local/share/fonts
CascadiaCode-BoldItalic.otf CascadiaCode-LightItalic.otf CascadiaCode-SemiLightItalic.otf 'FS Nokio Medium.otf' JetBrainsMono-Italic.ttf
CascadiaCode-Bold.otf CascadiaCode-Light.otf CascadiaCode-SemiLight.otf JetBrainsMono-Bold-Italic.ttf JetBrainsMono-Medium-Italic.ttf
CascadiaCode-ExtraLightItalic.otf CascadiaCode-Regular.otf 'FS Nokio Bold.otf' JetBrainsMono-Bold.ttf JetBrainsMono-Medium.ttf
CascadiaCode-ExtraLight.otf CascadiaCode-SemiBoldItalic.otf 'FS Nokio ExtraLight.otf' JetBrainsMono-ExtraBold-Italic.ttf JetBrainsMono-Regular.ttf
CascadiaCode-Italic.otf CascadiaCode-SemiBold.otf 'FS Nokio Light.otf' JetBrainsMono-ExtraBold.ttf
➜ ~ flatpak info --show-permissions dev.zed.Zed-Preview
[Context]
filesystems=home;~/.local/share/fonts;
// Zed settings
{
"ui_font_family": "Cascadia Code", // Value is not accepted.
"buffer_font_family": "Cascadia Code" // Value is not accepted.
}
With default config of flatpak package I can also see the fonts in ~/.local/share/fonts directory
➜ ~ flatpak info --show-permissions dev.zed.Zed-Preview
[Context]
filesystems=home;
➜ ~ flatpak run --command=sh --env=ZED_FLATPAK_NO_ESCAPE=1 dev.zed.Zed-Preview
[📦 dev.zed.Zed-Preview ~]$ ls ~/.local/share/fonts
CascadiaCode-BoldItalic.otf CascadiaCode-LightItalic.otf CascadiaCode-SemiLightItalic.otf 'FS Nokio Medium.otf' JetBrainsMono-Italic.ttf
CascadiaCode-Bold.otf CascadiaCode-Light.otf CascadiaCode-SemiLight.otf JetBrainsMono-Bold-Italic.ttf JetBrainsMono-Medium-Italic.ttf
CascadiaCode-ExtraLightItalic.otf CascadiaCode-Regular.otf 'FS Nokio Bold.otf' JetBrainsMono-Bold.ttf JetBrainsMono-Medium.ttf
CascadiaCode-ExtraLight.otf CascadiaCode-SemiBoldItalic.otf 'FS Nokio ExtraLight.otf' JetBrainsMono-ExtraBold-Italic.ttf JetBrainsMono-Regular.ttf
CascadiaCode-Italic.otf CascadiaCode-SemiBold.otf 'FS Nokio Light.otf' JetBrainsMono-ExtraBold.ttf
Apologies for the late reply! I looked into this further and realized that Zed actually uses cosmic-text on Linux, not font-kit. Here's what I found:
- The issue might be related to
fontdb, whichcosmic-textrelies on. There's a possibly related issue https://github.com/pop-os/cosmic-text/issues/379, which was resolved by updatingfontdb. While this doesn't directly mention Flatpak, it might be worth checking whether updatingfontdbcould help. - Another potential culprit is the upstream
fontconfig-parser. A recent fix https://github.com/Riey/fontconfig-parser/pull/11 was merged just a few days ago. Updating thefontconfig-parserversion might resolve the problem.
@ConradIrwin can update in the PR fontconfig-parser to be version 0.5.8 in Cargo.lock?
ping @ConradIrwin
Updated https://github.com/zed-industries/zed/pull/30687 with latest main and the new fontconfig-parser.
Sorry for the delay, was out of the office for the last fortnight.
Thanks, @ConradIrwin! Unfortunately, it's still not working in my test. Maybe we'll need to wait for cosmic-text to release a new version?
Blergh. Not sure either...
I just updated the Zed flatpak, and it seems to correctly use my system terminal font.
I didn't change anything though, and I still can't find the font while I try editing buffer_font_family
I just updated the Zed flatpak, and it seems to correctly use my system terminal font.
I have also upgraded to version 0.201.5, and the issue persists. Of course, if you disable the sandbox (which is the default), you can use system fonts.
Hi - maybe we need a new release of cosmic-text, I ask for it a few hours ago https://github.com/pop-os/cosmic-text/pull/383?notification_referrer_id=NT_kwDOAnqTy7QxNTk2NTAwMDQ2OTo0MTU4NzY1OQ#issuecomment-3233568784
A new version of cosmic-text (v0.15.0) has been released. Could we try upgrading to see if it resolves the problem?
Gentle ping @ConradIrwin
@NN708 are you able to send a PR?
@ConradIrwin Possibly, but I do have a concern about the CLA requirement.
This has been resolved. I'm closing the issue.