slint icon indicating copy to clipboard operation
slint copied to clipboard

Font conguration for embedded fonts for the software renderer on MCU

Open ogoffart opened this issue 3 months ago • 3 comments

When compiling with slint_build::EmbedResourcesKind::EmbedForSoftwareRenderer, we need a way to specify with font to embed, which glyph ranges, which sizes.

Currently there is some code that tries to auto-detect the sizes, and there is also the undocumented SLINT_FONT_SIZES env variable. But embedding all the fonts with all the glyphs with all size variant is taking way too much flash and is not practical.

ogoffart avatar Mar 27 '24 07:03 ogoffart

Some options: (We can combine several approach)

  1. Have a config file somewhere (see https://github.com/slint-ui/slint/issues/267 )
  2. Some more configuration in slint_build
  3. Add some syntax to the import "foo.ttf"; statement so we can specify sizes and ranges
  4. Improve the flexibility of environment variables, and document them.

ogoffart avatar Mar 27 '24 07:03 ogoffart

Would it be possible to extend Platform or add another Trait with a call like get_glyph(...) -> Option<...>? If a glyph is not found in the embedded font data, slint asks for the glyph.

MiSimon avatar Mar 27 '24 07:03 MiSimon

There is another issue for loading font at runtime: https://github.com/slint-ui/slint/issues/4250 But a fallback in the platform seems like a good idea as well.

ogoffart avatar Mar 27 '24 08:03 ogoffart