From c0b08b4f091641f70df0f5104f52c56ca360cc63 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 7 Jun 2018 11:44:33 +0200 Subject: Add GUI support for 'font-variant-east-asian' property. --- src/desktop-style.cpp | 20 +++- src/style-internal.cpp | 109 +++++++++++++++++- src/style-internal.h | 26 ++++- src/style.cpp | 4 +- src/style.h | 2 +- src/ui/widget/font-variants.cpp | 246 +++++++++++++++++++++++++++++++++++++++- src/ui/widget/font-variants.h | 26 ++++- 7 files changed, 421 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index a5cc75d15..0d9ae599e 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -1296,19 +1296,22 @@ objects_query_fontvariants (const std::vector &objects, SPStyle *style_ SPIEnum* position_res = &(style_res->font_variant_position); SPIEnum* caps_res = &(style_res->font_variant_caps); SPINumeric* numeric_res = &(style_res->font_variant_numeric); + SPIEastAsian* asian_res = &(style_res->font_variant_east_asian); // Stores 'and' of all values ligatures_res->computed = SP_CSS_FONT_VARIANT_LIGATURES_NORMAL; position_res->computed = SP_CSS_FONT_VARIANT_POSITION_NORMAL; caps_res->computed = SP_CSS_FONT_VARIANT_CAPS_NORMAL; numeric_res->computed = SP_CSS_FONT_VARIANT_NUMERIC_NORMAL; + asian_res->computed = SP_CSS_FONT_VARIANT_EAST_ASIAN_NORMAL; // Stores only differences ligatures_res->value = 0; position_res->value = 0; caps_res->value = 0; numeric_res->value = 0; - + asian_res->value = 0; + for (std::vector::const_iterator i = objects.begin(); i != objects.end(); ++i) { SPObject *obj = *i; @@ -1327,6 +1330,8 @@ objects_query_fontvariants (const std::vector &objects, SPStyle *style_ SPIEnum* position_in = &(style->font_variant_position); SPIEnum* caps_in = &(style->font_variant_caps); SPINumeric* numeric_in = &(style->font_variant_numeric); + SPIEastAsian* asian_in = &(style->font_variant_east_asian); + // computed stores which bits are on/off, only valid if same between all selected objects. // value stores which bits are different between objects. This is a bit of an abuse of // the values but then we don't need to add new variables to class. @@ -1343,20 +1348,25 @@ objects_query_fontvariants (const std::vector &objects, SPStyle *style_ numeric_res->value |= (numeric_res->computed ^ numeric_in->computed ); numeric_res->computed &= numeric_in->computed; + asian_res->value |= (asian_res->computed ^ asian_in->computed ); + asian_res->computed &= asian_in->computed; + } else { ligatures_res->computed = ligatures_in->computed; position_res->computed = position_in->computed; caps_res->computed = caps_in->computed; numeric_res->computed = numeric_in->computed; + asian_res->computed = asian_in->computed; } set = true; } - bool different = (style_res->font_variant_ligatures.value != 0 || - style_res->font_variant_position.value != 0 || - style_res->font_variant_caps.value != 0 || - style_res->font_variant_numeric.value != 0 ); + bool different = (style_res->font_variant_ligatures.value != 0 || + style_res->font_variant_position.value != 0 || + style_res->font_variant_caps.value != 0 || + style_res->font_variant_numeric.value != 0 || + style_res->font_variant_east_asian.value != 0); if (texts == 0 || !set) return QUERY_STYLE_NOTHING; diff --git a/src/style-internal.cpp b/src/style-internal.cpp index f8f2042c4..6178b30b4 100644 --- a/src/style-internal.cpp +++ b/src/style-internal.cpp @@ -17,7 +17,7 @@ * Copyright (C) 2001 Ximian, Inc. * Copyright (C) 2005 Monash University * Copyright (C) 2012 Kris De Gussem - * Copyright (C) 2014 Tavmjong Bah + * Copyright (C) 2014, 2018 Tavmjong Bah * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -1026,6 +1026,113 @@ SPINumeric::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase c } +// SPIEastAsian --------------------------------------------------- +// Used for 'font-variant-east-asian' +void +SPIEastAsian::read( gchar const *str ) { + + if( !str ) return; + + value = SP_CSS_FONT_VARIANT_EAST_ASIAN_NORMAL; + if( !strcmp(str, "inherit") ) { + set = true; + inherit = true; + } else if (!strcmp(str, "normal" )) { + // Defaults for TrueType + inherit = false; + set = true; + } else { + // We need to parse in order + std::vector tokens = Glib::Regex::split_simple("\\s+", str ); + for( unsigned i = 0; i < tokens.size(); ++i ) { + for (unsigned j = 0; enums[j].key; ++j ) { + if (tokens[i].compare( enums[j].key ) == 0 ) { + set = true; + inherit = false; + + // Must switch off incompatible value (turn on correct one below) + switch (enums[j].value ) { + case SP_CSS_FONT_VARIANT_EAST_ASIAN_JIS78: + case SP_CSS_FONT_VARIANT_EAST_ASIAN_JIS83: + case SP_CSS_FONT_VARIANT_EAST_ASIAN_JIS90: + case SP_CSS_FONT_VARIANT_EAST_ASIAN_JIS04: + case SP_CSS_FONT_VARIANT_EAST_ASIAN_SIMPLIFIED: + case SP_CSS_FONT_VARIANT_EAST_ASIAN_TRADITIONAL: + value &= ~SP_CSS_FONT_VARIANT_EAST_ASIAN_JIS78; + value &= ~SP_CSS_FONT_VARIANT_EAST_ASIAN_JIS83; + value &= ~SP_CSS_FONT_VARIANT_EAST_ASIAN_JIS90; + value &= ~SP_CSS_FONT_VARIANT_EAST_ASIAN_JIS04; + value &= ~SP_CSS_FONT_VARIANT_EAST_ASIAN_SIMPLIFIED; + value &= ~SP_CSS_FONT_VARIANT_EAST_ASIAN_TRADITIONAL; + break; + + case SP_CSS_FONT_VARIANT_EAST_ASIAN_FULL_WIDTH: + value &= ~SP_CSS_FONT_VARIANT_EAST_ASIAN_PROPORTIONAL_WIDTH; + break; + case SP_CSS_FONT_VARIANT_EAST_ASIAN_PROPORTIONAL_WIDTH: + value &= ~SP_CSS_FONT_VARIANT_EAST_ASIAN_FULL_WIDTH; + break; + + case SP_CSS_FONT_VARIANT_EAST_ASIAN_NORMAL: + case SP_CSS_FONT_VARIANT_EAST_ASIAN_RUBY: + // Do nothing + break; + + default: + std::cerr << "SPIEastasian::read(): Invalid value." << std::endl; + break; + } + + value |= enums[j].value; + } + } + } + } + computed = value; +} + +const Glib::ustring +SPIEastAsian::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const { + + SPIEnum const *const my_base = dynamic_cast(base); + bool dfp = (!inherits || !my_base || (my_base != this)); // Different from parent + bool src = (style_src_req == style_src || !(flags & SP_STYLE_FLAG_IFSRC)); + if (should_write(flags, set, dfp, src)) { + if (this->inherit) { + return (name + ":inherit" + important_str() + ";"); + } + if (value == SP_CSS_FONT_VARIANT_EAST_ASIAN_NORMAL ) { + return (name + ":normal" + important_str() + ";"); + } + + Glib::ustring return_string = name + ":"; + if ( value & SP_CSS_FONT_VARIANT_EAST_ASIAN_JIS78 ) + return_string += "jis78 "; + if ( value & SP_CSS_FONT_VARIANT_EAST_ASIAN_JIS83 ) + return_string += "jis83 "; + if ( value & SP_CSS_FONT_VARIANT_EAST_ASIAN_JIS90 ) + return_string += "jis90 "; + if ( value & SP_CSS_FONT_VARIANT_EAST_ASIAN_JIS04 ) + return_string += "jis04 "; + if ( value & SP_CSS_FONT_VARIANT_EAST_ASIAN_SIMPLIFIED ) + return_string += "simplified "; + if ( value & SP_CSS_FONT_VARIANT_EAST_ASIAN_TRADITIONAL ) + return_string += "traditional "; + if ( value & SP_CSS_FONT_VARIANT_EAST_ASIAN_FULL_WIDTH ) + return_string += "full-width "; + if ( value & SP_CSS_FONT_VARIANT_EAST_ASIAN_PROPORTIONAL_WIDTH ) + return_string += "proportional-width "; + if ( value & SP_CSS_FONT_VARIANT_EAST_ASIAN_RUBY ) + return_string += "ruby "; + return_string.erase( return_string.size() - 1 ); + return_string += important_str(); + return_string += ";"; + return return_string; + } + return Glib::ustring(""); +} + + // SPIString ------------------------------------------------------------ void diff --git a/src/style-internal.h b/src/style-internal.h index 0ca9b0445..7d2b3a89b 100644 --- a/src/style-internal.h +++ b/src/style-internal.h @@ -9,7 +9,7 @@ * Jon A. Cruz * Tavmjong Bah * - * Copyright (C) 2014 Tavmjong Bah + * Copyright (C) 2014, 2018 Tavmjong Bah * Copyright (C) 2010 Jon A. Cruz * Copyright (C) 2001-2002 Lauris Kaplinski * Copyright (C) 2001 Ximian, Inc. @@ -689,6 +689,30 @@ public: }; +/// SPIEnum w/ extra bits. The 'font-variants-east-asian' property is a complete mess that needs +/// special handling. Multiple key words can be specified, some exclusive of others. +class SPIEastAsian : public SPIEnum +{ + +public: + SPIEastAsian() : + SPIEnum( "anonymous_enumeastasian", NULL ) + {} + + SPIEastAsian( Glib::ustring const &name, SPStyleEnum const *enums) : + SPIEnum( name, enums, SP_CSS_FONT_VARIANT_EAST_ASIAN_NORMAL ) + {} + + virtual ~SPIEastAsian() + {} + + virtual void read( gchar const *str ); + virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET, + SPStyleSrc const &style_src_req = SP_STYLE_SRC_STYLE_PROP, + SPIBase const *const base = NULL ) const; +}; + + /// String type internal to SPStyle. // Used for 'marker', ..., 'font', 'font-family', 'inkscape-font-specification' class SPIString : public SPIBase diff --git a/src/style.cpp b/src/style.cpp index 03dec1e4b..ae3b86d1c 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -112,13 +112,13 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) : font(), // SPIFont font_specification( "-inkscape-font-specification" ), // SPIString - // Font variants + // Font variants (Features) font_variant_ligatures( "font-variant-ligatures", enum_font_variant_ligatures ), font_variant_position( "font-variant-position", enum_font_variant_position, SP_CSS_FONT_VARIANT_POSITION_NORMAL ), font_variant_caps( "font-variant-caps", enum_font_variant_caps, SP_CSS_FONT_VARIANT_CAPS_NORMAL ), font_variant_numeric( "font-variant-numeric", enum_font_variant_numeric ), font_variant_alternates("font-variant-alternates", enum_font_variant_alternates, SP_CSS_FONT_VARIANT_ALTERNATES_NORMAL ), - font_variant_east_asian("font-variant-east-asian", enum_font_variant_east_asian, SP_CSS_FONT_VARIANT_EAST_ASIAN_NORMAL ), + font_variant_east_asian("font-variant-east-asian", enum_font_variant_east_asian ), font_feature_settings( "font-feature-settings", "normal" ), // Variable Fonts diff --git a/src/style.h b/src/style.h index 8accd0384..c01f5d883 100644 --- a/src/style.h +++ b/src/style.h @@ -129,7 +129,7 @@ public: /** Font variant alternates (alternates/swatches) */ SPIEnum font_variant_alternates; /** Font variant East Asian */ - SPIEnum font_variant_east_asian; + SPIEastAsian font_variant_east_asian; /** Font feature settings (Low level access to TrueType tables) */ SPIString font_feature_settings; diff --git a/src/ui/widget/font-variants.cpp b/src/ui/widget/font-variants.cpp index 61cdb6517..6d1da6d60 100644 --- a/src/ui/widget/font-variants.cpp +++ b/src/ui/widget/font-variants.cpp @@ -61,13 +61,27 @@ namespace Widget { _numeric_ordinal ( Glib::ustring(C_("Font feature", "Ordinal" )) ), _numeric_slashed_zero ( Glib::ustring(C_("Font feature", "Slashed Zero" )) ), + _asian_frame ( Glib::ustring(C_("Font feature", "East Asian" )) ), + _asian_default_variant ( Glib::ustring(C_("Font feature", "Default" )) ), + _asian_jis78 ( Glib::ustring(C_("Font feature", "JIS78" )) ), + _asian_jis83 ( Glib::ustring(C_("Font feature", "JIS83" )) ), + _asian_jis90 ( Glib::ustring(C_("Font feature", "JIS90" )) ), + _asian_jis04 ( Glib::ustring(C_("Font feature", "JIS04" )) ), + _asian_simplified ( Glib::ustring(C_("Font feature", "Simplified" )) ), + _asian_traditional ( Glib::ustring(C_("Font feature", "Traditional" )) ), + _asian_default_width ( Glib::ustring(C_("Font feature", "Default" )) ), + _asian_full_width ( Glib::ustring(C_("Font feature", "Full Width" )) ), + _asian_proportional_width ( Glib::ustring(C_("Font feature", "Proportional" )) ), + _asian_ruby ( Glib::ustring(C_("Font feature", "Ruby" )) ), + _feature_frame ( Glib::ustring(C_("Font feature", "Feature Settings")) ), _feature_label ( Glib::ustring(C_("Font feature", "Selection has different Feature Settings!")) ), _ligatures_changed( false ), _position_changed( false ), _caps_changed( false ), - _numeric_changed( false ) + _numeric_changed( false ), + _asian_changed( false ) { @@ -264,6 +278,62 @@ namespace Widget { _numeric_frame.add( _numeric_grid ); pack_start( _numeric_frame, Gtk::PACK_SHRINK ); + // East Asian + + // Add tooltips + _asian_default_variant.set_tooltip_text ( _("Default variant.")); + _asian_jis78.set_tooltip_text( _("JIS78 forms. OpenType table: 'jp78'.")); + _asian_jis83.set_tooltip_text( _("JIS83 forms. OpenType table: 'jp83'.")); + _asian_jis90.set_tooltip_text( _("JIS90 forms. OpenType table: 'jp90'.")); + _asian_jis04.set_tooltip_text( _("JIS2004 forms. OpenType table: 'jp04'.")); + _asian_simplified.set_tooltip_text( _("Simplified forms. OpenType table: 'smpl'.")); + _asian_traditional.set_tooltip_text( _("Traditional forms. OpenType table: 'trad'.")); + _asian_default_width.set_tooltip_text ( _("Default width.")); + _asian_full_width.set_tooltip_text( _("Full width variants. OpenType table: 'fwid'.")); + _asian_proportional_width.set_tooltip_text(_("Proportional width variants. OpenType table: 'pwid'.")); + _asian_ruby.set_tooltip_text( _("Ruby variants. OpenType table: 'ruby'.")); + + // Add signals + _asian_default_variant.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::asian_callback) ); + _asian_jis78.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::asian_callback) ); + _asian_jis83.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::asian_callback) ); + _asian_jis90.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::asian_callback) ); + _asian_jis04.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::asian_callback) ); + _asian_simplified.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::asian_callback) ); + _asian_traditional.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::asian_callback) ); + _asian_default_width.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::asian_callback) ); + _asian_full_width.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::asian_callback) ); + _asian_proportional_width.signal_clicked().connect (sigc::mem_fun(*this, &FontVariants::asian_callback) ); + _asian_ruby.signal_clicked().connect( sigc::mem_fun(*this, &FontVariants::asian_callback) ); + + // Add to frame + _asian_grid.attach (_asian_default_variant, 0, 0, 1, 1); + _asian_grid.attach (_asian_jis78, 1, 0, 1, 1); + _asian_grid.attach (_asian_jis83, 2, 0, 1, 1); + _asian_grid.attach (_asian_jis90, 3, 0, 1, 1); + _asian_grid.attach (_asian_jis04, 4, 0, 1, 1); + _asian_grid.attach (_asian_simplified, 5, 0, 1, 1); + _asian_grid.attach (_asian_traditional, 6, 0, 1, 1); + _asian_grid.attach (_asian_default_width, 0, 1, 1, 1); + _asian_grid.attach (_asian_full_width, 1, 1, 1, 1); + _asian_grid.attach (_asian_proportional_width, 2, 1, 1, 1); + _asian_grid.attach (_asian_ruby, 0, 2, 1, 1); + + _asian_frame.add( _asian_grid ); + pack_start( _asian_frame, Gtk::PACK_SHRINK ); + + // Group Buttons + Gtk::RadioButton::Group asian_variant_group = _asian_default_variant.get_group(); + _asian_jis78.set_group(asian_variant_group); + _asian_jis83.set_group(asian_variant_group); + _asian_jis90.set_group(asian_variant_group); + _asian_jis04.set_group(asian_variant_group); + _asian_simplified.set_group(asian_variant_group); + _asian_traditional.set_group(asian_variant_group); + + Gtk::RadioButton::Group asian_width_group = _asian_default_width.get_group(); + _asian_full_width.set_group (asian_width_group); + _asian_proportional_width.set_group (asian_width_group); // Feature settings --------------------- @@ -341,6 +411,18 @@ namespace Widget { _changed_signal.emit(); } + void + FontVariants::asian_init() { + // std::cout << "FontVariants::asian_init()" << std::endl; + } + + void + FontVariants::asian_callback() { + // std::cout << "FontVariants::asian_callback()" << std::endl; + _asian_changed = true; + _changed_signal.emit(); + } + void FontVariants::feature_init() { // std::cout << "FontVariants::feature_init()" << std::endl; @@ -440,6 +522,47 @@ 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 ); + _asian_all = query->font_variant_east_asian.computed; + _asian_mix = query->font_variant_east_asian.value; + + if (_asian_all & SP_CSS_FONT_VARIANT_EAST_ASIAN_JIS78) { + _asian_jis78.set_active(); + } else if (_asian_all & SP_CSS_FONT_VARIANT_EAST_ASIAN_JIS83) { + _asian_jis83.set_active(); + } else if (_asian_all & SP_CSS_FONT_VARIANT_EAST_ASIAN_JIS90) { + _asian_jis90.set_active(); + } else if (_asian_all & SP_CSS_FONT_VARIANT_EAST_ASIAN_JIS04) { + _asian_jis04.set_active(); + } else if (_asian_all & SP_CSS_FONT_VARIANT_EAST_ASIAN_SIMPLIFIED) { + _asian_simplified.set_active(); + } else if (_asian_all & SP_CSS_FONT_VARIANT_EAST_ASIAN_TRADITIONAL) { + _asian_traditional.set_active(); + } else { + _asian_default_variant.set_active(); + } + + if (_asian_all & SP_CSS_FONT_VARIANT_EAST_ASIAN_FULL_WIDTH) { + _asian_full_width.set_active(); + } else if (_asian_all & SP_CSS_FONT_VARIANT_EAST_ASIAN_PROPORTIONAL_WIDTH) { + _asian_proportional_width.set_active(); + } else { + _asian_default_width.set_active(); + } + + _asian_ruby.set_active ( _asian_all & SP_CSS_FONT_VARIANT_EAST_ASIAN_RUBY ); + + _asian_jis78.set_inconsistent( _asian_mix & SP_CSS_FONT_VARIANT_EAST_ASIAN_JIS78); + _asian_jis83.set_inconsistent( _asian_mix & SP_CSS_FONT_VARIANT_EAST_ASIAN_JIS83); + _asian_jis90.set_inconsistent( _asian_mix & SP_CSS_FONT_VARIANT_EAST_ASIAN_JIS90); + _asian_jis04.set_inconsistent( _asian_mix & SP_CSS_FONT_VARIANT_EAST_ASIAN_JIS04); + _asian_simplified.set_inconsistent( _asian_mix & SP_CSS_FONT_VARIANT_EAST_ASIAN_SIMPLIFIED); + _asian_traditional.set_inconsistent( _asian_mix & SP_CSS_FONT_VARIANT_EAST_ASIAN_TRADITIONAL); + _asian_full_width.set_inconsistent( _asian_mix & SP_CSS_FONT_VARIANT_EAST_ASIAN_FULL_WIDTH); + _asian_proportional_width.set_inconsistent(_asian_mix & SP_CSS_FONT_VARIANT_EAST_ASIAN_PROPORTIONAL_WIDTH); + _asian_ruby.set_inconsistent( _asian_mix & SP_CSS_FONT_VARIANT_EAST_ASIAN_RUBY); + + + if( query->font_feature_settings.value ) _feature_entry.set_text( query->font_feature_settings.value ); if( different_features ) { @@ -584,6 +707,61 @@ namespace Widget { _numeric_slashed_zero.set_sensitive( false ); } + // East-Asian + if((it = res->openTypeTables.find("jp78"))!= res->openTypeTables.end()) { + _asian_jis78.set_sensitive(); + } else { + _asian_jis78.set_sensitive( false ); + } + + if((it = res->openTypeTables.find("jp83"))!= res->openTypeTables.end()) { + _asian_jis83.set_sensitive(); + } else { + _asian_jis83.set_sensitive( false ); + } + + if((it = res->openTypeTables.find("jp90"))!= res->openTypeTables.end()) { + _asian_jis90.set_sensitive(); + } else { + _asian_jis90.set_sensitive( false ); + } + + if((it = res->openTypeTables.find("jp04"))!= res->openTypeTables.end()) { + _asian_jis04.set_sensitive(); + } else { + _asian_jis04.set_sensitive( false ); + } + + if((it = res->openTypeTables.find("smpl"))!= res->openTypeTables.end()) { + _asian_simplified.set_sensitive(); + } else { + _asian_simplified.set_sensitive( false ); + } + + if((it = res->openTypeTables.find("trad"))!= res->openTypeTables.end()) { + _asian_traditional.set_sensitive(); + } else { + _asian_traditional.set_sensitive( false ); + } + + if((it = res->openTypeTables.find("fwid"))!= res->openTypeTables.end()) { + _asian_full_width.set_sensitive(); + } else { + _asian_full_width.set_sensitive( false ); + } + + if((it = res->openTypeTables.find("pwid"))!= res->openTypeTables.end()) { + _asian_proportional_width.set_sensitive(); + } else { + _asian_proportional_width.set_sensitive( false ); + } + + if((it = res->openTypeTables.find("ruby"))!= res->openTypeTables.end()) { + _asian_ruby.set_sensitive(); + } else { + _asian_ruby.set_sensitive( false ); + } + // List available ligatures Glib::ustring markup_liga; Glib::ustring markup_dlig; @@ -680,6 +858,15 @@ namespace Widget { 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 ); + if( (it = table_copy.find("jp78")) != table_copy.end() ) table_copy.erase( it ); + if( (it = table_copy.find("jp83")) != table_copy.end() ) table_copy.erase( it ); + if( (it = table_copy.find("jp90")) != table_copy.end() ) table_copy.erase( it ); + if( (it = table_copy.find("jp04")) != table_copy.end() ) table_copy.erase( it ); + if( (it = table_copy.find("smpl")) != table_copy.end() ) table_copy.erase( it ); + if( (it = table_copy.find("trad")) != table_copy.end() ) table_copy.erase( it ); + if( (it = table_copy.find("fwid")) != table_copy.end() ) table_copy.erase( it ); + if( (it = table_copy.find("pwid")) != table_copy.end() ) table_copy.erase( it ); + if( (it = table_copy.find("ruby")) != table_copy.end() ) table_copy.erase( it ); // An incomplete list of tables that should not be exposed to the user: if( (it = table_copy.find("abvs")) != table_copy.end() ) table_copy.erase( it ); @@ -872,6 +1059,38 @@ namespace Widget { sp_repr_css_set_property(css, "font-variant-numeric", css_string.c_str() ); } + // East Asian + bool default_variant = _asian_default_variant.get_active(); + bool jis78 = _asian_jis78.get_active(); + bool jis83 = _asian_jis83.get_active(); + bool jis90 = _asian_jis90.get_active(); + bool jis04 = _asian_jis04.get_active(); + bool simplified = _asian_simplified.get_active(); + bool traditional = _asian_traditional.get_active(); + bool asian_width = _asian_default_width.get_active(); + bool fwid = _asian_full_width.get_active(); + bool pwid = _asian_proportional_width.get_active(); + bool ruby = _asian_ruby.get_active(); + + if (default_style & asian_width & !ruby) { + sp_repr_css_set_property(css, "font-variant-east-asian", "normal"); + } else { + Glib::ustring css_string; + if (jis78) css_string += "jis78 "; + if (jis83) css_string += "jis83 "; + if (jis90) css_string += "jis90 "; + if (jis04) css_string += "jis04 "; + if (simplified) css_string += "simplfied "; + if (traditional) css_string += "traditional "; + + if (fwid) css_string += "fwid "; + if (pwid) css_string += "pwid "; + + if (ruby) css_string += "ruby "; + + sp_repr_css_set_property(css, "font-variant-east-asian", css_string.c_str() ); + } + // Feature settings Glib::ustring feature_string = _feature_entry.get_text(); if( !feature_string.empty() || feature_string.compare( "normal" ) ) { @@ -932,6 +1151,31 @@ namespace Widget { if (ordinal) markup += "ordn=1,"; if (slashed_zero) markup += "zero=1,"; + // East Asian + bool default_variant = _asian_default_variant.get_active(); + bool jis78 = _asian_jis78.get_active(); + bool jis83 = _asian_jis83.get_active(); + bool jis90 = _asian_jis90.get_active(); + bool jis04 = _asian_jis04.get_active(); + bool simplified = _asian_simplified.get_active(); + bool traditional = _asian_traditional.get_active(); + bool asian_width = _asian_default_width.get_active(); + bool fwid = _asian_full_width.get_active(); + bool pwid = _asian_proportional_width.get_active(); + bool ruby = _asian_ruby.get_active(); + + if (jis78 ) markup += "jp78=1,"; + if (jis83 ) markup += "jp83=1,"; + if (jis90 ) markup += "jp90=1,"; + if (jis04 ) markup += "jp04=1,"; + if (simplified ) markup += "smpl=1,"; + if (traditional ) markup += "trad=1,"; + + if (fwid ) markup += "fwid=1,"; + if (pwid ) markup += "pwid=1,"; + + if (ruby ) markup += "ruby=1,"; + // Feature settings Glib::ustring feature_string = _feature_entry.get_text(); if( !feature_string.empty() && feature_string.compare( "normal" ) != 0 ) { diff --git a/src/ui/widget/font-variants.h b/src/ui/widget/font-variants.h index ff8b1d781..f97f93a82 100644 --- a/src/ui/widget/font-variants.h +++ b/src/ui/widget/font-variants.h @@ -97,7 +97,25 @@ protected: Gtk::CheckButton _numeric_slashed_zero; Gtk::Label _numeric_slashed_zero_label; + // East Asian: Complicated! + Gtk::Expander _asian_frame; + Gtk::Grid _asian_grid; + Gtk::RadioButton _asian_default_variant; + Gtk::RadioButton _asian_jis78; + Gtk::RadioButton _asian_jis83; + Gtk::RadioButton _asian_jis90; + Gtk::RadioButton _asian_jis04; + Gtk::RadioButton _asian_simplified; + Gtk::RadioButton _asian_traditional; + + Gtk::RadioButton _asian_default_width; + Gtk::RadioButton _asian_full_width; + Gtk::RadioButton _asian_proportional_width; + + Gtk::CheckButton _asian_ruby; + + // ----- Gtk::Expander _feature_frame; Gtk::VBox _feature_vbox; Gtk::Entry _feature_entry; @@ -118,6 +136,9 @@ private: void numeric_init(); void numeric_callback(); + void asian_init(); + void asian_callback(); + void feature_init(); void feature_callback(); @@ -126,17 +147,20 @@ private: unsigned _position_all; unsigned _caps_all; unsigned _numeric_all; - + unsigned _asian_all; + unsigned _ligatures_mix; unsigned _position_mix; unsigned _caps_mix; unsigned _numeric_mix; + unsigned _asian_mix; bool _ligatures_changed; bool _position_changed; bool _caps_changed; bool _numeric_changed; bool _feature_changed; + bool _asian_changed; sigc::signal _changed_signal; -- cgit v1.2.3