diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2019-03-18 10:15:33 +0000 |
|---|---|---|
| committer | Tavmjong Bah <tavmjong@free.fr> | 2019-03-18 10:15:33 +0000 |
| commit | 0ad29b463567262c562c845cd9cdc07971afde28 (patch) | |
| tree | 808b49ab3351ef7329b6f12292b76651f0be7aca /src/ui/widget | |
| parent | Fix rendering for text with inherited 'font-variation-settings' property. (diff) | |
| download | inkscape-0ad29b463567262c562c845cd9cdc07971afde28.tar.gz inkscape-0ad29b463567262c562c845cd9cdc07971afde28.zip | |
Keep font variations widget in sync with CSS style widget.
Diffstat (limited to 'src/ui/widget')
| -rw-r--r-- | src/ui/widget/font-selector.cpp | 34 | ||||
| -rw-r--r-- | src/ui/widget/font-selector.h | 2 | ||||
| -rw-r--r-- | src/ui/widget/font-variations.cpp | 1 |
3 files changed, 24 insertions, 13 deletions
diff --git a/src/ui/widget/font-selector.cpp b/src/ui/widget/font-selector.cpp index dd33940fc..2263862a0 100644 --- a/src/ui/widget/font-selector.cpp +++ b/src/ui/widget/font-selector.cpp @@ -219,8 +219,10 @@ FontSelector::update_size (double size) } +// If use_variations is true (default), we get variation values from variations widget otherwise we +// get values from CSS widget (we need to be able to keep the two widgets synchronized both ways). Glib::ustring -FontSelector::get_fontspec() { +FontSelector::get_fontspec(bool use_variations) { // Build new fontspec from GUI settings Glib::ustring family = "Sans"; // Default...family list may not have been constructed. @@ -243,18 +245,23 @@ FontSelector::get_fontspec() { std::cerr << "FontSelector::get_fontspec: empty style!" << std::endl; } - // Clip any font_variation data in 'style' as we'll replace it. - if (auto pos = style.find('@') != Glib::ustring::npos) { - style.erase (pos, style.length()-1); - } + Glib::ustring fontspec = family + " "; - Glib::ustring variations = font_variations.get_pango_string(); + if (use_variations) { + // Clip any font_variation data in 'style' as we'll replace it. + if (auto pos = style.find('@') != Glib::ustring::npos) { + style.erase (pos, style.length()-1); + } - Glib::ustring fontspec = family + " "; - if (variations.empty()) { - fontspec += style; + Glib::ustring variations = font_variations.get_pango_string(); + + if (variations.empty()) { + fontspec += style; + } else { + fontspec += variations; + } } else { - fontspec += variations; + fontspec += style; } return fontspec; @@ -350,9 +357,14 @@ FontSelector::on_family_changed() { void FontSelector::on_style_changed() { - if (signal_block) return; + // Update variations widget if new style selected from style widget. + signal_block = true; + Glib::ustring fontspec = get_fontspec( false ); + font_variations.update( fontspec ); + signal_block = false; + // Let world know changed_emit(); } diff --git a/src/ui/widget/font-selector.h b/src/ui/widget/font-selector.h index df9057338..36458e7ba 100644 --- a/src/ui/widget/font-selector.h +++ b/src/ui/widget/font-selector.h @@ -124,7 +124,7 @@ public: /** * Get fontspec based on current settings. (Does not handle size, yet.) */ - Glib::ustring get_fontspec(); + Glib::ustring get_fontspec(bool use_variations = true); /** * Get font size. Could be merged with fontspec. diff --git a/src/ui/widget/font-variations.cpp b/src/ui/widget/font-variations.cpp index d0e6090e5..20012b381 100644 --- a/src/ui/widget/font-variations.cpp +++ b/src/ui/widget/font-variations.cpp @@ -93,7 +93,6 @@ FontVariations::update (Glib::ustring& font_spec) { void FontVariations::fill_css( SPCSSAttr *css ) { - std::cout << "FontVariations::fill_css" << std::endl; // Eventually will want to favor using 'font-weight', etc. but at the moment these // can't handle "fractional" values. See CSS Fonts Module Level 4. |
