Now also sorts the font list - unlike the app_server, it could also take the

user's locale into account.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14827 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2005-11-10 15:40:22 +00:00
parent 36a37b76d6
commit fff7b3cd5d

View File

@ -89,6 +89,17 @@ class FontList : public BLocker {
static BPrivate::FontList sFontList;
// #pragma mark -
static int
compare_families(const family* a, const family* b)
{
// TODO: compare font names according to the user's locale settings
return strcmp(a->name.String(), b->name.String());
}
namespace BPrivate {
FontList::FontList()
@ -179,7 +190,7 @@ FontList::_Update()
family->styles.AddItem(style);
}
fFamilies.AddItem(family);
fFamilies.BinaryInsert(family, compare_families);
}
fRevision = revision;
@ -209,16 +220,10 @@ FontList::_FindFamily(font_family name)
if (fLastFamily != NULL && fLastFamily->name == name)
return fLastFamily;
for (int32 i = 0; i < fFamilies.CountItems(); i++) {
family* family = fFamilies.ItemAt(i);
if (family->name == name) {
fLastFamily = family;
return family;
}
}
return NULL;
::family family;
family.name = name;
fLastFamily = const_cast< ::family*>(fFamilies.BinarySearch(family, compare_families));
return fLastFamily;
}