summaryrefslogtreecommitdiffstats
path: root/src/ui/widget/font-variants.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-07-24 18:45:27 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-07-24 18:45:27 +0000
commit50115a1e39ed4414dd9e684709253167072b29ee (patch)
treea37ac591208a0f52e64ad7f5bddd45e773f138ee /src/ui/widget/font-variants.cpp
parentfix minor bug (diff)
parentFix a bug continuing a bezier path whith a LPE one like spiro or bspline on a... (diff)
downloadinkscape-50115a1e39ed4414dd9e684709253167072b29ee.tar.gz
inkscape-50115a1e39ed4414dd9e684709253167072b29ee.zip
update to trunk
(bzr r13708.1.37)
Diffstat (limited to 'src/ui/widget/font-variants.cpp')
-rw-r--r--src/ui/widget/font-variants.cpp211
1 files changed, 209 insertions, 2 deletions
diff --git a/src/ui/widget/font-variants.cpp b/src/ui/widget/font-variants.cpp
index 637631fda..5d1e40971 100644
--- a/src/ui/widget/font-variants.cpp
+++ b/src/ui/widget/font-variants.cpp
@@ -13,7 +13,7 @@
#include <gtkmm.h>
#include <glibmm/i18n.h>
-
+#include <libnrtype/font-instance.h>
#include <iostream>
#include "font-variants.h"
@@ -68,6 +68,9 @@ namespace Widget {
_numeric_ordinal ( Glib::ustring(_("Ordinal" )) ),
_numeric_slashed_zero ( Glib::ustring(_("Slashed Zero" )) ),
+ _feature_frame ( Glib::ustring(_("Feature Settings")) ),
+ _feature_label ( Glib::ustring(_("Selection has different Feature Settings!")) ),
+
_ligatures_changed( false ),
_position_changed( false ),
_caps_changed( false ),
@@ -231,6 +234,21 @@ namespace Widget {
add( _numeric_frame );
+ // Feature settings ---------------------
+
+ // Add tooltips
+ _feature_entry.set_tooltip_text( _("Feature settings in CSS form. No sanity checking is performed."));
+
+ // Add to frame
+ _feature_vbox.add( _feature_entry );
+ _feature_vbox.add( _feature_label );
+ _feature_frame.add( _feature_vbox );
+ add( _feature_frame );
+
+ // Add signals
+ //_feature_entry.signal_key_press_event().connect ( sigc::mem_fun(*this, &FontVariants::feature_callback) );
+ _feature_entry.signal_changed().connect( sigc::mem_fun(*this, &FontVariants::feature_callback) );
+
show_all_children();
}
@@ -283,9 +301,21 @@ namespace Widget {
_changed_signal.emit();
}
+ void
+ FontVariants::feature_init() {
+ // std::cout << "FontVariants::feature_init()" << std::endl;
+ }
+
+ void
+ FontVariants::feature_callback() {
+ // std::cout << "FontVariants::feature_callback()" << std::endl;
+ _feature_changed = true;
+ _changed_signal.emit();
+ }
+
// Update GUI based on query.
void
- FontVariants::update( SPStyle const *query ) {
+ FontVariants::update( SPStyle const *query, bool different_features, Glib::ustring& font_spec ) {
_ligatures_all = query->font_variant_ligatures.computed;
_ligatures_mix = query->font_variant_ligatures.value;
@@ -370,10 +400,182 @@ namespace Widget {
_numeric_ordinal.set_inconsistent( _numeric_mix & SP_CSS_FONT_VARIANT_NUMERIC_ORDINAL );
_numeric_slashed_zero.set_inconsistent( _numeric_mix & SP_CSS_FONT_VARIANT_NUMERIC_SLASHED_ZERO );
+ if( query->font_feature_settings.value )
+ _feature_entry.set_text( query->font_feature_settings.value );
+ if( different_features ) {
+ _feature_label.show();
+ } else {
+ _feature_label.hide();
+ }
+
+
+ // Disable/Enable based on available OpenType tables.
+ font_instance* res = font_factory::Default()->FaceFromFontSpecification( font_spec.c_str() );
+ if( res ) {
+
+ std::map<Glib::ustring,int>::iterator it;
+
+ if((it = res->openTypeTables.find("liga"))!= res->openTypeTables.end() ||
+ (it = res->openTypeTables.find("clig"))!= res->openTypeTables.end()) {
+ _ligatures_common.set_sensitive();
+ } else {
+ _ligatures_common.set_sensitive( false );
+ }
+
+ if((it = res->openTypeTables.find("dlig"))!= res->openTypeTables.end()) {
+ _ligatures_discretionary.set_sensitive();
+ } else {
+ _ligatures_discretionary.set_sensitive( false );
+ }
+
+ if((it = res->openTypeTables.find("hlig"))!= res->openTypeTables.end()) {
+ _ligatures_historical.set_sensitive();
+ } else {
+ _ligatures_historical.set_sensitive( false );
+ }
+
+ if((it = res->openTypeTables.find("calt"))!= res->openTypeTables.end()) {
+ _ligatures_contextual.set_sensitive();
+ } else {
+ _ligatures_contextual.set_sensitive( false );
+ }
+
+ if((it = res->openTypeTables.find("subs"))!= res->openTypeTables.end()) {
+ _position_sub.set_sensitive();
+ } else {
+ _position_sub.set_sensitive( false );
+ }
+
+ if((it = res->openTypeTables.find("sups"))!= res->openTypeTables.end()) {
+ _position_super.set_sensitive();
+ } else {
+ _position_super.set_sensitive( false );
+ }
+
+ if((it = res->openTypeTables.find("smcp"))!= res->openTypeTables.end()) {
+ _caps_small.set_sensitive();
+ } else {
+ _caps_small.set_sensitive( false );
+ }
+
+ if((it = res->openTypeTables.find("c2sc"))!= res->openTypeTables.end() &&
+ (it = res->openTypeTables.find("smcp"))!= res->openTypeTables.end()) {
+ _caps_all_small.set_sensitive();
+ } else {
+ _caps_all_small.set_sensitive( false );
+ }
+
+ if((it = res->openTypeTables.find("pcap"))!= res->openTypeTables.end()) {
+ _caps_petite.set_sensitive();
+ } else {
+ _caps_petite.set_sensitive( false );
+ }
+
+ if((it = res->openTypeTables.find("c2sc"))!= res->openTypeTables.end() &&
+ (it = res->openTypeTables.find("pcap"))!= res->openTypeTables.end()) {
+ _caps_all_petite.set_sensitive();
+ } else {
+ _caps_all_petite.set_sensitive( false );
+ }
+
+ if((it = res->openTypeTables.find("unic"))!= res->openTypeTables.end()) {
+ _caps_unicase.set_sensitive();
+ } else {
+ _caps_unicase.set_sensitive( false );
+ }
+
+ if((it = res->openTypeTables.find("titl"))!= res->openTypeTables.end()) {
+ _caps_titling.set_sensitive();
+ } else {
+ _caps_titling.set_sensitive( false );
+ }
+
+ if((it = res->openTypeTables.find("lnum"))!= res->openTypeTables.end()) {
+ _numeric_lining.set_sensitive();
+ } else {
+ _numeric_lining.set_sensitive( false );
+ }
+
+ if((it = res->openTypeTables.find("onum"))!= res->openTypeTables.end()) {
+ _numeric_old_style.set_sensitive();
+ } else {
+ _numeric_old_style.set_sensitive( false );
+ }
+
+ if((it = res->openTypeTables.find("pnum"))!= res->openTypeTables.end()) {
+ _numeric_proportional.set_sensitive();
+ } else {
+ _numeric_proportional.set_sensitive( false );
+ }
+
+ if((it = res->openTypeTables.find("tnum"))!= res->openTypeTables.end()) {
+ _numeric_tabular.set_sensitive();
+ } else {
+ _numeric_tabular.set_sensitive( false );
+ }
+
+ if((it = res->openTypeTables.find("frac"))!= res->openTypeTables.end()) {
+ _numeric_diagonal.set_sensitive();
+ } else {
+ _numeric_diagonal.set_sensitive( false );
+ }
+
+ if((it = res->openTypeTables.find("afrac"))!= res->openTypeTables.end()) {
+ _numeric_stacked.set_sensitive();
+ } else {
+ _numeric_stacked.set_sensitive( false );
+ }
+
+ if((it = res->openTypeTables.find("ordn"))!= res->openTypeTables.end()) {
+ _numeric_ordinal.set_sensitive();
+ } else {
+ _numeric_ordinal.set_sensitive( false );
+ }
+
+ if((it = res->openTypeTables.find("zero"))!= res->openTypeTables.end()) {
+ _numeric_slashed_zero.set_sensitive();
+ } else {
+ _numeric_slashed_zero.set_sensitive( false );
+ }
+
+ // Make list of tables not handled above... eventually add Gtk::Label with
+ // this info.
+ // std::map<Glib::ustring,int> table_copy = res->openTypeTables;
+ // if( (it = table_copy.find("liga")) != table_copy.end() ) table_copy.erase( it );
+ // if( (it = table_copy.find("clig")) != table_copy.end() ) table_copy.erase( it );
+ // if( (it = table_copy.find("dlig")) != table_copy.end() ) table_copy.erase( it );
+ // if( (it = table_copy.find("hlig")) != table_copy.end() ) table_copy.erase( it );
+ // if( (it = table_copy.find("calt")) != table_copy.end() ) table_copy.erase( it );
+ // if( (it = table_copy.find("subs")) != table_copy.end() ) table_copy.erase( it );
+ // if( (it = table_copy.find("sups")) != table_copy.end() ) table_copy.erase( it );
+ // if( (it = table_copy.find("smcp")) != table_copy.end() ) table_copy.erase( it );
+ // if( (it = table_copy.find("c2sc")) != table_copy.end() ) table_copy.erase( it );
+ // if( (it = table_copy.find("pcap")) != table_copy.end() ) table_copy.erase( it );
+ // if( (it = table_copy.find("unic")) != table_copy.end() ) table_copy.erase( it );
+ // if( (it = table_copy.find("titl")) != table_copy.end() ) table_copy.erase( it );
+ // if( (it = table_copy.find("lnum")) != table_copy.end() ) table_copy.erase( it );
+ // if( (it = table_copy.find("onum")) != table_copy.end() ) table_copy.erase( it );
+ // if( (it = table_copy.find("pnum")) != table_copy.end() ) table_copy.erase( it );
+ // if( (it = table_copy.find("tnum")) != table_copy.end() ) table_copy.erase( it );
+ // if( (it = table_copy.find("frac")) != table_copy.end() ) table_copy.erase( it );
+ // if( (it = table_copy.find("afrc")) != table_copy.end() ) table_copy.erase( it );
+ // if( (it = table_copy.find("ordn")) != table_copy.end() ) table_copy.erase( it );
+ // if( (it = table_copy.find("zero")) != table_copy.end() ) table_copy.erase( it );
+ // for(it = table_copy.begin(); it != table_copy.end(); ++it) {
+ // std::cout << "Other: " << it->first << " Occurances: " << it->second << std::endl;
+ // }
+
+ } else {
+ std::cerr << "FontVariants::update(): Couldn't find font_instance for: "
+ << font_spec << std::endl;
+ }
+
+
_ligatures_changed = false;
_position_changed = false;
_caps_changed = false;
_numeric_changed = false;
+ _feature_changed = false;
}
void
@@ -494,6 +696,11 @@ namespace Widget {
sp_repr_css_set_property(css, "font-variant-numeric", css_string.c_str() );
}
+ // Feature settings
+ Glib::ustring feature_string = _feature_entry.get_text();
+ if( !feature_string.empty() || feature_string.compare( "normal" ) ) {
+ sp_repr_css_set_property(css, "font-feature-settings", feature_string.c_str());
+ }
}
} // namespace Widget