Logo Search packages:      
Sourcecode: inkscape version File versions

int objects_query_fontfamily ( GSList *  objects,
SPStyle style_res 
)

Write to style_res the average font family of objects.

Definition at line 1004 of file desktop-style.cpp.

References SPTextStyle::font_family, SPIString::set, SPStyle::text, and SPIString::value.

Referenced by sp_desktop_query_style_from_list().

{
    bool different = false;
    int texts = 0;

    if (style_res->text->font_family.value) {
        g_free(style_res->text->font_family.value);
        style_res->text->font_family.value = NULL;
    }
    style_res->text->font_family.set = FALSE;

    for (GSList const *i = objects; i != NULL; i = i->next) {
        SPObject *obj = SP_OBJECT (i->data);

        if (!SP_IS_TEXT(obj) && !SP_IS_FLOWTEXT(obj)
            && !SP_IS_TSPAN(obj) && !SP_IS_TREF(obj) && !SP_IS_TEXTPATH(obj)
            && !SP_IS_FLOWDIV(obj) && !SP_IS_FLOWPARA(obj) && !SP_IS_FLOWTSPAN(obj))
            continue;

        SPStyle *style = SP_OBJECT_STYLE (obj);
        if (!style) continue;

        texts ++;

        if (style_res->text->font_family.value && style->text->font_family.value &&
            strcmp (style_res->text->font_family.value, style->text->font_family.value)) {
            different = true;  // different fonts
        }

        if (style_res->text->font_family.value) {
            g_free(style_res->text->font_family.value);
            style_res->text->font_family.value = NULL;
        }

        style_res->text->font_family.set = TRUE;
        style_res->text->font_family.value = g_strdup(style->text->font_family.value);
    }

    if (texts == 0 || !style_res->text->font_family.set)
        return QUERY_STYLE_NOTHING;

    if (texts > 1) {
        if (different) {
            return QUERY_STYLE_MULTIPLE_DIFFERENT;
        } else {
            return QUERY_STYLE_MULTIPLE_SAME;
        }
    } else {
        return QUERY_STYLE_SINGLE;
    }
}


Generated by  Doxygen 1.6.0   Back to index