[Development] QFontMetrics and QScriptLine height calculation

Rafael Roquetto rafael.roquetto at kdab.com
Thu Oct 4 22:22:46 CEST 2012


I am trying to fix tst_QAccessibility for QNX, and I have a problem on line

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,

** Qt Developer Conference: http://qtconference.kdab.com/ **

Rafael Roquetto | rafael.roquetto at kdab.com | Software Engineer
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - Qt Experts - Platform-independent software solutions

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3721 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20121004/eda9aac9/attachment.bin>

More information about the Development mailing list