Skip to content

Add support for rendering rich text #9560

@tronical

Description

@tronical

This task is derived from #2723 but with a focus solely on providing the APIs to feed attributed text into Slint and rendering, NOT to support the end-user editing said text.

The following feature set for attributes is in scope:

  • Hyperlinks (including way of handling clicks)
  • Text colors
  • Style: Bold, Italic, Underline
  • Unordered/ordered lists

List of things to do before this issue is done:

  • better interpolation handling. The following should work: @markdown("# Foo {}", @markdown("*Bar*")) / @markdown("`{}`", "Some`Code`With`Quote"); (this may mean doing the interpolation as part of the parsing instead of escaping)
  • Document the StyledText element in the language reference (including an inline example with screenshot, as well as what type of styling is supported)
  • C++ Api needs a way of constructing a StyledText from markdown (including a unit test)
  • Make sure the software renderer doesn't panic when rendering a StyledText element
  • A test in tests/cases/elements that constructs a StyledText element in Slint and the styled-text is exposed to Rust and C++, and it can be read and written from Rust and C++. Verify that the preferred-height is greater than zero when a text is set, so that when the test is run, the entire parsing and layout code path as well as the code generator is covered.
  • Produce compile errors when invalid markdown is used with @markdown(). (extend internal/compiler/tests/syntax/basic/markdown.slint)
  • One last API review before the next release.
  • Extend the widgets gallery example to show hyperlinks, text colours, styles (bold/italic/underline) and unordered/ordered lists.
  • Add a test for the StyledText::link-clicked callback. Send a synthetic mouse click in a new or existing test under tests/cases and verify the callback was invoked.
  • Add Slint.open-url(string) function #10513

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    a:textText rendering, fonts, Text input (mS,bF)

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions