summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2015-05-16 12:50:10 +0000
committertavmjong-free <tavmjong@free.fr>2015-05-16 12:50:10 +0000
commitddf9853ed86846c5cc4e22a1ede31dafcda5c99d (patch)
tree1c3b8a10aa9caae16921dffc4b55eb11bad94e82 /src/ui
parentLatvian translation update (diff)
downloadinkscape-ddf9853ed86846c5cc4e22a1ede31dafcda5c99d.tar.gz
inkscape-ddf9853ed86846c5cc4e22a1ede31dafcda5c99d.zip
Enable setting of 'font-variant-position' and 'font-variant-caps'. Rendering awaits Pango update.
(bzr r14155)
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/dialog/text-edit.cpp2
-rw-r--r--src/ui/widget/font-variants.cpp121
-rw-r--r--src/ui/widget/font-variants.h19
3 files changed, 130 insertions, 12 deletions
diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp
index 2726d979c..4fd227f01 100644
--- a/src/ui/dialog/text-edit.cpp
+++ b/src/ui/dialog/text-edit.cpp
@@ -389,7 +389,7 @@ void TextEdit::onReadSelection ( gboolean dostyle, gboolean /*docontent*/ )
// Update font variant widget
//int result_variants =
sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_FONTVARIANTS);
- vari_vbox.update( query.font_variant_ligatures.computed, query.font_variant_ligatures.value );
+ vari_vbox.update( &query );
}
blocked = false;
diff --git a/src/ui/widget/font-variants.cpp b/src/ui/widget/font-variants.cpp
index 7da7662e2..8ca926d8f 100644
--- a/src/ui/widget/font-variants.cpp
+++ b/src/ui/widget/font-variants.cpp
@@ -66,8 +66,12 @@ namespace Widget {
_numeric_stacked ( Glib::ustring(_("Stacked" )) ),
_numeric_default_fractions( Glib::ustring(_("Default Fractions")) ),
_numeric_ordinal ( Glib::ustring(_("Ordinal" )) ),
- _numeric_slashed_zero ( Glib::ustring(_("Slashed Zero" )) )
+ _numeric_slashed_zero ( Glib::ustring(_("Slashed Zero" )) ),
+ _ligatures_changed( false ),
+ _position_changed( false ),
+ _caps_changed( false ),
+ _numeric_changed( false )
{
@@ -183,6 +187,7 @@ namespace Widget {
void
FontVariants::ligatures_callback() {
// std::cout << "FontVariants::ligatures_callback()" << std::endl;
+ _ligatures_changed = true;
}
void
@@ -193,6 +198,7 @@ namespace Widget {
void
FontVariants::position_callback() {
// std::cout << "FontVariants::position_callback()" << std::endl;
+ _position_changed = true;
}
void
@@ -203,6 +209,7 @@ namespace Widget {
void
FontVariants::caps_callback() {
// std::cout << "FontVariants::caps_callback()" << std::endl;
+ _caps_changed = true;
}
void
@@ -214,21 +221,61 @@ namespace Widget {
void
FontVariants::numeric_callback() {
// std::cout << "FontVariants::numeric_callback()" << std::endl;
+ _numeric_changed = true;
}
+ // Update GUI based on query.
void
- FontVariants::update( unsigned all, unsigned mix ) {
+ FontVariants::update( SPStyle const *query ) {
// std::cout << "FontVariants::update" << std::endl;
- _ligatures_common.set_active( all & SP_CSS_FONT_VARIANT_LIGATURES_COMMON );
- _ligatures_discretionary.set_active( all & SP_CSS_FONT_VARIANT_LIGATURES_DISCRETIONARY );
- _ligatures_historical.set_active( all & SP_CSS_FONT_VARIANT_LIGATURES_HISTORICAL );
- _ligatures_contextual.set_active( all & SP_CSS_FONT_VARIANT_LIGATURES_CONTEXTUAL );
+ _ligatures_all = query->font_variant_ligatures.computed;
+ _ligatures_mix = query->font_variant_ligatures.value;
+
+ _ligatures_common.set_active( _ligatures_all & SP_CSS_FONT_VARIANT_LIGATURES_COMMON );
+ _ligatures_discretionary.set_active(_ligatures_all & SP_CSS_FONT_VARIANT_LIGATURES_DISCRETIONARY );
+ _ligatures_historical.set_active( _ligatures_all & SP_CSS_FONT_VARIANT_LIGATURES_HISTORICAL );
+ _ligatures_contextual.set_active( _ligatures_all & SP_CSS_FONT_VARIANT_LIGATURES_CONTEXTUAL );
+
+ _ligatures_common.set_inconsistent( _ligatures_mix & SP_CSS_FONT_VARIANT_LIGATURES_COMMON );
+ _ligatures_discretionary.set_inconsistent( _ligatures_mix & SP_CSS_FONT_VARIANT_LIGATURES_DISCRETIONARY );
+ _ligatures_historical.set_inconsistent( _ligatures_mix & SP_CSS_FONT_VARIANT_LIGATURES_HISTORICAL );
+ _ligatures_contextual.set_inconsistent( _ligatures_mix & SP_CSS_FONT_VARIANT_LIGATURES_CONTEXTUAL );
+
+ _position_all = query->font_variant_position.computed;
+ _position_mix = query->font_variant_position.value;
- _ligatures_common.set_inconsistent( mix & SP_CSS_FONT_VARIANT_LIGATURES_COMMON );
- _ligatures_discretionary.set_inconsistent( mix & SP_CSS_FONT_VARIANT_LIGATURES_DISCRETIONARY );
- _ligatures_historical.set_inconsistent( mix & SP_CSS_FONT_VARIANT_LIGATURES_HISTORICAL );
- _ligatures_contextual.set_inconsistent( mix & SP_CSS_FONT_VARIANT_LIGATURES_CONTEXTUAL );
+ _position_normal.set_active( _position_all & SP_CSS_FONT_VARIANT_POSITION_NORMAL );
+ _position_sub.set_active( _position_all & SP_CSS_FONT_VARIANT_POSITION_SUB );
+ _position_super.set_active( _position_all & SP_CSS_FONT_VARIANT_POSITION_SUPER );
+
+ _position_normal.set_inconsistent( _position_mix & SP_CSS_FONT_VARIANT_POSITION_NORMAL );
+ _position_sub.set_inconsistent( _position_mix & SP_CSS_FONT_VARIANT_POSITION_SUB );
+ _position_super.set_inconsistent( _position_mix & SP_CSS_FONT_VARIANT_POSITION_SUPER );
+
+ unsigned _caps_all = query->font_variant_caps.computed;
+ unsigned _caps_mix = query->font_variant_caps.value;
+
+ _caps_normal.set_active( _caps_all & SP_CSS_FONT_VARIANT_CAPS_NORMAL );
+ _caps_small.set_active( _caps_all & SP_CSS_FONT_VARIANT_CAPS_SMALL );
+ _caps_all_small.set_active( _caps_all & SP_CSS_FONT_VARIANT_CAPS_ALL_SMALL );
+ _caps_petite.set_active( _caps_all & SP_CSS_FONT_VARIANT_CAPS_PETITE );
+ _caps_all_petite.set_active( _caps_all & SP_CSS_FONT_VARIANT_CAPS_ALL_PETITE );
+ _caps_unicase.set_active( _caps_all & SP_CSS_FONT_VARIANT_CAPS_UNICASE );
+ _caps_titling.set_active( _caps_all & SP_CSS_FONT_VARIANT_CAPS_TITLING );
+
+ _caps_normal.set_inconsistent( _caps_mix & SP_CSS_FONT_VARIANT_CAPS_NORMAL );
+ _caps_small.set_inconsistent( _caps_mix & SP_CSS_FONT_VARIANT_CAPS_SMALL );
+ _caps_all_small.set_inconsistent( _caps_mix & SP_CSS_FONT_VARIANT_CAPS_ALL_SMALL );
+ _caps_petite.set_inconsistent( _caps_mix & SP_CSS_FONT_VARIANT_CAPS_PETITE );
+ _caps_all_petite.set_inconsistent( _caps_mix & SP_CSS_FONT_VARIANT_CAPS_ALL_PETITE );
+ _caps_unicase.set_inconsistent( _caps_mix & SP_CSS_FONT_VARIANT_CAPS_UNICASE );
+ _caps_titling.set_inconsistent( _caps_mix & SP_CSS_FONT_VARIANT_CAPS_TITLING );
+
+ _ligatures_changed = false;
+ _position_changed = false;
+ _caps_changed = false;
+ _numeric_changed = false;
}
void
@@ -256,6 +303,60 @@ namespace Widget {
css_string += "no-contextual ";
sp_repr_css_set_property(css, "font-variant-ligatures", css_string.c_str() );
}
+
+ // Position
+ {
+ unsigned position_new = SP_CSS_FONT_VARIANT_POSITION_NORMAL;
+ Glib::ustring css_string;
+ if( _position_normal.get_active() ) {
+ css_string = "normal";
+ } else if( _position_sub.get_active() ) {
+ css_string = "sub";
+ position_new = SP_CSS_FONT_VARIANT_POSITION_SUB;
+ } else if( _position_super.get_active() ) {
+ css_string = "super";
+ position_new = SP_CSS_FONT_VARIANT_POSITION_SUPER;
+ }
+
+ // 'if' may not be necessary... need to test.
+ if( (_position_all != position_new) || ((_position_mix != 0) && _position_changed) ) {
+ sp_repr_css_set_property(css, "font-variant-position", css_string.c_str() );
+ }
+ }
+
+ // Caps
+ {
+ unsigned caps_new = SP_CSS_FONT_VARIANT_CAPS_NORMAL;
+ Glib::ustring css_string;
+ if( _caps_normal.get_active() ) {
+ css_string = "normal";
+ caps_new = SP_CSS_FONT_VARIANT_CAPS_NORMAL;
+ } else if( _caps_small.get_active() ) {
+ css_string = "small-caps";
+ caps_new = SP_CSS_FONT_VARIANT_CAPS_SMALL;
+ } else if( _caps_all_small.get_active() ) {
+ css_string = "all-small-caps";
+ caps_new = SP_CSS_FONT_VARIANT_CAPS_ALL_SMALL;
+ } else if( _caps_all_petite.get_active() ) {
+ css_string = "petite";
+ caps_new = SP_CSS_FONT_VARIANT_CAPS_PETITE;
+ } else if( _caps_all_petite.get_active() ) {
+ css_string = "all-petite";
+ caps_new = SP_CSS_FONT_VARIANT_CAPS_ALL_PETITE;
+ } else if( _caps_unicase.get_active() ) {
+ css_string = "unicase";
+ caps_new = SP_CSS_FONT_VARIANT_CAPS_UNICASE;
+ } else if( _caps_titling.get_active() ) {
+ css_string = "titling";
+ caps_new = SP_CSS_FONT_VARIANT_CAPS_TITLING;
+ }
+
+ // May not be necessary... need to test.
+ //if( (_caps_all != caps_new) || ((_caps_mix != 0) && _caps_changed) ) {
+ sp_repr_css_set_property(css, "font-variant-caps", css_string.c_str() );
+ //}
+ }
+
}
} // namespace Widget
diff --git a/src/ui/widget/font-variants.h b/src/ui/widget/font-variants.h
index f58b80f34..04c05d3c6 100644
--- a/src/ui/widget/font-variants.h
+++ b/src/ui/widget/font-variants.h
@@ -18,6 +18,7 @@
class SPDesktop;
class SPObject;
+class SPStyle;
class SPCSSAttr;
namespace Inkscape {
@@ -95,8 +96,24 @@ private:
void numeric_init();
void numeric_callback();
+ // To determine if we need to write out property (may not be necessary)
+ unsigned _ligatures_all;
+ unsigned _position_all;
+ unsigned _caps_all;
+ unsigned _numeric_all;
+
+ unsigned _ligatures_mix;
+ unsigned _position_mix;
+ unsigned _caps_mix;
+ unsigned _numeric_mix;
+
+ bool _ligatures_changed;
+ bool _position_changed;
+ bool _caps_changed;
+ bool _numeric_changed;
+
public:
- void update( unsigned all, unsigned mix );
+ void update( SPStyle const *query );
void fill_css( SPCSSAttr* css );
};