summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2494e9f)
raw | patch | inline | side by side (parent: 2494e9f)
author | gbanaszk <gbanaszk@users.sourceforge.net> | |
Thu, 10 Jan 2008 22:40:48 +0000 (22:40 +0000) | ||
committer | gbanaszk <gbanaszk@users.sourceforge.net> | |
Thu, 10 Jan 2008 22:40:48 +0000 (22:40 +0000) |
- I didn't see the problem described in the main part, but the assert was overzealous and, in my new opinion, shouldn't be there, so it's gone.
- Fixed other style button problems mentioned in comments.
- Fixed other style button problems mentioned in comments.
src/desktop-style.cpp | patch | blob | history | |
src/libnrtype/FontFactory.cpp | patch | blob | history | |
src/widgets/toolbox.cpp | patch | blob | history |
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp
index e56e7fbbe8acf99eb26155b5eb2f617e83f226ed..fe388ded39b26b066b88e9af5c750ef50020ff65 100644 (file)
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
texts ++;
- if (style_res->text->font_specification.value && style->text->font_specification.value &&
+ if (style_res->text->font_specification.value && style_res->text->font_specification.set &&
+ style->text->font_specification.value && style->text->font_specification.set &&
strcmp (style_res->text->font_specification.value, style->text->font_specification.value)) {
different = true; // different fonts
}
+
+ if (style->text->font_specification.set) {
- if (style_res->text->font_specification.value) {
- g_free(style_res->text->font_specification.value);
- style_res->text->font_specification.value = NULL;
+ 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);
}
-
- 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)
index 2d56a1a41e89278c8ebe676a7daaa9b002af080d..98846b77fcc8d8da6aaac721941b3e6d92c793cc 100644 (file)
@@ -420,8 +420,6 @@ Glib::ustring font_factory::ReplaceFontSpecificationFamily(const Glib::ustring &
// Find the PangoFontDescription associated to this fontSpec
PangoStringToDescrMap::iterator it = fontInstanceMap.find(fontSpec);
- g_assert(it != fontInstanceMap.end());
-
if (it != fontInstanceMap.end()) {
PangoFontDescription *descr = pango_font_description_copy((*it).second);
@@ -496,8 +494,6 @@ Glib::ustring font_factory::FontSpecificationSetItalic(const Glib::ustring & fon
// Find the PangoFontDesecription that goes with this font specification string
PangoStringToDescrMap::iterator it = fontInstanceMap.find(fontSpec);
- g_assert(it != fontInstanceMap.end());
-
if (it != fontInstanceMap.end()) {
// If we did find one, make a copy and set/unset the italic as needed
PangoFontDescription *descr = pango_font_description_copy((*it).second);
index 85001866295994233b09c9fdf26607cda7b68afb..5d01eb78f09d377ea3d98556ae3ced360f07ed39 100644 (file)
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
int result_fontspec =
sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION);
+ font_instance * fontFromStyle = font_factory::Default()->FaceFromStyle(query);
+
SPCSSAttr *css = sp_repr_css_attr_new ();
- std::string fontSpec = query->text->font_specification.value;
+
+ // First try to get the font spec from the stored value
+ Glib::ustring fontSpec = query->text->font_specification.set ? query->text->font_specification.value : "";
+
+ if (fontSpec.empty()) {
+ // Construct a new font specification if it does not yet exist
+ font_instance * fontFromStyle = font_factory::Default()->FaceFromStyle(query);
+ fontSpec = font_factory::Default()->ConstructFontSpecification(fontFromStyle);
+ fontFromStyle->Unref();
+ }
+
if (!fontSpec.empty()) {
Glib::ustring newFontSpec = font_factory::Default()->ReplaceFontSpecificationFamily(fontSpec, family);
if (!newFontSpec.empty() && fontSpec != newFontSpec) {
SPStyle *query =
sp_style_new (SP_ACTIVE_DOCUMENT);
+
int result_fontspec =
sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONT_SPECIFICATION);
-
- Glib::ustring fontSpec = query->text->font_specification.value;
- Glib::ustring newFontSpec;
+ int result_family =
+ sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTFAMILY);
+
+ int result_style =
+ sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTSTYLE);
+
+ int result_numbers =
+ sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_FONTNUMBERS);
+
+ Glib::ustring fontSpec = query->text->font_specification.set ? query->text->font_specification.value : "";
+ Glib::ustring newFontSpec = "";
+
+ if (fontSpec.empty()) {
+ // Construct a new font specification if it does not yet exist
+ font_instance * fontFromStyle = font_factory::Default()->FaceFromStyle(query);
+ fontSpec = font_factory::Default()->ConstructFontSpecification(fontFromStyle);
+ fontFromStyle->Unref();
+ }
+
switch (prop)
{
case 0:
newFontSpec = font_factory::Default()->FontSpecificationSetBold(fontSpec, active);
}
if (fontSpec != newFontSpec) {
+ // Don't even set the bold if the font didn't exist on the system
sp_repr_css_set_property (css, "font-weight", active ? "bold" : "normal" );
}
break;
newFontSpec = font_factory::Default()->FontSpecificationSetItalic(fontSpec, active);
}
if (fontSpec != newFontSpec) {
+ // Don't even set the italic if the font didn't exist on the system
sp_repr_css_set_property (css, "font-style", active ? "italic" : "normal");
}
break;
}
}
- if (!fontSpec.empty()) {
- sp_repr_css_set_property (css, "-inkscape-font-specification", fontSpec.c_str());
+ if (!newFontSpec.empty()) {
+ sp_repr_css_set_property (css, "-inkscape-font-specification", newFontSpec.c_str());
}
// If querying returned nothing, read the style from the text tool prefs (default style for new texts)
@@ -5286,3 +5317,4 @@ static void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* main
+