Kaydet (Commit) b1a918ae authored tarafından Miklos Vajna's avatar Miklos Vajna

tdf#93838 windows opengl: fix vertical text position in UniscribeLayout

For one, aPos.Y() is meant to be the baseline position of the text.
Based on the MSDN documentation and
<https://www-user.tu-chemnitz.de/~ygu/petzold/ch05c.htm>, that means if
we want to get top position, we have to only extract tmAscent and not
tmInternalLeading.

For another, ImplWinFontEntry::AddChunkOfGlyphs() adds a border of 2
pixels both horizontally and vertically, which means that then we need
to undo that when counting the vertical position, too.

Change-Id: I4ac8e881ea5910662674c2a1b53ece943487ccd9
üst 6a12aecf
...@@ -65,7 +65,7 @@ struct OpenGLGlyphCacheChunk ...@@ -65,7 +65,7 @@ struct OpenGLGlyphCacheChunk
int mnGlyphCount; int mnGlyphCount;
std::vector<Rectangle> maLocation; std::vector<Rectangle> maLocation;
std::shared_ptr<OpenGLTexture> mpTexture; std::shared_ptr<OpenGLTexture> mpTexture;
int mnAscentPlusIntLeading; int mnAscent;
bool mbVertical; bool mbVertical;
}; };
...@@ -303,7 +303,7 @@ bool ImplWinFontEntry::AddChunkOfGlyphs(int nGlyphIndex, const WinLayout& rLayou ...@@ -303,7 +303,7 @@ bool ImplWinFontEntry::AddChunkOfGlyphs(int nGlyphIndex, const WinLayout& rLayou
DeleteDC(hDC); DeleteDC(hDC);
return false; return false;
} }
aChunk.mnAscentPlusIntLeading = aTextMetric.tmAscent + aTextMetric.tmInternalLeading; aChunk.mnAscent = aTextMetric.tmAscent;
LOGFONTW aLogfont; LOGFONTW aLogfont;
if (!GetObjectW(rLayout.mhFont, sizeof(aLogfont), &aLogfont)) if (!GetObjectW(rLayout.mhFont, sizeof(aLogfont), &aLogfont))
...@@ -1755,7 +1755,7 @@ bool UniscribeLayout::DrawCachedGlyphs(SalGraphics& rGraphics) const ...@@ -1755,7 +1755,7 @@ bool UniscribeLayout::DrawCachedGlyphs(SalGraphics& rGraphics) const
{ {
SalTwoRect a2Rects(rChunk.maLocation[n].Left(), rChunk.maLocation[n].Top(), SalTwoRect a2Rects(rChunk.maLocation[n].Left(), rChunk.maLocation[n].Top(),
rChunk.maLocation[n].getWidth(), rChunk.maLocation[n].getHeight(), rChunk.maLocation[n].getWidth(), rChunk.maLocation[n].getHeight(),
nAdvance + aPos.X() + mpGlyphOffsets[i].du - 2, aPos.Y() + mpGlyphOffsets[i].dv - rChunk.mnAscentPlusIntLeading, nAdvance + aPos.X() + mpGlyphOffsets[i].du - 2, aPos.Y() + mpGlyphOffsets[i].dv - rChunk.mnAscent - 2,
rChunk.maLocation[n].getWidth(), rChunk.maLocation[n].getHeight()); // ??? rChunk.maLocation[n].getWidth(), rChunk.maLocation[n].getHeight()); // ???
pImpl->DrawMask(*rChunk.mpTexture, salColor, a2Rects); pImpl->DrawMask(*rChunk.mpTexture, salColor, a2Rects);
} }
......
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