Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-38846

QTextLayout: function xToCursor() returns wrong cursor position for BiDi text with "CursorOnCharacter" option

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • 5.3.1
    • 5.3.0 Beta1
    • GUI: Text handling
    • None
    • 793b7e80083d77b0804a40b5732a8888c9ce5cd8

    Description

      Due excess 'break' in loop, function xToCursor() with "CursorOnCharacter" option for BiDI text returns wrong cursor position (start glyph position) all time.

      string: ﻡﺮﺤﺑًﺍ.ﻡﺮﺤﺑًﺍ.ﻡﺮﺤﺑًﺍ.ﻡﺮﺤﺑًﺍ.ﻡﺮﺤﺑًﺍ.ﻡﺮﺤﺑًﺍ.ﻡﺮﺤﺑًﺍ.ﻡﺮﺤﺑًﺍ.wmv

      xToCursor: CursorBetweenCharacters = 38 | xToCursor:CursorOnCharacter = 0

      QTextLine::xToCursor: i = 0 | start=0, end=56, gs=0, ge=55, item_width=520.000000 | bidiLevel = 1

      QTextLine::xToCursor: glyph_pos = 0 | end = 56 | x = 159.000000 | edge = 520.000000

      It happens due excess 'break' on line 2813

      src/gui/text/qtextlayout.cpp

      2803             if (cpos == QTextLine::CursorOnCharacter) {
      2804                 if (si.analysis.bidiLevel % 2) {
      2805                     pos += item_width;
      2806                     glyph_pos = gs;
      2807                     while (gs <= ge) {
      2808                         if (glyphs.attributes[gs].clusterStart) {
      2809                             if (pos < x)
      2810                                 break;
      2811                             glyph_pos = gs;
      2812                             edge = pos;
      2813                             break;
      2814                         }
      2815                         pos -= glyphs.effectiveAdvance(gs);
      2816                         ++gs;
      2817                     }
      2818                 } else {
      2819                     glyph_pos = gs;
      2820                     while (gs <= ge) {
      2821                         if (glyphs.attributes[gs].clusterStart) {
      2822                             if (pos > x)
      2823                                 break;
      2824                             glyph_pos = gs;
      2825                             edge = pos;
      2826                         }
      2827                         pos += glyphs.effectiveAdvance(gs);
      2828                         ++gs;
      2829                     }
      2830                 }
      
      

      And also variable 'pos' undefined on first cycle of loop

      2748         // has to be in one of the runs
      2749         QFixed pos;
      
      2757         for (int i = 0; i < nItems; ++i) {
      2758             int item = visualOrder[i]+firstItem;
      
      2784             if (pos + item_width < x) {
      2785                 pos += item_width;
      2786                 nchars += end;
      2787                 continue;
      2788             }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            esabraha Eskil Abrahamsen Blomfeldt
            tharkum Andrei Volykhin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes