vcl/inc/win/salgdi.h | 11 -------- vcl/win/source/gdi/salgdi.cxx | 5 --- vcl/win/source/gdi/salgdi3.cxx | 40 ------------------------------- vcl/win/source/gdi/winlayout.cxx | 49 ++++----------------------------------- 4 files changed, 7 insertions(+), 98 deletions(-)
New commits: commit f1dec3a397393639da58585f834cc8d4d9409989 Author: Tor Lillqvist <t...@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]; commit 4f9262c87d707f220d640ad513264e8f67ae9761 Author: Tor Lillqvist <t...@collabora.com> Date: Thu Aug 20 13:37:13 2015 +0300 Drop code that is dead after 4667db065d34193d99bce82f7e8f3b20a03ecade Change-Id: Id023b43e901b0e41ebf3b208c6e80fd023bf7f9a diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index a700fac..f499a31 100644 --- a/vcl/inc/win/salgdi.h +++ b/vcl/inc/win/salgdi.h @@ -214,9 +214,6 @@ private: RGNDATA* mpClipRgnData; // ClipRegion-Data RGNDATA* mpStdClipRgnData; // Cache Standard-ClipRegion-Data ImplFontAttrCache* mpFontAttrCache; // Cache font attributes from files in so/share/fonts - bool mbFontKernInit; // FALSE: FontKerns must be queried - KERNINGPAIR* mpFontKernPairs; // Kerning Pairs of the current Font - sal_uIntPtr mnFontKernPairCount;// Number of Kerning Pairs of the current Font int mnPenWidth; // Linienbreite public: @@ -336,12 +333,6 @@ protected: const SalBitmap* pAlphaBitmap) SAL_OVERRIDE; virtual bool drawAlphaRect( long nX, long nY, long nWidth, long nHeight, sal_uInt8 nTransparency ) SAL_OVERRIDE; -private: - // local helpers - - // get kernign pairs of the current font - sal_uLong GetKernPairs(); - public: // public SalGraphics methods, the interface to the independent vcl part @@ -470,7 +461,7 @@ void ImplGetLogFontFromFontSelect( HDC, const FontSelectPattern*, #define MAX_64KSALPOINTS ((((sal_uInt16)0xFFFF)-8)/sizeof(POINTS)) // #102411# Win's GCP mishandles kerning => we need to do it ourselves -// SalGraphicsData::mpFontKernPairs is sorted by +// kerning pairs is sorted by inline bool ImplCmpKernData( const KERNINGPAIR& a, const KERNINGPAIR& b ) { if( a.wFirst < b.wFirst ) diff --git a/vcl/win/source/gdi/salgdi.cxx b/vcl/win/source/gdi/salgdi.cxx index 23d4e5c..64d4952 100644 --- a/vcl/win/source/gdi/salgdi.cxx +++ b/vcl/win/source/gdi/salgdi.cxx @@ -634,9 +634,6 @@ WinSalGraphics::WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND hW mhDefPal(0), mpStdClipRgnData(NULL), mpFontAttrCache(NULL), - mpFontKernPairs(NULL), - mnFontKernPairCount(0), - mbFontKernInit(false), mnPenWidth(GSL_PEN_WIDTH) { if (OpenGLHelper::isVCLOpenGLEnabled() && !mbPrinter) @@ -666,8 +663,6 @@ WinSalGraphics::~WinSalGraphics() // delete cache data delete [] mpStdClipRgnData; - - delete [] mpFontKernPairs; } SalGraphicsImpl* WinSalGraphics::GetImpl() const diff --git a/vcl/win/source/gdi/salgdi3.cxx b/vcl/win/source/gdi/salgdi3.cxx index c70d868..419fa26a 100644 --- a/vcl/win/source/gdi/salgdi3.cxx +++ b/vcl/win/source/gdi/salgdi3.cxx @@ -1559,17 +1559,6 @@ sal_uInt16 WinSalGraphics::SetFont( FontSelectPattern* pFont, int nFallbackLevel if( mpWinFontData[ nFallbackLevel ] ) mpWinFontData[ nFallbackLevel ]->UpdateFromHDC( getHDC() ); - if( !nFallbackLevel ) - { - mbFontKernInit = TRUE; - if ( mpFontKernPairs ) - { - delete[] mpFontKernPairs; - mpFontKernPairs = NULL; - } - mnFontKernPairCount = 0; - } - // some printers have higher internal resolution, so their // text output would be different from what we calculated // => suggest DrawTextArray to workaround this problem @@ -1655,35 +1644,6 @@ void WinSalGraphics::GetFontMetric( ImplFontMetricData* pMetric, int nFallbackLe pMetric->mnMinKashida = GetMinKashidaWidth(); } -sal_uLong WinSalGraphics::GetKernPairs() -{ - if ( mbFontKernInit ) - { - if( mpFontKernPairs ) - { - delete[] mpFontKernPairs; - mpFontKernPairs = NULL; - } - mnFontKernPairCount = 0; - - KERNINGPAIR* pPairs = NULL; - int nCount = ::GetKerningPairsW( getHDC(), 0, NULL ); - if( nCount ) - { - pPairs = new KERNINGPAIR[ nCount+1 ]; - mpFontKernPairs = pPairs; - mnFontKernPairCount = nCount; - ::GetKerningPairsW( getHDC(), nCount, pPairs ); - } - - mbFontKernInit = FALSE; - - std::sort( mpFontKernPairs, mpFontKernPairs + mnFontKernPairCount, ImplCmpKernData ); - } - - return mnFontKernPairCount; -} - const FontCharMapPtr WinSalGraphics::GetFontCharMap() const { if( !mpWinFontData[0] ) diff --git a/vcl/win/source/gdi/winlayout.cxx b/vcl/win/source/gdi/winlayout.cxx index c1c2d7e..315d983 100644 --- a/vcl/win/source/gdi/winlayout.cxx +++ b/vcl/win/source/gdi/winlayout.cxx @@ -77,14 +77,6 @@ private: // TODO: also add HFONT??? Watch out for issues with too many active fonts... public: - bool HasKernData() const; - void SetKernData( int, const KERNINGPAIR* ); - int GetKerning( sal_Unicode, sal_Unicode ) const; -private: - KERNINGPAIR* mpKerningPairs; - int mnKerningPairs; - -public: SCRIPT_CACHE& GetScriptCache() const { return maScriptCache; } private: @@ -2426,8 +2418,6 @@ int WinSalGraphics::GetMinKashidaWidth() ImplWinFontEntry::ImplWinFontEntry( FontSelectPattern& rFSD ) : ImplFontEntry( rFSD ) -, mpKerningPairs( NULL ) -, mnKerningPairs( -1 ) , maWidthMap( 512 ) , mnMinKashidaWidth( -1 ) , mnMinKashidaGlyph( -1 ) @@ -2439,38 +2429,6 @@ ImplWinFontEntry::~ImplWinFontEntry() { if( maScriptCache != NULL ) ScriptFreeCache( &maScriptCache ); - delete[] mpKerningPairs; -} - -bool ImplWinFontEntry::HasKernData() const -{ - return (mnKerningPairs >= 0); -} - -void ImplWinFontEntry::SetKernData( int nPairCount, const KERNINGPAIR* pPairData ) -{ - mnKerningPairs = nPairCount; - mpKerningPairs = new KERNINGPAIR[ mnKerningPairs ]; - memcpy( mpKerningPairs, (const void*)pPairData, nPairCount*sizeof(KERNINGPAIR) ); -} - -int ImplWinFontEntry::GetKerning( sal_Unicode cLeft, sal_Unicode cRight ) const -{ - int nKernAmount = 0; - if( mpKerningPairs ) - { - const KERNINGPAIR aRefPair = { cLeft, cRight, 0 }; - const KERNINGPAIR* pFirstPair = mpKerningPairs; - const KERNINGPAIR* pEndPair = mpKerningPairs + mnKerningPairs; - const KERNINGPAIR* pPair = std::lower_bound( pFirstPair, - pEndPair, aRefPair, ImplCmpKernData ); - if( (pPair != pEndPair) - && (pPair->wFirst == aRefPair.wFirst) - && (pPair->wSecond == aRefPair.wSecond) ) - nKernAmount = pPair->iKernAmount; - } - - return nKernAmount; } bool ImplWinFontEntry::InitKashidaHandling( HDC hDC ) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits