summaryrefslogtreecommitdiffstats
path: root/src/desktop-style.cpp
diff options
context:
space:
mode:
authorBryce Harrington <bryce@bryceharrington.org>2008-01-05 10:38:18 +0000
committerbryce <bryce@users.sourceforge.net>2008-01-05 10:38:18 +0000
commit512f06a80f013e903d513b6ffa069d48c6abbfaa (patch)
tree966213a353297141089cd8c080ede6ac6a4385e8 /src/desktop-style.cpp
parentFixing up a few more files (diff)
downloadinkscape-512f06a80f013e903d513b6ffa069d48c6abbfaa.tar.gz
inkscape-512f06a80f013e903d513b6ffa069d48c6abbfaa.zip
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)
Diffstat (limited to 'src/desktop-style.cpp')
-rw-r--r--src/desktop-style.cpp57
1 files changed, 56 insertions, 1 deletions
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
@@ -1051,6 +1051,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)
{
const int empty_prev = -2;
@@ -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) {