summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qfontengine_coretext.mm
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2010-12-07 12:53:51 +0100
committerJiang Jiang <jiang.jiang@nokia.com>2010-12-09 13:08:12 +0100
commit43d5a0757d857c2a6694ae81d6b70c04ef876aff (patch)
tree3af54311b8e9e534f0da91bc14c2b879d254798b /src/gui/text/qfontengine_coretext.mm
parentbf3c5942840dc9dadcfa89b26ca46f61d8d79f93 (diff)
Fix boundingBox for raster engine with synthesized italic fonts
We need to account for the extra right side bearing caused by text transform for synthesized italic. Task-number: QTBUG-14803 Reviewed-by: Eskil
Diffstat (limited to 'src/gui/text/qfontengine_coretext.mm')
-rw-r--r--src/gui/text/qfontengine_coretext.mm13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/gui/text/qfontengine_coretext.mm b/src/gui/text/qfontengine_coretext.mm
index dcc8329612..2ae60b15f4 100644
--- a/src/gui/text/qfontengine_coretext.mm
+++ b/src/gui/text/qfontengine_coretext.mm
@@ -50,6 +50,8 @@
QT_BEGIN_NAMESPACE
+static float SYNTHETIC_ITALIC_SKEW = tanf(14 * acosf(0) / 90);
+
QCoreTextFontEngineMulti::QCoreTextFontEngineMulti(const QCFString &name, const QFontDef &fontDef, bool kerning)
: QFontEngineMulti(0)
{
@@ -396,6 +398,9 @@ glyph_metrics_t QCoreTextFontEngine::boundingBox(glyph_t glyph)
glyph_metrics_t ret;
CGGlyph g = glyph;
CGRect rect = CTFontGetBoundingRectsForGlyphs(ctfont, kCTFontHorizontalOrientation, &g, 0, 1);
+ if (synthesisFlags & QFontEngine::SynthesizedItalic) {
+ rect.size.width += rect.size.height * SYNTHETIC_ITALIC_SKEW;
+ }
ret.width = QFixed::fromReal(rect.size.width);
ret.height = QFixed::fromReal(rect.size.height);
ret.x = QFixed::fromReal(rect.origin.x);
@@ -487,7 +492,7 @@ void QCoreTextFontEngine::draw(CGContextRef ctx, qreal x, qreal y, const QTextIt
CGAffineTransformConcat(cgMatrix, oldTextMatrix);
if (synthesisFlags & QFontEngine::SynthesizedItalic)
- cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, -tanf(14 * acosf(0) / 90), 1, 0, 0));
+ cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, -SYNTHETIC_ITALIC_SKEW, 1, 0, 0));
cgMatrix = CGAffineTransformConcat(cgMatrix, transform);
@@ -570,13 +575,11 @@ static void convertCGPathToQPainterPath(void *info, const CGPathElement *element
void QCoreTextFontEngine::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nGlyphs,
QPainterPath *path, QTextItem::RenderFlags)
{
-
CGAffineTransform cgMatrix = CGAffineTransformIdentity;
cgMatrix = CGAffineTransformScale(cgMatrix, 1, -1);
if (synthesisFlags & QFontEngine::SynthesizedItalic)
- cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, -tanf(14 * acosf(0) / 90), 1, 0, 0));
-
+ cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, -SYNTHETIC_ITALIC_SKEW, 1, 0, 0));
for (int i = 0; i < nGlyphs; ++i) {
QCFType<CGPathRef> cgpath = CTFontCreatePathForGlyph(ctfont, glyphs[i], &cgMatrix);
@@ -616,7 +619,7 @@ QImage QCoreTextFontEngine::imageForGlyph(glyph_t glyph, QFixed subPixelPosition
CGAffineTransformConcat(cgMatrix, oldTextMatrix);
if (synthesisFlags & QFontEngine::SynthesizedItalic)
- cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, tanf(14 * acosf(0) / 90), 1, 0, 0));
+ cgMatrix = CGAffineTransformConcat(cgMatrix, CGAffineTransformMake(1, 0, SYNTHETIC_ITALIC_SKEW, 1, 0, 0));
cgMatrix = CGAffineTransformConcat(cgMatrix, transform);