[Libreoffice-commits] core.git: vcl/inc vcl/source
Chris Sherlock
chris.sherlock79 at gmail.com
Fri Jan 1 07:05:48 PST 2016
vcl/inc/PhysicalFontFace.hxx | 16 +++++++++++-----
vcl/source/font/PhysicalFontFace.cxx | 32 ++++++++++++++------------------
vcl/source/font/PhysicalFontFamily.cxx | 3 ++-
3 files changed, 27 insertions(+), 24 deletions(-)
New commits:
commit b890a0ed02968589029fedf1854be83f1ffe8600
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date: Fri Jan 1 22:38:29 2016 +1100
Revert "vcl: Get rid of FontMatchStatus structure"
This reverts commit 60676b3b376d5f3f6fb29fa68c34117c2149bbec.
The FontMapStatus structure is passed as a reference to save the
search state outside of the search loop in
PhysicalFontFamily::FindBestFontFace.
This *looked* like it would be an easy win, evidently not! Back to
the drawing board.
Change-Id: Icc7078543e50bc34221127d8df055f056e249cdb
diff --git a/vcl/inc/PhysicalFontFace.hxx b/vcl/inc/PhysicalFontFace.hxx
index 4c3704c..bb0b900 100644
--- a/vcl/inc/PhysicalFontFace.hxx
+++ b/vcl/inc/PhysicalFontFace.hxx
@@ -25,9 +25,19 @@
#include "outfont.hxx"
class ImplFontEntry;
+struct FontMatchStatus;
class FontSelectPattern;
class PhysicalFontFamily;
+struct FontMatchStatus
+{
+public:
+ int mnFaceMatch;
+ int mnHeightMatch;
+ int mnWidthMatch;
+ const OUString* mpTargetStyleName;
+};
+
// - PhysicalFontFace -
// TODO: no more direct access to members
@@ -68,11 +78,7 @@ public:
bool IsScalable() const { return (mnHeight == 0); }
bool CheckMagic( int n ) const { return (n == mnMagic); }
- bool IsBetterMatch( const FontSelectPattern& rFSD,
- const OUString* pTargetStyleName,
- int nStatusFaceMatch=0,
- int nStatusHeightMatch=0,
- int nStatusWidthMatch=0 ) const;
+ bool IsBetterMatch( const FontSelectPattern&, FontMatchStatus& ) const;
sal_Int32 CompareWithSize( const PhysicalFontFace& ) const;
sal_Int32 CompareIgnoreSize( const PhysicalFontFace& ) const;
virtual ~PhysicalFontFace() {}
diff --git a/vcl/source/font/PhysicalFontFace.cxx b/vcl/source/font/PhysicalFontFace.cxx
index 5383e36..c7c7ee2 100644
--- a/vcl/source/font/PhysicalFontFace.cxx
+++ b/vcl/source/font/PhysicalFontFace.cxx
@@ -84,11 +84,7 @@ sal_Int32 PhysicalFontFace::CompareWithSize( const PhysicalFontFace& rOther ) co
return 0;
}
-bool PhysicalFontFace::IsBetterMatch( const FontSelectPattern& rFSD,
- const OUString* pTargetStyleName,
- int nStatusFaceMatch,
- int nStatusHeightMatch,
- int nStatusWidthMatch ) const
+bool PhysicalFontFace::IsBetterMatch( const FontSelectPattern& rFSD, FontMatchStatus& rStatus ) const
{
int nMatch = 0;
@@ -96,8 +92,8 @@ bool PhysicalFontFace::IsBetterMatch( const FontSelectPattern& rFSD,
if( rFontName.equalsIgnoreAsciiCase( GetFamilyName() ) )
nMatch += 240000;
- if( pTargetStyleName
- && GetStyleName().equalsIgnoreAsciiCase( *pTargetStyleName ) )
+ if( rStatus.mpTargetStyleName
+ && GetStyleName().equalsIgnoreAsciiCase( *rStatus.mpTargetStyleName ) )
nMatch += 120000;
if( (rFSD.GetPitch() != PITCH_DONTKNOW) && (rFSD.GetPitch() == GetPitch()) )
@@ -202,31 +198,31 @@ bool PhysicalFontFace::IsBetterMatch( const FontSelectPattern& rFSD,
}
}
- if( nStatusFaceMatch > nMatch )
+ if( rStatus.mnFaceMatch > nMatch )
return false;
- else if( nStatusFaceMatch < nMatch )
+ else if( rStatus.mnFaceMatch < nMatch )
{
- nStatusFaceMatch = nMatch;
- nStatusHeightMatch = nHeightMatch;
- nStatusWidthMatch = nWidthMatch;
+ rStatus.mnFaceMatch = nMatch;
+ rStatus.mnHeightMatch = nHeightMatch;
+ rStatus.mnWidthMatch = nWidthMatch;
return true;
}
// when two fonts are still competing prefer the
// one with the best matching height
- if( nStatusHeightMatch > nHeightMatch )
+ if( rStatus.mnHeightMatch > nHeightMatch )
return false;
- else if( nStatusHeightMatch < nHeightMatch )
+ else if( rStatus.mnHeightMatch < nHeightMatch )
{
- nStatusHeightMatch = nHeightMatch;
- nStatusWidthMatch = nWidthMatch;
+ rStatus.mnHeightMatch = nHeightMatch;
+ rStatus.mnWidthMatch = nWidthMatch;
return true;
}
- if( nStatusWidthMatch > nWidthMatch )
+ if( rStatus.mnWidthMatch > nWidthMatch )
return false;
- nStatusWidthMatch = nWidthMatch;
+ rStatus.mnWidthMatch = nWidthMatch;
return true;
}
diff --git a/vcl/source/font/PhysicalFontFamily.cxx b/vcl/source/font/PhysicalFontFamily.cxx
index cc01487..8cc691b 100644
--- a/vcl/source/font/PhysicalFontFamily.cxx
+++ b/vcl/source/font/PhysicalFontFamily.cxx
@@ -229,10 +229,11 @@ PhysicalFontFace* PhysicalFontFamily::FindBestFontFace( const FontSelectPattern&
// TODO: linear search improve!
PhysicalFontFace* pBestFontFace = maFontFaces[0];
+ FontMatchStatus aFontMatchStatus = {0,0,0, pTargetStyleName};
for( std::vector< PhysicalFontFace* >::const_iterator it=maFontFaces.begin(); it != maFontFaces.end(); ++it )
{
PhysicalFontFace* pFoundFontFace = *it;
- if( pFoundFontFace->IsBetterMatch( rFSD, pTargetStyleName ) )
+ if( pFoundFontFace->IsBetterMatch( rFSD, aFontMatchStatus ) )
pBestFontFace = pFoundFontFace;
}
More information about the Libreoffice-commits
mailing list