Use correct underline thickness on OS X
While the calculated underline thickness would be approximately correct for many fonts and sizes, it was sometimes incorrect, e.g. for 18 pt Helvetica. Found while investigating QTBUG-33708. Change-Id: Ic1d8f2d809c02235d8f15f0414536e04c2a7b844 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
This commit is contained in:
parent
ddef89b323
commit
1d5c29da59
@ -215,6 +215,8 @@ void QCoreTextFontEngine::init()
|
||||
} else
|
||||
avgCharWidth = QFontEngine::averageCharWidth();
|
||||
|
||||
underlineThickness = QFixed::fromReal(CTFontGetUnderlineThickness(ctfont));
|
||||
|
||||
cache_cost = (CTFontGetAscent(ctfont) + CTFontGetDescent(ctfont)) * avgCharWidth.toInt() * 2000;
|
||||
|
||||
// HACK hb_coretext requires both CTFont and CGFont but user_data is only void*
|
||||
@ -757,6 +759,11 @@ bool QCoreTextFontEngine::supportsTransformation(const QTransform &transform) co
|
||||
return false;
|
||||
}
|
||||
|
||||
QFixed QCoreTextFontEngine::lineThickness() const
|
||||
{
|
||||
return underlineThickness;
|
||||
}
|
||||
|
||||
QFontEngine::Properties QCoreTextFontEngine::properties() const
|
||||
{
|
||||
Properties result;
|
||||
|
@ -92,6 +92,8 @@ public:
|
||||
int synthesized() const Q_DECL_OVERRIDE { return synthesisFlags; }
|
||||
bool supportsSubPixelPositions() const Q_DECL_OVERRIDE { return true; }
|
||||
|
||||
QFixed lineThickness() const Q_DECL_OVERRIDE;
|
||||
|
||||
void draw(CGContextRef ctx, qreal x, qreal y, const QTextItemInt &ti, int paintDeviceHeight);
|
||||
|
||||
FaceId faceId() const Q_DECL_OVERRIDE;
|
||||
@ -140,6 +142,7 @@ private:
|
||||
int synthesisFlags;
|
||||
CGAffineTransform transform;
|
||||
QFixed avgCharWidth;
|
||||
QFixed underlineThickness;
|
||||
QFontEngine::FaceId face_id;
|
||||
mutable bool kerningPairsLoaded;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user