summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2015-08-20 15:40:40 +0300
committerTor Lillqvist <tml@collabora.com>2015-08-20 16:04:34 +0300
commit6cbdaed5b27e803be7b6190ca3f92698c48ac6e9 (patch)
tree1f66fa49cede86149d93c96639981498dba89ba6 /vcl
parentf4fb9bec728a5e1ccd8466efa4d60f429478cefa (diff)
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
Diffstat (limited to 'vcl')
-rw-r--r--vcl/win/source/gdi/winlayout.cxx7
1 files changed, 6 insertions, 1 deletions
diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx
index 315d9834d934..d445506204d5 100644
--- a/vcl/win/source/gdi/winlayout.cxx
+++ b/vcl/win/source/gdi/winlayout.cxx
@@ -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];