summaryrefslogtreecommitdiff
path: root/vcl/source/gdi/outdev3.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-06-19 22:23:33 +0100
committerMichael Meeks <michael.meeks@suse.com>2012-06-25 10:44:27 +0100
commitd122b0f592aaa8af00695109ce2a71f6d8807a96 (patch)
tree864c0dcb44d3fb747f3da0786746cf28cc822229 /vcl/source/gdi/outdev3.cxx
parent3e6d34e4afa67d01a40804e93b6d3f94b09dcc5e (diff)
Resolves: fdo#47636 cache fontconfig font substitutions
But this time cache on *all* properties, not just the name, which doesn't cut it, given the things fontconfig can do, e.g. fdo#41556 (cherry picked from commit 8c023fd645c8b83637ffcde4055886b2e4f94393) Conflicts: vcl/generic/fontmanager/fontsubst.cxx vcl/inc/outfont.hxx vcl/source/gdi/outdev3.cxx Change-Id: Idfc1dbac67b6912e4985570a0b7c6ccdf47fa4a5 Signed-off-by: Michael Meeks <michael.meeks@suse.com>
Diffstat (limited to 'vcl/source/gdi/outdev3.cxx')
-rwxr-xr-xvcl/source/gdi/outdev3.cxx165
1 files changed, 128 insertions, 37 deletions
diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
index e35928133ca7..2e2f373d07d5 100755
--- a/vcl/source/gdi/outdev3.cxx
+++ b/vcl/source/gdi/outdev3.cxx
@@ -2151,21 +2151,17 @@ ImplGetDevSizeList* ImplDevFontList::GetDevSizeList( const String& rFontName ) c
return pGetDevSizeList;
}
-// =======================================================================
-
-FontSelectPattern::FontSelectPattern( const Font& rFont,
- const String& rSearchName, const Size& rSize, float fExactHeight)
-: maSearchName( rSearchName ),
- mnWidth( rSize.Width() ),
- mnHeight( rSize.Height() ),
- mfExactHeight( fExactHeight),
- mnOrientation( rFont.GetOrientation() ),
- meLanguage( rFont.GetLanguage() ),
- mbVertical( rFont.IsVertical() ),
- mbNonAntialiased( false ),
- mbEmbolden( false ),
- mpFontData( NULL ),
- mpFontEntry( NULL )
+FontSelectPatternAttributes::FontSelectPatternAttributes( const Font& rFont,
+ const String& rSearchName, const Size& rSize, float fExactHeight )
+ : maSearchName( rSearchName )
+ , mnWidth( rSize.Width() )
+ , mnHeight( rSize.Height() )
+ , mfExactHeight( fExactHeight)
+ , mnOrientation( rFont.GetOrientation() )
+ , meLanguage( rFont.GetLanguage() )
+ , mbVertical( rFont.IsVertical() )
+ , mbNonAntialiased( false )
+ , mbEmbolden( false )
{
maTargetName = maName;
@@ -2187,51 +2183,115 @@ FontSelectPattern::FontSelectPattern( const Font& rFont,
mnWidth = -mnWidth;
}
-// -----------------------------------------------------------------------
+FontSelectPattern::FontSelectPattern( const Font& rFont,
+ const String& rSearchName, const Size& rSize, float fExactHeight)
+ : FontSelectPatternAttributes(rFont, rSearchName, rSize, fExactHeight)
+ , mpFontData( NULL )
+ , mpFontEntry( NULL )
+{
+}
-FontSelectPattern::FontSelectPattern( const ImplFontData& rFontData,
+// NOTE: this ctor is still used on Windows. Do not remove.
+FontSelectPatternAttributes::FontSelectPatternAttributes( const ImplFontData& rFontData,
const Size& rSize, float fExactHeight, int nOrientation, bool bVertical )
-: ImplFontAttributes( rFontData ),
- mnWidth( rSize.Width() ),
- mnHeight( rSize.Height() ),
- mfExactHeight( fExactHeight ),
- mnOrientation( nOrientation ),
- meLanguage( 0 ),
- mbVertical( bVertical ),
- mbNonAntialiased( false ),
- mbEmbolden( false ),
- mpFontData( &rFontData ),
- mpFontEntry( NULL )
+ : ImplFontAttributes( rFontData )
+ , mnWidth( rSize.Width() )
+ , mnHeight( rSize.Height() )
+ , mfExactHeight( fExactHeight )
+ , mnOrientation( nOrientation )
+ , meLanguage( 0 )
+ , mbVertical( bVertical )
+ , mbNonAntialiased( false )
+ , mbEmbolden( false )
{
maTargetName = maSearchName = maName;
// NOTE: no normalization for width/height/orientation
}
+FontSelectPattern::FontSelectPattern( const ImplFontData& rFontData,
+ const Size& rSize, float fExactHeight, int nOrientation, bool bVertical )
+ : FontSelectPatternAttributes(rFontData, rSize, fExactHeight, nOrientation, bVertical)
+ , mpFontData( &rFontData )
+ , mpFontEntry( NULL )
+{
+}
+
+void FontSelectPattern::copyAttributes(const FontSelectPatternAttributes &rAttributes)
+{
+ static_cast<FontSelectPatternAttributes&>(*this) = rAttributes;
+}
+
// =======================================================================
size_t ImplFontCache::IFSD_Hash::operator()( const FontSelectPattern& rFSD ) const
{
+ return rFSD.hashCode();
+}
+
+size_t FontSelectPatternAttributes::hashCode() const
+{
// TODO: does it pay off to improve this hash function?
static FontNameHash aFontNameHash;
- size_t nHash = aFontNameHash( rFSD.maSearchName );
+ size_t nHash = aFontNameHash( maSearchName );
#ifdef ENABLE_GRAPHITE
// check for features and generate a unique hash if necessary
- if (rFSD.maTargetName.Search(grutils::GrFeatureParser::FEAT_PREFIX)
+ if (maTargetName.Search(grutils::GrFeatureParser::FEAT_PREFIX)
!= STRING_NOTFOUND)
{
- nHash = aFontNameHash( rFSD.maTargetName );
+ nHash = aFontNameHash( maTargetName );
}
#endif
- nHash += 11 * rFSD.mnHeight;
- nHash += 19 * rFSD.meWeight;
- nHash += 29 * rFSD.meItalic;
- nHash += 37 * rFSD.mnOrientation;
- nHash += 41 * rFSD.meLanguage;
- if( rFSD.mbVertical )
+ nHash += 11 * mnHeight;
+ nHash += 19 * meWeight;
+ nHash += 29 * meItalic;
+ nHash += 37 * mnOrientation;
+ nHash += 41 * meLanguage;
+ if( mbVertical )
nHash += 53;
return nHash;
}
+bool FontSelectPatternAttributes::operator==(const FontSelectPatternAttributes& rOther) const
+{
+ if (static_cast<const ImplFontAttributes&>(*this) != static_cast<const ImplFontAttributes&>(rOther))
+ return false;
+
+ if (maTargetName != rOther.maTargetName)
+ return false;
+
+ if (maSearchName != rOther.maSearchName)
+ return false;
+
+ if (mnWidth != rOther.mnWidth)
+ return false;
+
+ if (mnHeight != rOther.mnHeight)
+ return false;
+
+ if (mfExactHeight != rOther.mfExactHeight)
+ return false;
+
+ if (mnOrientation != rOther.mnOrientation)
+ return false;
+
+ if (meLanguage != rOther.meLanguage)
+ return false;
+
+ if (mbVertical != rOther.mbVertical)
+ return false;
+
+ if (mbNonAntialiased != rOther.mbNonAntialiased)
+ return false;
+
+ if (mbEmbolden != rOther.mbEmbolden)
+ return false;
+
+ if (maItalicMatrix != rOther.maItalicMatrix)
+ return false;
+
+ return true;
+}
+
// -----------------------------------------------------------------------
bool ImplFontCache::IFSD_Equal::operator()(const FontSelectPattern& rA, const FontSelectPattern& rB) const
@@ -3290,6 +3350,37 @@ void OutputDevice::ImplInitAboveTextLineSize()
// -----------------------------------------------------------------------
+bool ImplFontAttributes::operator==(const ImplFontAttributes& rOther) const
+{
+ if (maName != rOther.maName)
+ return false;
+
+ if (maStyleName != rOther.maStyleName)
+ return false;
+
+ if (meWeight != rOther.meWeight)
+ return false;
+
+ if (meItalic != rOther.meItalic)
+ return false;
+
+ if (meFamily != rOther.meFamily)
+ return false;
+
+ if (mePitch != rOther.mePitch)
+ return false;
+
+ if (meWidthType != rOther.meWidthType)
+ return false;
+
+ if (mbSymbolFlag != rOther.mbSymbolFlag)
+ return false;
+
+ return true;
+}
+
+// -----------------------------------------------------------------------
+
ImplFontMetricData::ImplFontMetricData( const FontSelectPattern& rFontSelData )
: ImplFontAttributes( rFontSelData )
{