slint icon indicating copy to clipboard operation
slint copied to clipboard

Misleading compilation error when default font cannot be embedded when embedding glyphs

Open ogoffart opened this issue 3 months ago • 5 comments

When building with slint_build::EmbedResourcesKind::EmbedForSoftwareRenderer, we get misleading compilation error when the default font don't exist.

To reproduce, edit the carousel_demo.slint and change the default font binding:

default-font-family: "NOT EXIST";

Then you get the error:

error: could not find font that provides specified family, falling back to Sans-Serif
    --> /home/olivier/slint/examples/carousel/ui/carousel_demo.slint:22:26
     |
  22 |     default-font-family: "NOT EXIST";
     |                          

It says it is falling back, but it doesn't since it errors out.

The error is even worse if the invalid font comes from the style. Eg, modify the material-base/std-widget-impl.slint to change the default font

    out property <string> default-font-family: "NOT EXIST";

and remove the default-font-family property from the window. Now we get:

error: internal error: fontdb could not determine a default font for sans-serif
   --> /home/olivier/slint/examples/carousel/ui/carousel_demo.slint:8:38
    |
  8 | export component MainWindow inherits Window {
    |                                      ^

ogoffart avatar Apr 02 '24 13:04 ogoffart

I am also having a similar issue on FreeBSD... Anyone have a fix yet? I used the default template with cargo-generate. It seemed to build fine, but when I ran cargo run I got the error you see below.

image

V0idMatr1x avatar May 10 '24 12:05 V0idMatr1x

Similar issue indeed. Do you have libfontconfig on your system installed?

tronical avatar May 10 '24 13:05 tronical

Similar issue indeed. Do you have libfontconfig on your system installed?

Yes, it was installed. That was the first thing I thought to check. Thanks for the quick response!

V0idMatr1x avatar May 11 '24 08:05 V0idMatr1x

Ok - next thing to check :). What does fc-match sans-serif print?

tronical avatar May 11 '24 11:05 tronical

Ok - next thing to check :). What does fc-match sans-serif print?

It prints NotoSans-Regular.ttf: "Noto Sans" "Regular"

V0idMatr1x avatar May 20 '24 18:05 V0idMatr1x