Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic in the software renderer with clipped text and scale factor #3059

Merged
merged 4 commits into from
Jul 7, 2023

Commits on Jul 7, 2023

  1. Fix panic in the software renderer with clipped text and scale factor

    We ended rendering glyphs with empty or even negative size, causing
    panics down the line.
    
    I added a way in the screenshot tester to change the scale factor
    
    CC: #2957
    ogoffart committed Jul 7, 2023
    Configuration menu
    Copy the full SHA
    2847c7a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    72512ab View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    ea4ceb1 View commit details
    Browse the repository at this point in the history
  4. swr: Fix panic when drawing clipped text

    In some case, when the clip is, eg on a 0.25 of a pixel, but the offset is 0.75,
    (such that the begining of the glyph starts at 0.5) difference in
    rounding in different computation can result in a width which is one
    pixel bigger than the source image.
    I couldn't reproduce this in a testcase, but this can be reproduced
    while resizing or scrolling through a TextEdit
    
    I think this fixes #2957
    
    The panic fixed by this commit looks like this:
    ```
    thread 'main' panicked at 'index out of bounds: the len is 131 but the index is 131', /home/olivier/slint/internal/core/software_renderer/draw_functions.rs:81:19
    stack backtrace:
       3: i_slint_core::software_renderer::draw_functions::draw_texture_line
                 at ./internal/core/software_renderer/draw_functions.rs:81:19
       4: <i_slint_core::software_renderer::RenderToBuffer<T> as i_slint_core::software_renderer::ProcessScene>::process_shared_image_buffer
                 at ./internal/core/software_renderer.rs:1023:13
       5: i_slint_core::software_renderer::SceneBuilder<T>::draw_text_paragraph::{{closure}}
                 at ./internal/core/software_renderer.rs:1404:37
       6: i_slint_core::textlayout::TextParagraphLayout<Font>::layout_lines::{{closure}}
                 at ./internal/core/textlayout.rs:219:17
    ```
    ogoffart committed Jul 7, 2023
    Configuration menu
    Copy the full SHA
    e1e271a View commit details
    Browse the repository at this point in the history