Commit graph

24 commits

Author SHA1 Message Date
Simon Hausmann
02694f4992 Replace unwraps in compiler glyph embedding with diagnostics
As discussed with Olivier, fatal diagnostics are better than a panicing
compiler.
2023-02-09 18:16:29 +01:00
Simon Hausmann
047ab1d419 Fix run-time panic when combining forward-focus with text rendering in no_std environments
As outlined in #2199, there may be ways to trigger text layout code
through forward-focus before embedded fonts are registered. To fix this,
this patch replaces the init_code vector, which had the SetFocusItem
code before the font registration, with three explicit vectors for focus
setup code, code from init callbacks, and initial focus, and defines the
order in one central place in the copmiler (iter()).

Fixes #2199
2023-02-08 15:41:35 +01:00
Simon Hausmann
860f318f7c
Bump femtovg, rustybuzz, ttf-parser, and fontdb dependencies (#2191)
Mostly bugfix changes upstream with some minor API changes. FemtoVG is
no more limited to 24 gradient stops for the paint.
2023-02-08 09:56:53 +01:00
Simon Hausmann
c04bc00d34 Add initial support for rendering text in the screenshot test driver
This uses the approach discussed in Mattermost: The compiler understands
a SLINT_DEFAULT_FONT environment variable that can point to a path,
which overrides the fallback font that would otherwise come from the
system (and differ between test systems).
2023-01-09 14:12:33 +01:00
Simon Hausmann
907b58161c Add support for invoking an init callback on component and element construction
This enables imperative code to be run. To be used sparingly :-)
2022-11-17 10:12:08 +01:00
Olivier Goffart
ca616857b1 Workaround compiler bug with Rust 1.64 and aarch64 2022-11-07 12:50:09 +01:00
Simon Hausmann
8428a1dad1 Fix wasm build 2022-06-16 15:21:01 +02:00
Simon Hausmann
7c37a3b14e mcu: Fix missing glyphs in the slide puzzle
Scan for string literals to make sure to include the special characters used in the demo.
2022-06-16 15:21:01 +02:00
Simon Hausmann
9f957e7db5 Fix some missing glyphs in the slide puzzle on stm32h7
Implement some very rudimentary font fallback handling and add some the
glyphs the puzzle needs.

The font fallback handling deserves to go into a module shared between
GL backend and the compiler.

For the character selection we should scan the text elements for
literals just like we do for the font size.
2022-06-16 15:21:01 +02:00
Simon Hausmann
3bc43cdcfa mcu: embed default font and imported fonts
Make sure to embed whatever we pick as default font, but also register
any custom imported fonts.

This fixes the plaster font not showing up in the slide puzzle on the
stm32.
2022-06-16 15:21:01 +02:00
Simon Hausmann
5aae0b7312 Fix wasm build 2022-04-08 15:11:26 +02:00
Simon Hausmann
70f3f50359 mcu: Add support for automatic font size detection
Continue to support specififying logical font sizes in the compile step
via SLINT_FONT_SIZES, but additionally look for Text/TextInput/Window elements
and extract any constant font sizes
found.

This makes it work out of the box with the printer demo.
2022-04-08 15:11:26 +02:00
Olivier Goffart
cf49568373 Compiler: make the image processing an enum in the config 2022-03-24 13:16:21 +01:00
Olivier Goffart
41b20fdd59 MCU build system: pass information about embedding images and glyph to the compiler
... using metadata from the build script send with the DEP_I_SLINT_BACKEND_MCU

Saves two environment variable that we don't have to pass
2022-03-24 13:16:21 +01:00
Simon Hausmann
43759cd1bb Fix elided text rendering on mcu
Commit aee3ffca27 accidentally removed the elision character
2022-03-10 11:43:01 +01:00
Simon Hausmann
aee3ffca27 Add additional glyphs for embedding
Co-authored-by: Olivier Goffart <olivier.goffart@slint-ui.com>
2022-03-10 10:51:32 +01:00
Simon Hausmann
abca5bed78 Include elision character in bitmap glyphs 2022-03-10 10:51:32 +01:00
Simon Hausmann
f5a34b3df0 Add colon to the list of hard-coded glyphs to cover 2022-03-10 10:51:32 +01:00
Simon Hausmann
738ac0dc01 mcu: scale images at compile time (#966)
Apply a scale factor to reduce the size of embedded images at compile
time.
2022-03-03 13:28:47 +01:00
Simon Hausmann
668e02aa83 Fix glyph embedding on Linux
Copy the fontconfig code from the GL backend to find out what the font for "sans-serif" is, in case we need a fallback.
2022-02-23 12:13:10 +01:00
Simon Hausmann
f912ec7e6b Fix scaling of glyphs and improve type safety in the MCU backend
The code was mixing logical and physical sizes, causing glyphs being
doubly scaled down. Instead, this patch introduces:

 * Physical* and Logical* euclid length/size/rect aliases
 * some extraction traits for getting the scalars in rects/sizes as lengths (until euclid has them
built-in)
 * wrapper traits/types for safely extracting the physical font metrics the
 compiler generates (i16)
 * Fix a bug in the text height calculation where we failed to take the
   descent into account
2022-02-17 15:07:57 +01:00
Simon Hausmann
27a8c33c07 janitor: fix wasm build of the compiler
Seems weird, but the wasm-interpreter needs the compiler lib :)
2022-02-15 16:03:17 +01:00
Simon Hausmann
07da5c1c36 janitor: Fix license headers 2022-02-15 15:55:41 +01:00
Simon Hausmann
304e06f758 Begin rasterizing glyphs for glyph embedding
Enable with `SLINT_EMBED_GLYPHS=1` and select sizes like
`SLINT_FONT_SIZES=12,16`

This change just puts the data structures in place, rasterizes a fixed
subset, embeds that into the rust generated code and calls a backend
function for registering the font that is unimplemented.
2022-02-15 15:52:24 +01:00