[QScintilla] wrong cursor moving

Phil Thompson phil at riverbankcomputing.com
Tue Nov 9 18:33:43 GMT 2010


On Mon, 8 Nov 2010 12:01:44 +0100, Petr Vanek <petr at scribus.info> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> 
> On Nov 8, 2010 (Monday), at 12:33 AM, David Hess wrote:
> 
>> On Nov 6, 2010, at 8:50 AM, Petr Vaněk wrote:
>> 
>>> ... snip ...
>>>>> changes if you highlight it via selection.
>>>>> 
>>>>> So it seems not to just be a cursor positioning issue but also a
>>>>> layout
>>>>> problem.
>>>> Out of curiosity, if the patch did...
>>>> 
>>>>   qRound(ceil(width));
>>>> 
>>>> ...is it any better?
>>> 
>>> for me it seems little bit worse with the ceil(). But maybe it's only
>>> due my
>>> tired eyes.
>>> 
>>> Anyway, I can confirm the selection display is somehow wrong - with or
>>> without
>>> the patch as well.
>>> 
>>>> Even if the patch isn't exactly correct, is it a definite
improvement?
>>> 
>>> for me it makes qsci finally usable on mac - at least the cursor is in
>>> the
>>> right place.
>> 
>> It may be the colorizing making the difference for me, but it still
>> seems pretty bad overall. A long line with colorized text will still
put
>> the cursor in the wrong place.
> 
> I think it's not a "colorized" but "font weight/bold" problem.
>> 
>> Poking around inside of Scintilla shows that it uses integer pixel
>> positions which I guess your patch is attempting to deal with?
>> 
>> I did some searching in the Qt bug database and saw this ticket:
>> http://bugreports.qt.nokia.com/browse/QTBUG-11234
>> 
>> It seems that adding:
>> 
>>        f->setStyleStrategy(QFont::ForceIntegerMetrics);
>> 
>> to Font::Create(...) is worth a try?
>> 
>> I'm working with 4.6.2 which doesn't have QFont::ForceIntegerMetrics.
>> Petr are you working with > 4.6.2 and if so can you try that?
> 
> I have 4.7 here. Testing with this patch for PlatQt.cpp:
> 
> - --- PlatQt.cpp  2010-11-08 11:56:59.000000000 +0100
> +++ PlatQt.cpp.orig     2010-08-31 09:49:37.000000000 +0200
> @@ -122,13 +122,6 @@
>      Release();
>  
>      QFont *f = new QFont();
> - -#ifdef Q_WS_MAC
> - -#if QT_VERSION >= 0x040700
> - -    f->setStyleStrategy(QFont::ForceIntegerMetrics);
> - -#else
> - -#warning "Correct handling of the QFont metrics requited Qt>=4.7"
> - -#endif
> - -#endif
>  
>      // If name of the font begins with a '-', assume, that it is an
XLFD.
>      if (faceName[0] == '-')
> 
> - ---
> and it seems it works. Well, the cursor is still 1-2px shifted into the
> glyph itself (comparing linux) but the gap/shift is constant.
> And of course - I'm not sure if I applu the setStyleStrategy in the
right
> place... but as I said it seems to work - including selections in the
> colorized/bold texts.

I've applied the patch - thanks.

Phil


More information about the QScintilla mailing list