Kaydet (Commit) 6cbdaed5 authored tarafından Tor Lillqvist's avatar Tor Lillqvist

Adjust for the TA_BASELINE of the DC

The text alignment of DCs is set to TA_BASELINE in
WinSalGraphics::InitGraphics(). In the ScriptTextOut-using old code
path this affects where glyphs are put, so we need to take it into
consideration also in the new code path that uses cached glyph
textures. Adjusting the position up by the ascent plus internal
leading of the font seems to work at least for horizontal scripts.

(We used to bluntly adjust the position up by the height of the glyph
cache texture, which was too much. The glyphs got positioned too high
and the top of tall ones was clipped.)

Change-Id: I86aecd6f3016e14b2f0328555ddfd3129e394c4c
üst f4fb9bec
......@@ -64,6 +64,7 @@ struct OpenGLGlyphCacheChunk
int mnGlyphCount;
std::vector<Rectangle> maLocation;
std::shared_ptr<OpenGLTexture> mpTexture;
int mnAscentPlusIntLeading;
};
// win32 specific physical font instance
......@@ -355,6 +356,10 @@ bool ImplWinFontEntry::AddChunkOfGlyphs(int nGlyphIndex, const WinLayout& rLayou
aChunk.mpTexture = std::unique_ptr<OpenGLTexture>(aDC.getTexture());
TEXTMETRICW aTextMetric;
GetTextMetricsW(aDC.getCompatibleHDC(), &aTextMetric);
aChunk.mnAscentPlusIntLeading = aTextMetric.tmAscent + aTextMetric.tmInternalLeading;
maOpenGLGlyphCache.insert(n, aChunk);
SelectFont(aDC.getCompatibleHDC(), hOrigFont);
......@@ -1667,7 +1672,7 @@ bool UniscribeLayout::DrawCachedGlyphs(SalGraphics& rGraphics) const
SalTwoRect a2Rects(rChunk.maLocation[n].Left(), rChunk.maLocation[n].Top(),
rChunk.maLocation[n].getWidth(), rChunk.maLocation[n].getHeight(),
nAdvance + aPos.X() + mpGlyphOffsets[i].du, aPos.Y() + mpGlyphOffsets[i].dv - rChunk.maLocation[n].getHeight(),
nAdvance + aPos.X() + mpGlyphOffsets[i].du, aPos.Y() + mpGlyphOffsets[i].dv - rChunk.mnAscentPlusIntLeading,
rChunk.maLocation[n].getWidth(), rChunk.maLocation[n].getHeight()); // ???
pImpl->DrawMask(*rChunk.mpTexture, salColor, a2Rects);
nAdvance += mpGlyphAdvances[i];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment