Пример #1
0
FontStyle*
FontFamily::_FindStyle(const char* name) const
{
    int32 count = fStyles.CountItems();
    if (!name || count < 1)
        return NULL;

    for (int32 i = 0; i < count; i++) {
        FontStyle *style = fStyles.ItemAt(i);
        if (!strcmp(style->Name(), name))
            return style;
    }

    return NULL;
}
Пример #2
0
/*!
	\brief Adds the style to the family
	\param style pointer to FontStyle object to be added
*/
bool
FontFamily::AddStyle(FontStyle *style)
{
    if (!style)
        return false;

    // Don't add if it already is in the family.
    int32 count = fStyles.CountItems();
    for (int32 i = 0; i < count; i++) {
        FontStyle *item = fStyles.ItemAt(i);
        if (!strcmp(item->Name(), style->Name()))
            return false;
    }

    if (!fStyles.BinaryInsert(style, compare_font_styles))
        return false;

    style->_SetFontFamily(this, fNextID++);

    // force a refresh if a request for font flags is needed
    fFlags = kInvalidFamilyFlags;

    return true;
}