summaryrefslogtreecommitdiff
path: root/vcl/win
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2015-08-20 15:40:40 +0300
committerMichael Meeks <michael.meeks@collabora.com>2015-08-28 12:29:21 +0100
commit4b062fabe992ac9ef1037acb2598973809f161cd (patch)
tree36438e75d9a33c7d6515f792afc25968f562e4bc /vcl/win
parent8e3cf27c919f8eecd8ae2a5e70cee102a5564566 (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 Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
Diffstat (limited to 'vcl/win')
-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];