From beede51bca1a43befe42499ad784af57d2450162 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 30 Jan 2020 10:01:09 +0100 Subject: 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 Reviewed-by: Allan Sandfeld Jensen --- .../fontdatabases/windows/qwindowsfontenginedirectwrite.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/platformsupport/fontdatabases') 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, -- cgit v1.2.3