summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlasconic <lasconic@gmail.com>2014-09-18 07:44:03 (GMT)
committerAshish Kulkarni <kulkarni.ashish@gmail.com>2014-12-16 04:18:03 (GMT)
commitbf1fce4fc18d09fd640f4c765522737173d4fee5 (patch)
tree03c24328ff5f3027762ed1498433f9c0c30cfa61
parent61379d481a1a9d646c812df010089c6d52d18f31 (diff)
downloadQt-bf1fce4fc18d09fd640f4c765522737173d4fee5.zip
Qt-bf1fce4fc18d09fd640f4c765522737173d4fee5.tar.gz
Qt-bf1fce4fc18d09fd640f4c765522737173d4fee5.tar.bz2
Use metrics returned by GetGlyphOutline in GGO_METRICS mode
GetGlyphOutline Windows API returns wrong values when used with an OpenType PS font and in GGO_NATIVE mode. It causes problem when exporting to PDF. The fix changes the GetGlyphOutline call to use GGO_METRICS instead. Task-number: QTBUG-12799 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com> Change-Id: I38ca46d50e490e3b704a89d08b1a8697bca5f079 (cherry picked from qtbase/4aba2d07d2fe67beaf544a4b38c5b9aa8b8ec39b) Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
-rw-r--r--src/gui/text/qfontengine_win.cpp29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp
index 9852b89..5d0c209 100644
--- a/src/gui/text/qfontengine_win.cpp
+++ b/src/gui/text/qfontengine_win.cpp
@@ -864,13 +864,34 @@ static bool addGlyphToPath(glyph_t glyph, const QFixedPoint &position, HDC hdc,
mat.eM11.fract = mat.eM22.fract = 0;
mat.eM21.value = mat.eM12.value = 0;
mat.eM21.fract = mat.eM12.fract = 0;
+
+ GLYPHMETRICS gMetric;
+ memset(&gMetric, 0, sizeof(GLYPHMETRICS));
+
+#ifndef Q_OS_WINCE
+ if (metric) {
+ // If metrics requested, retrieve first using GGO_METRICS, because the returned
+ // values are incorrect for OpenType PS fonts if obtained at the same time as the
+ // glyph paths themselves (ie. with GGO_NATIVE as the format).
+ uint format = GGO_METRICS;
+ if (ttf)
+ format |= GGO_GLYPH_INDEX;
+ int res = GetGlyphOutline(hdc, glyph, format, &gMetric, 0, 0, &mat);
+ if (res == GDI_ERROR) {
+ return false;
+ }
+ // #### obey scale
+ *metric = glyph_metrics_t(gMetric.gmptGlyphOrigin.x, -gMetric.gmptGlyphOrigin.y,
+ (int)gMetric.gmBlackBoxX, (int)gMetric.gmBlackBoxY,
+ gMetric.gmCellIncX, gMetric.gmCellIncY);
+ }
+#endif
+
uint glyphFormat = GGO_NATIVE;
if (ttf)
glyphFormat |= GGO_GLYPH_INDEX;
- GLYPHMETRICS gMetric;
- memset(&gMetric, 0, sizeof(GLYPHMETRICS));
int bufferSize = GDI_ERROR;
#if !defined(Q_WS_WINCE)
bufferSize = GetGlyphOutline(hdc, glyph, glyphFormat, &gMetric, 0, 0, &mat);
@@ -889,12 +910,14 @@ static bool addGlyphToPath(glyph_t glyph, const QFixedPoint &position, HDC hdc,
return false;
}
- if(metric) {
+#ifdef Q_OS_WINCE
+ if (metric) {
// #### obey scale
*metric = glyph_metrics_t(gMetric.gmptGlyphOrigin.x, -gMetric.gmptGlyphOrigin.y,
(int)gMetric.gmBlackBoxX, (int)gMetric.gmBlackBoxY,
gMetric.gmCellIncX, gMetric.gmCellIncY);
}
+#endif
int offset = 0;
int headerOffset = 0;