From 512f06a80f013e903d513b6ffa069d48c6abbfaa Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Sat, 5 Jan 2008 10:38:18 +0000 Subject: Applying Gail's patch for font-specification (Closes LP: #169973) - New attribute in an object's style string called -inkscape-font-specification stores full font name - This will be useful when we can support fonts that don't fit into the confines of CSS (if either pango enhances their PangoFontDescription structure, or we can get around its limitations) - Framework in place to separate font families from their "styles" (faces) in the text and font dialog - need only the code that does the actual separation - Text and Styles dialog shows only fonts it can handle (bzr r4392) --- src/desktop-style.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) (limited to 'src/desktop-style.cpp') diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index d0cecda03..e56e7fbbe 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -1050,6 +1050,59 @@ objects_query_fontfamily (GSList *objects, SPStyle *style_res) } } +int +objects_query_fontspecification (GSList *objects, SPStyle *style_res) +{ + bool different = false; + int texts = 0; + + if (style_res->text->font_specification.value) { + g_free(style_res->text->font_specification.value); + style_res->text->font_specification.value = NULL; + } + style_res->text->font_specification.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_specification.value && style->text->font_specification.value && + strcmp (style_res->text->font_specification.value, style->text->font_specification.value)) { + different = true; // different fonts + } + + if (style_res->text->font_specification.value) { + g_free(style_res->text->font_specification.value); + style_res->text->font_specification.value = NULL; + } + + style_res->text->font_specification.set = TRUE; + style_res->text->font_specification.value = g_strdup(style->text->font_specification.value); + } + + if (texts == 0 || !style_res->text->font_specification.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; + } +} + int objects_query_blend (GSList *objects, SPStyle *style_res) { @@ -1221,7 +1274,9 @@ sp_desktop_query_style_from_list (GSList *list, SPStyle *style, int property) } else if (property == QUERY_STYLE_PROPERTY_MASTEROPACITY) { return objects_query_opacity (list, style); - + + } else if (property == QUERY_STYLE_PROPERTY_FONT_SPECIFICATION) { + return objects_query_fontspecification (list, style); } else if (property == QUERY_STYLE_PROPERTY_FONTFAMILY) { return objects_query_fontfamily (list, style); } else if (property == QUERY_STYLE_PROPERTY_FONTSTYLE) { -- cgit v1.2.3