Commit graph

60 commits

Author SHA1 Message Date
Yuri Astrakhan
5356fdcf89 Fix clippy issues, plus a few manual cleanups
* Run `cargo clippy --fix`
*  `BackendSelector` is easier to instantiate with auto `Default`
2025-02-06 17:28:51 +01:00
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
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
Olivier Goffart
7afec3a1c5 Text layout: fix char-wrap doesn't wrap between lines
Fixes #6346

ChangeLog: Software renderer: fixed `char-wrap` not braking between lines
2024-09-27 13:29:45 +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
a8f912900b janitor: Fix warnings in nightly about redandant use 2024-02-19 17:05:21 +01:00
Tobias Hunger
b12575a4c4 janitor: Go over our spell checking setup
* Extend the cspell word list
* Remove those extensions from individual source files
* white-list licenses and such as we should not meddle with those
* Fix spelling
2023-10-16 09:01:51 +02:00
J-P Nurmi
c4864d62ff SW: stop breaking lines after reaching the max (elided) lines 2023-10-13 22:14:58 +02:00
J-P Nurmi
6686861523 SW: fix vertical alignment of elided multiline text 2023-10-11 14:35:20 +02:00
Aurindam Jana
5a4a7fee63
Update royalty free license to 1.1 (#2994) 2023-07-10 10:12:11 +02:00
Guilhem Vallat
555e191ab4 remove clippy::needless_borrow warnings 2023-06-30 12:28:13 +02:00
Tobias Hunger
4ab19f3011 Incorporate feedback from code review 2023-06-28 14:22:30 +02:00
Tobias Hunger
e81a3d40f0 Get rid of more clippy warnings
* Configure clippy to not report about type complexity until *much*
  later
* Configure clippy to only complain about more than 10 function
  arguments
* Properly format safety sections
* Allow unnecessary main functions in doctests in the slint API crate
* AccessKit: Move big block of code before if condition
2023-06-28 14:22:30 +02:00
Tobias Hunger
e02c360000 Clippy polish 2023-06-28 14:22:30 +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
328cfc76b6 Move sharedfontdb from core to common
This way it is also accessible to the compiler.
2023-05-23 08:26:03 +02:00
Simon Hausmann
37a21ee13a Move the shared font database to core 2023-05-19 10:40:51 +02:00
Simon Hausmann
97129eb940 FemtoVG renderer: Separate the font database from the font cache
This is done in preparation for moving the database to core.
2023-05-19 10:40:51 +02:00
Simon Hausmann
8ffd17007a textlayout: Fix cursor position calculation when clicking at the end of lines with forced line break
Make sure that the byte ranges of adjancent fragments have no gaps.

Co-authored-by: Florian Blasius <FloVanGH@users.noreply.github.com>
2023-05-17 09:58:45 +02:00
Simon Hausmann
aec8a86c02 textlayout: Fix missing byte range on empty lines
Even for an empty line, we should report a byte range so that clicking into an empty line
can produce a cursor offset.

The previous behavior was covered by an existing test, that's now adjusted.
In addition a new test covers that we report the correct
start also for lines starting with whitespace (non-breaking, that is - regular
breaking whitespace is covered by the line breaker).
2023-05-15 17:15:53 +02:00
Florian Blasius
e25e7cf1b0 swr: implement text_input_byte_offset_for_position
* add byte_offset_for_position to TextParagraphLayout
2023-05-15 13:23:05 +00:00
Simon Hausmann
6ad30c9bd4 Fix cursor_pos_for_byte_offset to return the correct x coordinate when the cursor is within the trailing whitespace of a line
Co-authored-by: Florian Blasius <FloVanGH@users.noreply.github.com>
2023-05-11 10:34:49 +00:00
Simon Hausmann
13697bc63c Implement a line-skipping shortcut for cursor_pos_for_byte_offset() 2023-05-11 10:34:49 +00:00
Olivier Goffart
538dddf953 Update fontdb since resvg depends on the newer one 2023-03-28 15:55:27 +02:00
Simon Hausmann
6d968aa329 Extract the FemtoVG renderer into a separate crate
This will be needed for a future experiment. Unlike the Skia renderer,
which operates on raw window handles, the FemtoVG renderer exposes a
different interface where it assumes that the caller takes care of the
OpenGL context state. This means more boilerplate remains in the winit
backend, including the glutin dependency. The upside is that it will
allow using the FemtoVG renderer in environments without glutin.

In order to work in an environment without fontconfig or memmap, the
crate has two features:

  - fontconfig (set when we anticipate fontconfig to be available at
    run-time and libloading being available at compile time).
  - diskfonts (set when we want to be able to load fonts from disk)

The winit crate enables fontconfig on "Linux" and diskfonts on !wasm.
2023-03-06 11:45:28 +01:00
Olivier Goffart
35c16b9a69 Fix panics in the software renderer system font
Two bugs:
 - There was an extra `* 4` that caused panic when the Text was clipped
 - There was a bug in glyph handling when the text is being split in
   several runs
2023-01-27 12:34:45 +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
6dc67d5b7b janitor: work around rustybuzz version incompatibility
Use the re-export to avoid a version clash for ttf-parser.
2022-10-23 14:36:44 +02:00
Olivier Goffart
ad80e3e5e2 Fix software renderer line breaker without the unicode feature
This change makes the test pass without the unicode feature.

Note that it is not possible to run the test without the unicode feature
unless one changes the Cargo.toml, so I did that locally to run the
tests
2022-09-07 13:49:02 +02:00
Simon Hausmann
90ba9ffa17 Fix "glyph box" in AboutSlint when rendered on MCU
The AboutSlint text has a forced linebreak in it, which becomes a box
glyph on MCUs when the font on the host system doesn't use an empty
glyph but a box glyph for \n.

This patch explicitly excludes glyph clusters from text fragments that
feed into lines that originate from one of the three valid separators:
ascii newline, unicode paragraph and unicode line separators.
2022-09-05 21:42:26 +02:00
Olivier Goffart
398eb68b9e swrenderer textlayout: fix panic when max_with is 0
Because a single glyph wouldn't fit on a line, it would loop forever
2022-08-23 08:19:25 +02:00
Simon Hausmann
27bf9348e6 Rename the backend-gl crate into backend-winit 2022-07-26 17:43:51 +02:00
Simon Hausmann
8056836b1f Fix failing i-slint-core tests
Fix the path to the test font.
2022-07-21 14:48:49 +02:00
Simon Hausmann
dcfb285aa8 Add test for whitespace between fragments that wasn't accounted for 2022-06-17 12:08:45 +02:00
Olivier Goffart
318bb5a56c MCU: Fix width of the text not including whitespaces
When concatenating two fragment, we should account for the trailing whitespace
in the previous fragment in the total width.

This fixes the "l" of "Ink level" not beoing drawn properly in the printer
demo with the partial renderer if the Text item (which is too small as a result
of this bug) does not overlap the dirty region, but part of the text still
need to be drawn outside before it overflows
2022-06-17 12:08:45 +02:00
Simon Hausmann
38abeaec41 text handling: clean up font traits
Separate the text shaping functionality from font metrics by having a
FontMetrics trait next to the TextShaper. AbstractFont is the combining
super trait. This allows eliminating the font height member from
TextParagraphLayout and improving the overall naming of fields and
types.

Finally, this prepares the API for composability of TextShaper for font
fallback handling.
2022-05-16 08:21:14 +02:00
Simon Hausmann
3ce142344a text handling: cleanup
Rename "byte_offset" in the Glyph structure to "text_byte_offset" to make
it clearer that this refers to the original text. Also added docs.
2022-05-16 08:21:14 +02:00
Simon Hausmann
02690bfde6 text handling: added some docs 2022-05-16 08:21:14 +02:00
Simon Hausmann
b6eba63f8e text handling: fix glyph cluster type names
Use the term glyph cluster instead of grapheme where we're dealing with
the glyphs for line breaking. Those may coincide with grapheme
boundaries, but aren't required to.
2022-05-15 12:03:29 +02:00
Simon Hausmann
93b5eda82e text handling: simplify glyph data structure handling
Replace the abstract glyph trait with a glyph struct. That way the text
layout code can operate properly on a struct with fields, instead of on
functions on a trait (some of which returning a mutable reference). The
input is a glyph with offset, advance, etc. - everything needed for the
layout and the output is a position along with the platform specific
glyph data.
2022-05-15 12:03:29 +02:00
Simon Hausmann
99ea6db9d4 text handling: simplify shaper <> glyph relation
Use the Glyph trait also for the byte offset handling, to avoid the use of
tuples.
2022-05-15 12:03:29 +02:00
Simon Hausmann
5f52f18df4 mcu text handling: Add support for letter spacing
This is implemented generically by adjusting the advances on the shape buffer, so that we can
use the same in the future in the GL backend.
2022-05-15 12:03:29 +02:00
Simon Hausmann
a7fb45365d text handling: remove unused advance getter on TextShaper
This is available via GlyphMetrics now.
2022-05-15 11:50:54 +02:00
Simon Hausmann
ba59bd5e52 text handling: simplify grapheme and text fragment iterators
Remove the font reference field anymore as it's not needed anymore and
remove the manual clone implementations. Those were needed because
otherwise the TextShaper trait would have to also support clone - as
[derive(Clone)] imposes that. Now we can impose that just on Glyph and
that's easy and makes sense.
2022-05-15 11:50:37 +02:00
Simon Hausmann
08e27fef4a text handling: move function from TextShaper to glyph trait
This will avoid the need to keep a reference to the TextShaper
around.
2022-05-15 11:50:14 +02:00