From 8d6697587776136f3121733e1c29d4200720dbd9 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Fri, 22 Aug 2014 00:37:46 +0100 Subject: fdo#79761 - avoid re-canonicalising each font name on clone repeatedly. Change-Id: I5b32787943ab3f824249359e9924eae25ba5783b --- vcl/source/font/PhysicalFontFamily.cxx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/vcl/source/font/PhysicalFontFamily.cxx b/vcl/source/font/PhysicalFontFamily.cxx index 3cba47056f81..6307ac0ea444 100644 --- a/vcl/source/font/PhysicalFontFamily.cxx +++ b/vcl/source/font/PhysicalFontFamily.cxx @@ -281,6 +281,10 @@ void PhysicalFontFamily::GetFontHeights( std::set& rHeights ) const void PhysicalFontFamily::UpdateCloneFontList( PhysicalFontCollection& rFontCollection, bool bScalable, bool bEmbeddable ) const { + // This is rather expensive to do per face. + OUString aFamilyName = GetEnglishSearchFontName( GetFamilyName() ); + PhysicalFontFamily* pFamily = rFontCollection.FindOrCreateFamily( aFamilyName ); + for( PhysicalFontFace* pFace = mpFirst; pFace; pFace = pFace->GetNextFace() ) { if( bScalable && !pFace->IsScalable() ) @@ -289,7 +293,12 @@ void PhysicalFontFamily::UpdateCloneFontList( PhysicalFontCollection& rFontColle continue; PhysicalFontFace* pClonedFace = pFace->Clone(); - rFontCollection.Add( pClonedFace ); + + assert( pClonedFace->GetFamilyName() == GetFamilyName() ); + assert( rFontCollection.FindOrCreateFamily( GetEnglishSearchFontName( pClonedFace->GetFamilyName() ) ) == pFamily ); + + if (! pFamily->AddFontFace( pClonedFace ) ) + delete pClonedFace; } } -- cgit