summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/fontdatabases
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-01-30 10:01:09 +0100
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2020-02-01 10:04:19 +0100
commitbeede51bca1a43befe42499ad784af57d2450162 (patch)
tree45471d0c90eefe11ef2c113b482537a38795c375 /src/platformsupport/fontdatabases
parentb35dda7ee71fee896f7c2554293fae51b821d1bd (diff)
Fix rendering offset when using DirectWrite engine
When rendering the glyphs into the texture, we need to translate by the margins (this is accounted for later). The visible symptom for this was that when the DirectWrite engine was used all glyphs would be two pixels to the left (which could be seen when placing a cursor at the glyph for instance, and sometimes the edge of the glyph was clipped). Change-Id: Ife72ae8b5663cf43448ae0f8323a459210609b4d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/platformsupport/fontdatabases')
-rw-r--r--src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp
index 5c999f455e..f84ee3dcaa 100644
--- a/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp
+++ b/src/platformsupport/fontdatabases/windows/qwindowsfontenginedirectwrite.cpp
@@ -696,7 +696,7 @@ QImage QWindowsFontEngineDirectWrite::imageForGlyph(glyph_t t,
&transform,
renderMode,
DWRITE_MEASURING_MODE_NATURAL,
- 0.0, 0.0,
+ margin, margin,
&glyphAnalysis
);
@@ -997,6 +997,7 @@ glyph_metrics_t QWindowsFontEngineDirectWrite::alphaMapBoundingBox(glyph_t glyph
DWRITE_RENDERING_MODE renderMode =
hintingPreferenceToRenderingMode(QFont::HintingPreference(fontDef.hintingPreference));
+ const int margin = glyphMargin(QFontEngine::Format_A32);
IDWriteGlyphRunAnalysis *glyphAnalysis = NULL;
HRESULT hr = m_fontEngineData->directWriteFactory->CreateGlyphRunAnalysis(
&glyphRun,
@@ -1004,7 +1005,7 @@ glyph_metrics_t QWindowsFontEngineDirectWrite::alphaMapBoundingBox(glyph_t glyph
&transform,
renderMode,
DWRITE_MEASURING_MODE_NATURAL,
- 0.0, 0.0,
+ margin, margin,
&glyphAnalysis
);
@@ -1013,8 +1014,6 @@ glyph_metrics_t QWindowsFontEngineDirectWrite::alphaMapBoundingBox(glyph_t glyph
glyphAnalysis->GetAlphaTextureBounds(DWRITE_TEXTURE_CLEARTYPE_3x1, &rect);
glyphAnalysis->Release();
- int margin = glyphMargin(QFontEngine::Format_A32);
-
return glyph_metrics_t(rect.left - margin,
rect.top - margin,
rect.right - rect.left + margin * 2,