Kaydet (Commit) 1b7e788e authored tarafından Khaled Hosny's avatar Khaled Hosny

The mfFontScale[n] is always 1.0

Change-Id: Ica2e67632f5bfe1f70ba7b2d7502257b47d053ce
Reviewed-on: https://gerrit.libreoffice.org/32592Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarKhaled Hosny <khaledhosny@eglug.org>
üst 7633cbb0
...@@ -166,8 +166,6 @@ private: ...@@ -166,8 +166,6 @@ private:
HFONT mhFonts[ MAX_FALLBACK ]; // Font + Fallbacks HFONT mhFonts[ MAX_FALLBACK ]; // Font + Fallbacks
const WinFontFace* mpWinFontData[ MAX_FALLBACK ]; // pointer to the most recent font face const WinFontFace* mpWinFontData[ MAX_FALLBACK ]; // pointer to the most recent font face
WinFontInstance* mpWinFontEntry[ MAX_FALLBACK ]; // pointer to the most recent font instance 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 HRGN mhRegion; // vcl::Region Handle
HPEN mhDefPen; // DefaultPen HPEN mhDefPen; // DefaultPen
HBRUSH mhDefBrush; // DefaultBrush HBRUSH mhDefBrush; // DefaultBrush
...@@ -207,7 +205,7 @@ public: ...@@ -207,7 +205,7 @@ public:
HWND gethWnd(); HWND gethWnd();
HFONT ImplDoSetFont( FontSelectPattern* i_pFont, float& o_rFontScale, HFONT& o_rOldFont ); HFONT ImplDoSetFont( FontSelectPattern* i_pFont, HFONT& o_rOldFont );
public: public:
explicit WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND hWnd, explicit WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND hWnd,
......
...@@ -836,8 +836,9 @@ void ImplGetLogFontFromFontSelect( HDC hDC, ...@@ -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; HFONT hNewFont = nullptr;
HDC hdcScreen = nullptr; HDC hdcScreen = nullptr;
...@@ -853,19 +854,19 @@ HFONT WinSalGraphics::ImplDoSetFont( FontSelectPattern* i_pFont, float& o_rFontS ...@@ -853,19 +854,19 @@ HFONT WinSalGraphics::ImplDoSetFont( FontSelectPattern* i_pFont, float& o_rFontS
if( (-aLogFont.lfHeight <= MAXFONTHEIGHT) if( (-aLogFont.lfHeight <= MAXFONTHEIGHT)
&& (+aLogFont.lfWidth <= MAXFONTHEIGHT) ) && (+aLogFont.lfWidth <= MAXFONTHEIGHT) )
{ {
o_rFontScale = 1.0; fFontScale = 1.0;
} }
else if( -aLogFont.lfHeight >= +aLogFont.lfWidth ) else if( -aLogFont.lfHeight >= +aLogFont.lfWidth )
{ {
o_rFontScale = -aLogFont.lfHeight / (float)MAXFONTHEIGHT; fFontScale = -aLogFont.lfHeight / (float)MAXFONTHEIGHT;
aLogFont.lfHeight = -MAXFONTHEIGHT; aLogFont.lfHeight = -MAXFONTHEIGHT;
aLogFont.lfWidth = FRound( aLogFont.lfWidth / o_rFontScale ); aLogFont.lfWidth = FRound( aLogFont.lfWidth / fFontScale );
} }
else // #i95867# also limit font widths else // #i95867# also limit font widths
{ {
o_rFontScale = +aLogFont.lfWidth / (float)MAXFONTHEIGHT; fFontScale = +aLogFont.lfWidth / (float)MAXFONTHEIGHT;
aLogFont.lfWidth = +MAXFONTHEIGHT; aLogFont.lfWidth = +MAXFONTHEIGHT;
aLogFont.lfHeight = FRound( aLogFont.lfHeight / o_rFontScale ); aLogFont.lfHeight = FRound( aLogFont.lfHeight / fFontScale );
} }
hNewFont = ::CreateFontIndirectW( &aLogFont ); hNewFont = ::CreateFontIndirectW( &aLogFont );
...@@ -905,7 +906,6 @@ void WinSalGraphics::SetFont( FontSelectPattern* pFont, int nFallbackLevel ) ...@@ -905,7 +906,6 @@ void WinSalGraphics::SetFont( FontSelectPattern* pFont, int nFallbackLevel )
// deselect still active font // deselect still active font
if( mhDefFont ) if( mhDefFont )
::SelectFont( getHDC(), mhDefFont ); ::SelectFont( getHDC(), mhDefFont );
mfCurrentFontScale = mfFontScale[nFallbackLevel];
// release no longer referenced font handles // release no longer referenced font handles
for( int i = nFallbackLevel; i < MAX_FALLBACK; ++i ) for( int i = nFallbackLevel; i < MAX_FALLBACK; ++i )
{ {
...@@ -938,8 +938,7 @@ void WinSalGraphics::SetFont( FontSelectPattern* pFont, int nFallbackLevel ) ...@@ -938,8 +938,7 @@ void WinSalGraphics::SetFont( FontSelectPattern* pFont, int nFallbackLevel )
mpWinFontData[ nFallbackLevel ] = static_cast<const WinFontFace*>( pFont->mpFontData ); mpWinFontData[ nFallbackLevel ] = static_cast<const WinFontFace*>( pFont->mpFontData );
HFONT hOldFont = nullptr; HFONT hOldFont = nullptr;
HFONT hNewFont = ImplDoSetFont( pFont, mfFontScale[ nFallbackLevel ], hOldFont ); HFONT hNewFont = ImplDoSetFont(pFont, hOldFont);
mfCurrentFontScale = mfFontScale[nFallbackLevel];
if( !mhDefFont ) if( !mhDefFont )
{ {
...@@ -1000,7 +999,7 @@ void WinSalGraphics::GetFontMetric( ImplFontMetricDataRef& rxFontMetric, int nFa ...@@ -1000,7 +999,7 @@ void WinSalGraphics::GetFontMetric( ImplFontMetricDataRef& rxFontMetric, int nFa
rxFontMetric->SetSlant( 0 ); rxFontMetric->SetSlant( 0 );
// transformation dependent font metrics // 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> rHhea(aHheaRawData.get(), aHheaRawData.get() + aHheaRawData.size());
const std::vector<uint8_t> rOS2(aOS2RawData.get(), aOS2RawData.get() + aOS2RawData.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 ...@@ -1370,10 +1369,8 @@ bool WinSalGraphics::GetGlyphBoundRect(const GlyphItem& rGlyph, Rectangle& rRect
rRect = Rectangle( Point( +aGM.gmptGlyphOrigin.x, -aGM.gmptGlyphOrigin.y ), rRect = Rectangle( Point( +aGM.gmptGlyphOrigin.x, -aGM.gmptGlyphOrigin.y ),
Size( aGM.gmBlackBoxX, aGM.gmBlackBoxY ) ); Size( aGM.gmBlackBoxX, aGM.gmBlackBoxY ) );
rRect.Left() = static_cast<int>( mfCurrentFontScale * rRect.Left() ); rRect.Right() += 1;
rRect.Right() = static_cast<int>( mfCurrentFontScale * rRect.Right() ) + 1; rRect.Bottom() += 1;
rRect.Top() = static_cast<int>( mfCurrentFontScale * rRect.Top() );
rRect.Bottom() = static_cast<int>( mfCurrentFontScale * rRect.Bottom() ) + 1;
return true; return true;
} }
...@@ -1550,7 +1547,7 @@ bool WinSalGraphics::GetGlyphOutline(const GlyphItem& rGlyph, ...@@ -1550,7 +1547,7 @@ bool WinSalGraphics::GetGlyphOutline(const GlyphItem& rGlyph,
// rescaling needed for the tools::PolyPolygon conversion // rescaling needed for the tools::PolyPolygon conversion
if( rB2DPolyPoly.count() ) if( rB2DPolyPoly.count() )
{ {
const double fFactor(mfCurrentFontScale/256); const double fFactor(1.0/256);
rB2DPolyPoly.transform(basegfx::tools::createScaleB2DHomMatrix(fFactor, fFactor)); rB2DPolyPoly.transform(basegfx::tools::createScaleB2DHomMatrix(fFactor, fFactor));
} }
...@@ -1628,9 +1625,8 @@ bool WinSalGraphics::CreateFontSubset( const OUString& rToFile, ...@@ -1628,9 +1625,8 @@ bool WinSalGraphics::CreateFontSubset( const OUString& rToFile,
// TODO: much better solution: move SetFont and restoration of old font to caller // TODO: much better solution: move SetFont and restoration of old font to caller
ScopedFont aOldFont(*this); ScopedFont aOldFont(*this);
float fScale = 1.0;
HFONT hOldFont = nullptr; HFONT hOldFont = nullptr;
ImplDoSetFont( &aIFSD, fScale, hOldFont ); ImplDoSetFont(&aIFSD, hOldFont);
WinFontFace const * pWinFontData = static_cast<WinFontFace const *>(aIFSD.mpFontData); WinFontFace const * pWinFontData = static_cast<WinFontFace const *>(aIFSD.mpFontData);
...@@ -1777,9 +1773,8 @@ void WinSalGraphics::GetGlyphWidths( const PhysicalFontFace* pFont, ...@@ -1777,9 +1773,8 @@ void WinSalGraphics::GetGlyphWidths( const PhysicalFontFace* pFont,
// TODO: much better solution: move SetFont and restoration of old font to caller // TODO: much better solution: move SetFont and restoration of old font to caller
ScopedFont aOldFont(*this); ScopedFont aOldFont(*this);
float fScale = 0.0;
HFONT hOldFont = nullptr; HFONT hOldFont = nullptr;
ImplDoSetFont( &aIFSD, fScale, hOldFont ); ImplDoSetFont(&aIFSD, hOldFont);
// get raw font file data // get raw font file data
const RawFontData xRawFontData( getHDC() ); const RawFontData xRawFontData( getHDC() );
......
...@@ -608,7 +608,6 @@ WinSalGraphics::WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND hW ...@@ -608,7 +608,6 @@ WinSalGraphics::WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND hW
mbWindow(eType == WinSalGraphics::WINDOW), mbWindow(eType == WinSalGraphics::WINDOW),
mbScreen(bScreen), mbScreen(bScreen),
mhWnd(hWnd), mhWnd(hWnd),
mfCurrentFontScale(1.0),
mhRegion(nullptr), mhRegion(nullptr),
mhDefPen(nullptr), mhDefPen(nullptr),
mhDefBrush(nullptr), mhDefBrush(nullptr),
...@@ -627,7 +626,6 @@ WinSalGraphics::WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND hW ...@@ -627,7 +626,6 @@ WinSalGraphics::WinSalGraphics(WinSalGraphics::Type eType, bool bScreen, HWND hW
mhFonts[ i ] = nullptr; mhFonts[ i ] = nullptr;
mpWinFontData[ i ] = nullptr; mpWinFontData[ i ] = nullptr;
mpWinFontEntry[ i ] = nullptr; mpWinFontEntry[ i ] = nullptr;
mfFontScale[ i ] = 1.0;
} }
} }
......
...@@ -601,8 +601,7 @@ int WinSalGraphics::GetMinKashidaWidth() ...@@ -601,8 +601,7 @@ int WinSalGraphics::GetMinKashidaWidth()
if( !mpWinFontEntry[0] ) if( !mpWinFontEntry[0] )
return 0; return 0;
mpWinFontEntry[0]->InitKashidaHandling( getHDC() ); mpWinFontEntry[0]->InitKashidaHandling( getHDC() );
int nMinKashida = static_cast<int>(mfFontScale[0] * mpWinFontEntry[0]->GetMinKashidaWidth()); return mpWinFontEntry[0]->GetMinKashidaWidth();
return nMinKashida;
} }
LogicalFontInstance * WinSalGraphics::GetWinFontEntry(int const nFallbackLevel) LogicalFontInstance * WinSalGraphics::GetWinFontEntry(int const nFallbackLevel)
......
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