Fix TTF iteration in case of an empty list.

pull/479/head
Ryan Pavlik 2019-08-20 11:23:09 -05:00 committed by whitequark
parent 15838dc5a1
commit 61c0167ad7
1 changed files with 3 additions and 3 deletions

View File

@ -72,13 +72,13 @@ void TtfFontList::LoadAll() {
}
// Sort fonts according to their actual name, not filename.
std::sort(&l[0], &l[l.n],
std::sort(l.begin(), l.end(),
[](const TtfFont &a, const TtfFont &b) { return a.name < b.name; });
// Filter out fonts with the same family and style name. This is not
// strictly necessarily the exact same font, but it will almost always be.
TtfFont *it = std::unique(&l[0], &l[l.n],
[](const TtfFont &a, const TtfFont &b) { return a.name == b.name; });
TtfFont *it = std::unique(l.begin(), l.end(),
[](const TtfFont &a, const TtfFont &b) { return a.name == b.name; });
l.RemoveLast(&l[l.n] - it);
//! @todo identify fonts by their name and not filename, which may change