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>
This commit is contained in:
parent
b35dda7ee7
commit
beede51bca
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user