vcl: PhysicalFontFamily::maFontFaces must be sorted

When toggling the "Apply replacement table" setting in
Tools->Options->Fonts, the fonts are re-enumerated once per
OutputDevice, so if the sorting isn't maintained properly duplicates
will be inserted and the number of font faces goes from 400 to 40k.

(regression from a20a52a2f4)

Change-Id: I7daa53ff28187056e34efa4e2173dea45a47df27
This commit is contained in:
Michael Stahl
2016-05-06 15:53:20 +02:00
parent afad4eeaff
commit 3b12b5f44c

View File

@@ -158,7 +158,8 @@ bool PhysicalFontFamily::AddFontFace( PhysicalFontFace* pNewFontFace )
// add the new physical font face, replacing existing font face if necessary
// TODO: get rid of linear search?
for(std::vector< PhysicalFontFace* >::iterator it=maFontFaces.begin(); it != maFontFaces.end(); ++it )
auto it(maFontFaces.begin());
for (; it != maFontFaces.end(); ++it)
{
PhysicalFontFace* pFoundFontFace = *it;
sal_Int32 eComp = pNewFontFace->CompareWithSize( *pFoundFontFace );
@@ -177,12 +178,11 @@ bool PhysicalFontFamily::AddFontFace( PhysicalFontFace* pNewFontFace )
// replace existing font face with a better one
delete pFoundFontFace;
it = maFontFaces.erase( it );
maFontFaces.push_back( pNewFontFace );
*it = pNewFontFace; // insert at sort position
return true;
}
maFontFaces.push_back( pNewFontFace );
maFontFaces.insert(it, pNewFontFace); // insert at sort position
return true;
}