Commit graph

36 commits

Author SHA1 Message Date
Olivier Goffart
c98d234b9e Janitor: Always use `#![no_std] for runtime lib
And call `extern crate std` when the feature is enabled.
I've read this is the good practice on how to do it.
So that the std prelude is no longer included automatically.
There is then less difference between std and and no-std build which
should avoid surprises in the CI when we use things from the prelude.

The downside is that there is a bit of churn in the tests
2025-01-27 19:22:00 +01:00
Olivier Goffart
4e7bbcf2ba
Try to improve rendering (positioning) of signed field distance font. (#6868)
* WIP: swrenderer: use fixed point for the pixmap font coordinate

* swrenderer: signed distance field: move the glyph to the middle

* swrenderer: round the advance instead of truncating it in distance field

* swrenderer: actually align the gplyph on the sub-pixel precision

sub-pixel within the source.

* swrenderer: adapt the threshold for signed distance field

sqrt(2) is the distance to the diagonal, seems like this gives sharper fonts

* Fix bug in the elision, and re-upload the screenshort

the screenshot changed because the afvanced is now rounded intead of
truncated
2024-11-30 23:03:31 +01:00
Olivier Goffart
446bb4a6bf
swrenderer: signed distance field: properly round the x and y glyph coordinate (#6687) 2024-10-30 18:12:52 +01:00
Olivier Goffart
45976bcf2b
Small polish of the appearence of small glyph with sdf
The trick is that we should have a constant delta, regardless of the
size of the individual glyphs.
2024-10-30 10:43:32 +01:00
Olivier Goffart
d8ab4e4600 Signed DistanceField font rendering in swrenderer
Note that this is still disabled in the compiler with no way to enable
it with public API
2024-10-23 09:12:30 +02:00
Simon Hausmann
20cf304936 Enable support for WASM builds with the software renderer
Everything is already working, just had to play around with a few cfgs. The sharedfontdb module already takes care of including DejaVuSans as default fallback font.
2024-10-17 08:50:25 +02:00
Simon Hausmann
0b028bfb6f
Add support for a font-metrics property to Text/TextInput. (#6452)
The struct held provides access to the design metrics of the font scaled
to the font pixel size used by the element.

ChangeLog: Slint Language: Added font-metrics property to `Text` and `TextInput`.

Closes #6047
2024-10-05 17:00:46 +02:00
Daniel Stuart
436efaceea renderer: Use TextWrap enum for text_size function 2024-06-17 23:52:04 -07:00
Daniel Stuart
bac81bf350 Add character wrapping for software renderer
This adds `char-wrap` functionality to the software renderer.
2024-06-17 23:52:04 -07:00
Aurindam Jana
3523e86359
Simplify commercial license (#3063)
Base the commercial license on the Royalty-free license adding clauses pertaining to the fees.
2024-05-31 14:06:17 +02:00
Aurindam Jana
9a3aa265d5
Update Royalty-free license (#5257)
Add clarification that Application may not expose Slint APIs.
2024-05-31 10:53:19 +02:00
Aurindam Jana
0cfeec1a31
Update Slint Community License (#4994)
Updated the version from 1.1 to 1.2 
Renamed the header to "Slint Royalty-free Desktop, Mobile, and Web Applications License"
Added definition of "Mobile Application" and grant of right
Moved "Limitations" to 3rd section and "License Conditions - Attributions" to 2nd section
Added flexibility to choose between showing "MadeWithSlint" as a dialog/splash screen or on a public webpage
Moved the para on copyright notices to section under "Limitations"
2024-04-15 15:18:55 +02:00
Tobias Hunger
77c85aa703 janitor: fix clippy warnings about "bound is defined in more than one place" 2024-03-14 13:42:38 +01:00
Tobias Hunger
a8f912900b janitor: Fix warnings in nightly about redandant use 2024-02-19 17:05:21 +01:00
Olivier Goffart
3a807e46c1
Renderer feature refactor 2023-07-27 19:11:24 +02:00
Aurindam Jana
5a4a7fee63
Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
Olivier Goffart
11dea135f7 Domain: slint-ui.com -> slint.dev 2023-06-16 10:55:08 +02:00
Aurindam Jana
039e54a5de
Add royalty free license to files except examples and docs (#2888) 2023-06-15 11:20:50 +02:00
Simon Hausmann
6b8214c3f9 Add support for italic and bold text in the software renderer's bitmap font path
In the screenshot tests this works by setting SLINT_DEFAULT_FONT to
pointer to a directory, instead of a file. We then load all fonts in
that directory and consider their families the default unless a family
is specified. This way for "Noto Sans" a regular as well as an italic
version is registered in fontdb and returned in the list of font
fallback ids. embed_glyphs in the compiler then embeds those variants
and we find them at run-time.
2023-05-31 18:47:39 +02:00
Simon Hausmann
057493b3a9 Add support for italic text in the software renderer's vector font path
Centralize also fontdb::Query creation and family fallback handling in
sharedfontdb. This way SLINT_DEFAULT_FONT also works for the femtovg
renderer.
2023-05-31 18:47:39 +02:00
Simon Hausmann
b38df20d9a Add a feature to enable system fonts with the software renderer
If we have a file system, then we can allow users of the software
renderer to support text rendering by from fonts served by the file
system.

cc #2100
2023-03-28 11:33:44 +02:00
Simon Hausmann
143a1881f1 software renderer: prefer bitmap fonts over vector fonts
Change the font selection in the software renderer to always prefer
embedded bitmap fonts. This way when running `cargo test -p
test-driver-screenshots` the pixel fonts are used (as before this patch)
as well as in the CI, when all features are enabled (including
"systemfonts").

This originates from #2141
2023-01-30 11:38:41 +01:00
Simon Hausmann
bf8187fed1 Cache glyphs rendered from truetype fonts
and cache the fontdue::Font as well, since that's also slow to create.
2022-12-16 18:20:12 +01:00
Simon Hausmann
2b7d4e7793 Basic implementation of the last resort font fallback for fontdb 2022-12-16 18:20:12 +01:00
Simon Hausmann
d92c49e09c Separate pixel and vector fonts into modules of their own 2022-12-16 18:20:12 +01:00
Simon Hausmann
dee1b11a83 Initial support for truetype fonts in the software renderer
This works, but it's super slow as for every glyph the font is loaded
again and the glyphs are rasterized every time they're drawn.
2022-12-16 18:20:12 +01:00
Simon Hausmann
7cf312667e Remove internal duplicated FontMetrics trait
There's also one in the textlayout module and this was is just confusing as a trait.
2022-12-16 18:20:12 +01:00
Simon Hausmann
d69b4b81ba Simplify glyph handling in the software renderer
Remove platform glyph abstraction, just use non-zero u16 as glyph index
like everyone else.  As a bonus, this reduces the memory consumption of
the glyph buffers per glyph from a size of a pointer to the size of the
u16.
2022-12-16 18:20:12 +01:00
Simon Hausmann
39121994ca Always set Window.default-font-size
Permit the style metrics to provide a `default-font-size` and bind that
to the `Window` if set. If not provided, then the backend can set a
`default-font-size`. By ensuring that the value is non-zero at run-time,
we can later introduce a rem unit that can act as factor relative to
this non-zero font size.
2022-11-03 17:15:44 +01:00
Simon Hausmann
37a8c50c12 Simplify FontRequest
It doesn't have to be generic as mostly the frontend code creates it with logical lengths.
2022-09-30 23:31:32 +02:00
Simon Hausmann
a52d633b59 Change FontRequest to be a generic over the length
The API uses a logical length for pixel sizes and letter spacing,
but the renderer will need the physical length eventually.
2022-09-30 13:00:37 +02:00
Simon Hausmann
1624a66ebc Change the Renderer trait's text related functions to explicitly operate on logical lengths 2022-09-30 13:00:37 +02:00
Simon Hausmann
d698af5326 Move physical length definitions into the software renderer
Their choice of i16 is specific to the software renderer. In say the Skia renderer
the physical coordinate space would still use Skia's Scalar (floating points).
2022-09-30 09:03:02 +02:00
Olivier Goffart
1ba4450115 Apply suggestions from code review
Co-authored-by: Simon Hausmann <simon.hausmann@slint-ui.com>
2022-09-07 17:11:57 +02:00
Olivier Goffart
abbf1edd91 Better error message when using the software renderer with a .slint file not compiled for it 2022-09-07 17:11:57 +02:00
Tobias Hunger
639dcaf702 api: Rename module swrenderer to software_renderer
Also rename the `swrenderer` feature to `software-renderer`.
2022-09-07 10:11:11 +02:00
Renamed from internal/core/swrenderer/fonts.rs (Browse further)