[Libreoffice-commits] core.git: vcl/inc vcl/win

Khaled Hosny khaledhosny at eglug.org
Mon Jan 2 00:23:25 UTC 2017


 vcl/inc/win/salgdi.h      |    4 +---
 vcl/win/gdi/salfont.cxx   |   33 ++++++++++++++-------------------
 vcl/win/gdi/salgdi.cxx    |    2 --
 vcl/win/gdi/winlayout.cxx |    3 +--
 4 files changed, 16 insertions(+), 26 deletions(-)

New commits:
commit 1b7e788eb3bf9cbe56ed5cc4a3fa7fa5e70ac40a
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Sun Jan 1 22:20:22 2017 +0200

    The mfFontScale[n] is always 1.0
    
    Change-Id: Ica2e67632f5bfe1f70ba7b2d7502257b47d053ce
    Reviewed-on: https://gerrit.libreoffice.org/32592
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Khaled Hosny <khaledhosny at eglug.org>

diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 65cf06f..d974e76 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -166,8 +166,6 @@ private:
     HFONT                   mhFonts[ MAX_FALLBACK ];        // Font + Fallbacks
     const WinFontFace*  mpWinFontData[ MAX_FALLBACK ];  // pointer to the most recent font face
     WinFontInstance*       mpWinFontEntry[ MAX_FALLBACK ]; // pointer to the most recent font instance
-    float                   mfFontScale[ MAX_FALLBACK ];        // allows metrics emulation of huge font sizes
-    float                   mfCurrentFontScale;
     HRGN                    mhRegion;           // vcl::Region Handle
     HPEN                    mhDefPen;           // DefaultPen
     HBRUSH                  mhDefBrush;         // DefaultBrush
@@ -207,7 +205,7 @@ public:
 
     HWND gethWnd();
 
-    HFONT                   ImplDoSetFont( FontSelectPattern* i_pFont, float& o_rFontScale, HFONT& o_rOldFont );
+    HFONT                   ImplDoSetFont( FontSelectPattern* i_pFont, HFONT& o_rOldFont );
 
 public:
     explicit WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND hWnd,
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index 6be5acd..b8da03d 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -836,8 +836,9 @@ void ImplGetLogFontFromFontSelect( HDC hDC,
     }
 }
 
-HFONT WinSalGraphics::ImplDoSetFont( FontSelectPattern* i_pFont, float& o_rFontScale, HFONT& o_rOldFont )
+HFONT WinSalGraphics::ImplDoSetFont(FontSelectPattern* i_pFont, HFONT& o_rOldFont)
 {
+    float fFontScale;
     HFONT hNewFont = nullptr;
 
     HDC hdcScreen = nullptr;
@@ -853,19 +854,19 @@ HFONT WinSalGraphics::ImplDoSetFont( FontSelectPattern* i_pFont, float& o_rFontS
     if( (-aLogFont.lfHeight <= MAXFONTHEIGHT)
     &&  (+aLogFont.lfWidth <= MAXFONTHEIGHT) )
     {
-        o_rFontScale = 1.0;
+        fFontScale = 1.0;
     }
     else if( -aLogFont.lfHeight >= +aLogFont.lfWidth )
     {
-        o_rFontScale = -aLogFont.lfHeight / (float)MAXFONTHEIGHT;
+        fFontScale = -aLogFont.lfHeight / (float)MAXFONTHEIGHT;
         aLogFont.lfHeight = -MAXFONTHEIGHT;
-        aLogFont.lfWidth = FRound( aLogFont.lfWidth / o_rFontScale );
+        aLogFont.lfWidth = FRound( aLogFont.lfWidth / fFontScale );
     }
     else // #i95867# also limit font widths
     {
-        o_rFontScale = +aLogFont.lfWidth / (float)MAXFONTHEIGHT;
+        fFontScale = +aLogFont.lfWidth / (float)MAXFONTHEIGHT;
         aLogFont.lfWidth = +MAXFONTHEIGHT;
-        aLogFont.lfHeight = FRound( aLogFont.lfHeight / o_rFontScale );
+        aLogFont.lfHeight = FRound( aLogFont.lfHeight / fFontScale );
     }
 
     hNewFont = ::CreateFontIndirectW( &aLogFont );
@@ -905,7 +906,6 @@ void WinSalGraphics::SetFont( FontSelectPattern* pFont, int nFallbackLevel )
         // deselect still active font
         if( mhDefFont )
             ::SelectFont( getHDC(), mhDefFont );
-        mfCurrentFontScale = mfFontScale[nFallbackLevel];
         // release no longer referenced font handles
         for( int i = nFallbackLevel; i < MAX_FALLBACK; ++i )
         {
@@ -938,8 +938,7 @@ void WinSalGraphics::SetFont( FontSelectPattern* pFont, int nFallbackLevel )
     mpWinFontData[ nFallbackLevel ] = static_cast<const WinFontFace*>( pFont->mpFontData );
 
     HFONT hOldFont = nullptr;
-    HFONT hNewFont = ImplDoSetFont( pFont, mfFontScale[ nFallbackLevel ], hOldFont );
-    mfCurrentFontScale = mfFontScale[nFallbackLevel];
+    HFONT hNewFont = ImplDoSetFont(pFont, hOldFont);
 
     if( !mhDefFont )
     {
@@ -1000,7 +999,7 @@ void WinSalGraphics::GetFontMetric( ImplFontMetricDataRef& rxFontMetric, int nFa
     rxFontMetric->SetSlant( 0 );
 
     // transformation dependent font metrics
-    rxFontMetric->SetWidth( static_cast<int>( mfFontScale[nFallbackLevel] * aWinMetric.tmAveCharWidth ) );
+    rxFontMetric->SetWidth(aWinMetric.tmAveCharWidth);
 
     const std::vector<uint8_t> rHhea(aHheaRawData.get(), aHheaRawData.get() + aHheaRawData.size());
     const std::vector<uint8_t> rOS2(aOS2RawData.get(), aOS2RawData.get() + aOS2RawData.size());
@@ -1370,10 +1369,8 @@ bool WinSalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, Rectangle& rRect
 
     rRect = Rectangle( Point( +aGM.gmptGlyphOrigin.x, -aGM.gmptGlyphOrigin.y ),
         Size( aGM.gmBlackBoxX, aGM.gmBlackBoxY ) );
-    rRect.Left()    = static_cast<int>( mfCurrentFontScale * rRect.Left() );
-    rRect.Right()   = static_cast<int>( mfCurrentFontScale * rRect.Right() ) + 1;
-    rRect.Top()     = static_cast<int>( mfCurrentFontScale * rRect.Top() );
-    rRect.Bottom()  = static_cast<int>( mfCurrentFontScale * rRect.Bottom() ) + 1;
+    rRect.Right()  += 1;
+    rRect.Bottom() += 1;
     return true;
 }
 
@@ -1550,7 +1547,7 @@ bool WinSalGraphics::GetGlyphOutline(const GlyphItem& rGlyph,
     // rescaling needed for the tools::PolyPolygon conversion
     if( rB2DPolyPoly.count() )
     {
-        const double fFactor(mfCurrentFontScale/256);
+        const double fFactor(1.0/256);
         rB2DPolyPoly.transform(basegfx::tools::createScaleB2DHomMatrix(fFactor, fFactor));
     }
 
@@ -1628,9 +1625,8 @@ bool WinSalGraphics::CreateFontSubset( const OUString& rToFile,
 
     // TODO: much better solution: move SetFont and restoration of old font to caller
     ScopedFont aOldFont(*this);
-    float fScale = 1.0;
     HFONT hOldFont = nullptr;
-    ImplDoSetFont( &aIFSD, fScale, hOldFont );
+    ImplDoSetFont(&aIFSD, hOldFont);
 
     WinFontFace const * pWinFontData = static_cast<WinFontFace const *>(aIFSD.mpFontData);
 
@@ -1777,9 +1773,8 @@ void WinSalGraphics::GetGlyphWidths( const PhysicalFontFace* pFont,
     // TODO: much better solution: move SetFont and restoration of old font to caller
     ScopedFont aOldFont(*this);
 
-    float fScale = 0.0;
     HFONT hOldFont = nullptr;
-    ImplDoSetFont( &aIFSD, fScale, hOldFont );
+    ImplDoSetFont(&aIFSD, hOldFont);
 
     // get raw font file data
     const RawFontData xRawFontData( getHDC() );
diff --git a/vcl/win/gdi/salgdi.cxx b/vcl/win/gdi/salgdi.cxx
index 50cfdb7..f8443f0 100644
--- a/vcl/win/gdi/salgdi.cxx
+++ b/vcl/win/gdi/salgdi.cxx
@@ -608,7 +608,6 @@ WinSalGraphics::WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND hW
     mbWindow(eType == WinSalGraphics::WINDOW),
     mbScreen(bScreen),
     mhWnd(hWnd),
-    mfCurrentFontScale(1.0),
     mhRegion(nullptr),
     mhDefPen(nullptr),
     mhDefBrush(nullptr),
@@ -627,7 +626,6 @@ WinSalGraphics::WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND hW
         mhFonts[ i ] = nullptr;
         mpWinFontData[ i ]  = nullptr;
         mpWinFontEntry[ i ] = nullptr;
-        mfFontScale[ i ] = 1.0;
     }
 }
 
diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index b60ce1b..04724d8 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -601,8 +601,7 @@ int    WinSalGraphics::GetMinKashidaWidth()
     if( !mpWinFontEntry[0] )
         return 0;
     mpWinFontEntry[0]->InitKashidaHandling( getHDC() );
-    int nMinKashida = static_cast<int>(mfFontScale[0] * mpWinFontEntry[0]->GetMinKashidaWidth());
-    return nMinKashida;
+    return mpWinFontEntry[0]->GetMinKashidaWidth();
 }
 
 LogicalFontInstance * WinSalGraphics::GetWinFontEntry(int const nFallbackLevel)


More information about the Libreoffice-commits mailing list