diff options
| author | Gail Carmichael <gail.banaszkiewicz@gmail.com> | 2008-01-10 22:40:48 +0000 |
|---|---|---|
| committer | gbanaszk <gbanaszk@users.sourceforge.net> | 2008-01-10 22:40:48 +0000 |
| commit | 2b56810c6a95306616f8e64499bfa20476dc7dff (patch) | |
| tree | 263eeb6eed8571cebe29fc574182ae35ca2d7e97 /src/widgets/toolbox.cpp | |
| parent | Fix small z-order error for 3D boxes (diff) | |
| download | inkscape-2b56810c6a95306616f8e64499bfa20476dc7dff.tar.gz inkscape-2b56810c6a95306616f8e64499bfa20476dc7dff.zip | |
Fix for Bug #181663 (Font style errors / assert when changing style)
- 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.
(bzr r4453)
Diffstat (limited to 'src/widgets/toolbox.cpp')
| -rw-r--r-- | src/widgets/toolbox.cpp | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 850018662..5d01eb78f 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -4181,9 +4181,21 @@ sp_text_toolbox_family_changed (GtkTreeSelection *selection, 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) { @@ -4334,12 +4346,29 @@ sp_text_toolbox_style_toggled (GtkToggleButton *button, 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: @@ -4348,6 +4377,7 @@ sp_text_toolbox_style_toggled (GtkToggleButton *button, 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; @@ -4359,14 +4389,15 @@ sp_text_toolbox_style_toggled (GtkToggleButton *button, 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 + |
