[Development] QFontMetrics and QScriptLine height calculation

Saether Jan-Arve Jan-Arve.Saether at digia.com
Wed Oct 10 15:05:16 CEST 2012


QAccessibleTextInterface::characterRect() is supposed to return the bounding box,
so if it's one pixel too high or something it's not something I would worry about.

The test could therefore be relaxed a bit. 
It should also be improved so that it doesn't just verify the size 
(it currently simply ignores the position, which should have much bigger variation 
 than the size).

I'll see what I can do with it.

Jan Arve

> -----Original Message-----
> From: development-bounces+jan-arve.saether=digia.com at qt-project.org
> [mailto:development-bounces+jan-arve.saether=digia.com at qt-project.org]
> On Behalf Of Rafael Roquetto
> Sent: 4. oktober 2012 22:23
> To: development at qt-project.org
> Subject: [Development] QFontMetrics and QScriptLine height calculation 
> Hello,
> 
> I am trying to fix tst_QAccessibility for QNX, and I have a problem on 
> line 2750:
> 
> QCOMPARE(iface->textInterface()->characterRect(0,
> QAccessible2::RelativeToParent).size(), QSize(fm.width("h"), 
> fm.height()));
> 
> This comparison is failing, because the caracter rect height is bigger 
> than the height returned by QFontMetrics. And...?
> 
> Well, ultimately the height of the character rect comes from 
> QScriptLine::height(). Here is how it is calculated (simplified):
> 
>     height = ascent + descent + 1 (leadingIncluded ? leading :
> QFixed())
> 
> While QFontMetrics does not use 'leading' to compute 'height'
> (simplified):
> 
>     height = ascent + descent + 1
> 
> Which leads to a few questions:
> 
> 1. Is this meant to be like that or is either class implementation 
> incorrect?
> 
> 2. If this is correct, then is the test erroneusly assuming that
> QFontMetrics::height() == QScriptLine::height() for every use case? Or...
> 
> 3. Should the 'leading' be '0' in the context of the test (what 
> happens in Qt built for Linux, but not for QNX)?
> 
> Well, I will continue to investigate it, but since I do not know much 
> about this corner of Qt, I thought it wouldn't hurt to ask :)
> 
> Thanks a lot in advance,
> Rafael
>



More information about the Development mailing list