[Libreoffice-commits] core.git: vcl/win
Tor Lillqvist
tml at collabora.com
Thu Aug 20 06:05:44 PDT 2015
vcl/win/source/gdi/winlayout.cxx | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
New commits:
commit 6cbdaed5b27e803be7b6190ca3f92698c48ac6e9
Author: Tor Lillqvist <tml at collabora.com>
Date: Thu Aug 20 15:40:40 2015 +0300
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
diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx
index 315d983..d445506 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];
More information about the Libreoffice-commits
mailing list