Skip to content
  • Olivier Goffart's avatar
    swr: Fix panic when drawing clipped text · 4a56531d
    Olivier Goffart 创作于
    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
    ```
    4a56531d