The font family list is now sorted - besides the obvious advantage for the user,

this also allows binary searching the families (which is now done, too).


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14826 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-11-10 15:33:18 +00:00
parent d5f377d66c
commit 36a37b76d6
+11 -10
View File
@@ -89,6 +89,13 @@ set_entry(node_ref& nodeRef, const char* name, BEntry& entry)
} }
static int
compare_font_families(const FontFamily* a, const FontFamily* b)
{
return strcmp(a->Name(), b->Name());
}
// #pragma mark - // #pragma mark -
@@ -426,7 +433,7 @@ FontManager::_AddFont(font_directory& directory, BEntry& entry)
if (family == NULL) { if (family == NULL) {
family = new (nothrow) FontFamily(face->family_name, fNextID++); family = new (nothrow) FontFamily(face->family_name, fNextID++);
if (family == NULL if (family == NULL
|| !fFamilies.AddItem(family)) { || !fFamilies.BinaryInsert(family, compare_font_families)) {
delete family; delete family;
FT_Done_Face(face); FT_Done_Face(face);
return B_NO_MEMORY; return B_NO_MEMORY;
@@ -699,15 +706,9 @@ FontManager::_FindFamily(const char* name) const
if (name == NULL) if (name == NULL)
return NULL; return NULL;
int32 count = fFamilies.CountItems(); FontFamily family(name, 0);
return const_cast<FontFamily*>(fFamilies.BinarySearch(family,
for (int32 i = 0; i < count; i++) { compare_font_families));
FontFamily* family = fFamilies.ItemAt(i);
if (!strcmp(family->Name(), name))
return family;
}
return NULL;
} }