slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.13k stars 581 forks source link

CJK Glyphs Render as empty squares in Flatpak #6483

Open R3alCl0ud opened 6 hours ago

R3alCl0ud commented 6 hours ago

Linux Flatpak: Runtime: org.freedesktop.Platform//24.08 Host distrubutions confirmed: Steam OS (Steam Deck), Arch Linux Rust. Slint 1.8.0, Winit backend, cosmic style

Build slint app and package it as flatpak. Run app. CJK Glyphs do not render correctly look ma no glyphs Left Flatpak, Right System

Forcibly including the font by adding it in the appwindow.slint as an import does not make them render correctly

import "./fonts/NotoSerifCJK-VF.ttf.ttc";
import "./fonts/NotoSansCJK-VF.ttf.ttc";
import "./fonts/NotoSansMonoCJK-VF.ttf.ttc";

export component App inherits Window {
    default-font-family: "Noto Sans";
    Text {
        text: "これはテキストと漢字"; // displays as boxes
    }
}

I believe that this may be related to #2563 and #1138

R3alCl0ud commented 6 hours ago

I just created a repo which recreates the bug in question to make it much easier to understand https://github.com/R3alCl0ud/slint-cjk-flatpak-test

R3alCl0ud commented 5 hours ago

Did some more testing, turns out this is an issue with the winit backend specifically.

tronical commented 1 hour ago

I tried building the flatpack package, but I get error: app/org.flatpak.Builder/aarch64/master not installed.

Where in your host file system is the font (NotoSerifCJ*) located, and how do you make it accessible to the flatpack sandbox?

Do you set environment variables like FONTCONFIG_FILE or XDG_CONFIG_HOME? For the sandboxed process, what would be located in /etc/fonts/?

R3alCl0ud commented 58 minutes ago
  1. oops, the flatpak builder package is needed, try installing these build dependancies flatpak install org.flatpak.Builder org.kde.Platform//6.7 org.kde.Sdk//6.7 then try building it again.
  2. I am on arch linux using the noto-fonts-cjk package which places the font files in /usr/share/fonts/noto-cjk
  3. I am not overriding or setting the FONTCONFIG_FILE or XDG_CONGIF_HOME env vars. image
  4. in the example repo I provided I included the font files and have them imported into the binary (I believe thats what happens based on this verbage in the 1.8.0 documentation), so it should have access to the CJK fonts since they are part of the binary.
    You can select a custom font with the import statement: import "./my_custom_font.ttf" in a .slint file. This instructs the Slint compiler to include the font and makes the font families globally available for use with font-family properties.
  5. I can confirm the missing cjk glyphs behavior is only present when using the winit backends. Forcing the qt backend with flatpak --env=SLINT_BACKEND=qt run io.github.r3alcl0ud.slint-cjk-flatpak-test makes the CJK glyphs render normally.
R3alCl0ud commented 32 minutes ago

I updated the example repo with more clear instructions, and switched it's run time to the kde runtime since QT is not in the freedesktop runtime sandbox. This does not change the behavior of the missing cjk glyphs when using winit backends.

R3alCl0ud commented 13 minutes ago

host font files are exposed in /run/host/fonts when inside of the sandbox