summaryrefslogtreecommitdiffstats
path: root/src/ui/widget/font-selector.cpp
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2019-03-18 10:15:33 +0000
committerTavmjong Bah <tavmjong@free.fr>2019-03-18 10:15:33 +0000
commit0ad29b463567262c562c845cd9cdc07971afde28 (patch)
tree808b49ab3351ef7329b6f12292b76651f0be7aca /src/ui/widget/font-selector.cpp
parentFix rendering for text with inherited 'font-variation-settings' property. (diff)
downloadinkscape-0ad29b463567262c562c845cd9cdc07971afde28.tar.gz
inkscape-0ad29b463567262c562c845cd9cdc07971afde28.zip
Keep font variations widget in sync with CSS style widget.
Diffstat (limited to 'src/ui/widget/font-selector.cpp')
-rw-r--r--src/ui/widget/font-selector.cpp34
1 files changed, 23 insertions, 11 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();
}