diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-07-24 23:26:11 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2015-07-24 23:26:11 +0000 |
| commit | 7b6ffd82650ee1e20a53b0631d5c2dddef58e8d5 (patch) | |
| tree | 48cae26bf789b11d79f72efc16a6676f960eaaa6 /src/style.cpp | |
| parent | update to trunk (diff) | |
| parent | 3D box tool: the shift key must not prevent snapping of the vanishing point. ... (diff) | |
| download | inkscape-7b6ffd82650ee1e20a53b0631d5c2dddef58e8d5.tar.gz inkscape-7b6ffd82650ee1e20a53b0631d5c2dddef58e8d5.zip | |
update to trunk
(bzr r12588.1.45)
Diffstat (limited to 'src/style.cpp')
| -rw-r--r-- | src/style.cpp | 157 |
1 files changed, 155 insertions, 2 deletions
diff --git a/src/style.cpp b/src/style.cpp index b65bff53f..d8402e08a 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -14,7 +14,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-2015 Tavmjong Bah * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -118,6 +118,15 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) : font(), // SPIFont font_specification( "-inkscape-font-specification" ), // SPIString + // Font variants + 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_feature_settings( "font-feature-settings", "normal" ), + // Text related properties text_indent( "text-indent", 0.0 ), // SPILength text_align( "text-align", enum_text_align, SP_CSS_TEXT_ALIGN_START ), @@ -288,6 +297,15 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) : _properties.push_back( &font ); _properties.push_back( &font_specification ); + // Font variants + _properties.push_back( &font_variant_ligatures ); + _properties.push_back( &font_variant_position ); + _properties.push_back( &font_variant_caps ); + _properties.push_back( &font_variant_numeric ); + _properties.push_back( &font_variant_alternates ); + _properties.push_back( &font_variant_east_asian ); + _properties.push_back( &font_feature_settings ); + _properties.push_back( &text_indent ); _properties.push_back( &text_align ); @@ -374,6 +392,14 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) : // _propmap.insert( std::make_pair( font.name, reinterpret_cast<SPIBasePtr>(&SPStyle::font ) ) ); // _propmap.insert( std::make_pair( font_specification.name, reinterpret_cast<SPIBasePtr>(&SPStyle::font_specification ) ) ); + // font_variant_ligatures ); + // font_variant_position ); + // font_variant_caps ); + // font_variant_numeric ); + // font_variant_alternates ); + // font_variant_east_asian ); + // font_feature_settings ); + // _propmap.insert( std::make_pair( text_indent.name, reinterpret_cast<SPIBasePtr>(&SPStyle::text_indent ) ) ); // _propmap.insert( std::make_pair( text_align.name, reinterpret_cast<SPIBasePtr>(&SPStyle::text_align ) ) ); @@ -573,7 +599,15 @@ SPStyle::read( SPObject *object, Inkscape::XML::Node *repr ) { /* 3 Presentation attributes */ // std::cout << " MERGING PRESENTATION ATTRIBUTES" << std::endl; for(std::vector<SPIBase*>::size_type i = 0; i != _properties.size(); ++i) { - _properties[i]->readAttribute( repr ); + + // Shorthands are not allowed as presentation properites. Note: text-decoration and + // font-variant are converted to shorthands in CSS 3 but can still be read as a + // non-shorthand for compatability with older renders, so they should not be in this list. + // We could add a flag to SPIBase to avoid string comparison. + if( _properties[i]->name.compare( "font" ) != 0 && + _properties[i]->name.compare( "marker" ) != 0 ) { + _properties[i]->readAttribute( repr ); + } } // for(SPPropMap::iterator i = _propmap.begin(); i != _propmap.end(); ++i ) { // (this->*(i->second)).readAttribute( repr ); @@ -686,6 +720,29 @@ SPStyle::readIfUnset( gint id, gchar const *val ) { font.readIfUnset( val ); break; + /* Font Variants CSS 3 */ + case SP_PROP_FONT_VARIANT_LIGATURES: + font_variant_ligatures.readIfUnset( val ); + break; + case SP_PROP_FONT_VARIANT_POSITION: + font_variant_position.readIfUnset( val ); + break; + case SP_PROP_FONT_VARIANT_CAPS: + font_variant_caps.readIfUnset( val ); + break; + case SP_PROP_FONT_VARIANT_NUMERIC: + font_variant_numeric.readIfUnset( val ); + break; + case SP_PROP_FONT_VARIANT_ALTERNATES: + font_variant_alternates.readIfUnset( val ); + break; + case SP_PROP_FONT_VARIANT_EAST_ASIAN: + font_variant_east_asian.readIfUnset( val ); + break; + case SP_PROP_FONT_FEATURE_SETTINGS: + font_feature_settings.readIfUnset( val ); + break; + /* Text */ case SP_PROP_TEXT_INDENT: text_indent.readIfUnset( val ); @@ -1133,6 +1190,92 @@ SPStyle::_mergeObjectStylesheet( SPObject const *const object ) { } } +std::string +SPStyle::getFontFeatureString() { + + std::string feature_string; + + if ( !(font_variant_ligatures.value & SP_CSS_FONT_VARIANT_LIGATURES_COMMON) ) + feature_string += "liga 0, clig 0, "; + if ( font_variant_ligatures.value & SP_CSS_FONT_VARIANT_LIGATURES_DISCRETIONARY ) + feature_string += "dlig, "; + if ( font_variant_ligatures.value & SP_CSS_FONT_VARIANT_LIGATURES_HISTORICAL ) + feature_string += "hlig, "; + if ( !(font_variant_ligatures.value & SP_CSS_FONT_VARIANT_LIGATURES_CONTEXTUAL) ) + feature_string += "calt 0, "; + + if ( font_variant_position.value & SP_CSS_FONT_VARIANT_POSITION_SUB ) + feature_string += "subs, "; + if ( font_variant_position.value & SP_CSS_FONT_VARIANT_POSITION_SUPER ) + feature_string += "sups, "; + + if ( font_variant_caps.value & SP_CSS_FONT_VARIANT_CAPS_SMALL ) + feature_string += "smcp, "; + if ( font_variant_caps.value & SP_CSS_FONT_VARIANT_CAPS_ALL_SMALL ) + feature_string += "smcp, c2sc, "; + if ( font_variant_caps.value & SP_CSS_FONT_VARIANT_CAPS_PETITE ) + feature_string += "pcap, "; + if ( font_variant_caps.value & SP_CSS_FONT_VARIANT_CAPS_ALL_PETITE ) + feature_string += "pcap, c2pc, "; + if ( font_variant_caps.value & SP_CSS_FONT_VARIANT_CAPS_UNICASE ) + feature_string += "unic, "; + if ( font_variant_caps.value & SP_CSS_FONT_VARIANT_CAPS_TITLING ) + feature_string += "titl, "; + + if ( font_variant_numeric.value & SP_CSS_FONT_VARIANT_NUMERIC_LINING_NUMS ) + feature_string += "lnum, "; + if ( font_variant_numeric.value & SP_CSS_FONT_VARIANT_NUMERIC_OLDSTYLE_NUMS ) + feature_string += "onum, "; + if ( font_variant_numeric.value & SP_CSS_FONT_VARIANT_NUMERIC_PROPORTIONAL_NUMS ) + feature_string += "pnum, "; + if ( font_variant_numeric.value & SP_CSS_FONT_VARIANT_NUMERIC_TABULAR_NUMS ) + feature_string += "tnum, "; + if ( font_variant_numeric.value & SP_CSS_FONT_VARIANT_NUMERIC_DIAGONAL_FRACTIONS ) + feature_string += "frac, "; + if ( font_variant_numeric.value & SP_CSS_FONT_VARIANT_NUMERIC_STACKED_FRACTIONS ) + feature_string += "afrc, "; + if ( font_variant_numeric.value & SP_CSS_FONT_VARIANT_NUMERIC_ORDINAL ) + feature_string += "ordn, "; + if ( font_variant_numeric.value & SP_CSS_FONT_VARIANT_NUMERIC_SLASHED_ZERO ) + feature_string += "zero, "; + + if( font_variant_east_asian.value & SP_CSS_FONT_VARIANT_EAST_ASIAN_JIS78 ) + feature_string += "jp78, "; + if( font_variant_east_asian.value & SP_CSS_FONT_VARIANT_EAST_ASIAN_JIS83 ) + feature_string += "jp83, "; + if( font_variant_east_asian.value & SP_CSS_FONT_VARIANT_EAST_ASIAN_JIS90 ) + feature_string += "jp90, "; + if( font_variant_east_asian.value & SP_CSS_FONT_VARIANT_EAST_ASIAN_JIS04 ) + feature_string += "jp04, "; + if( font_variant_east_asian.value & SP_CSS_FONT_VARIANT_EAST_ASIAN_SIMPLIFIED ) + feature_string += "smpl, "; + if( font_variant_east_asian.value & SP_CSS_FONT_VARIANT_EAST_ASIAN_TRADITIONAL ) + feature_string += "trad, "; + if( font_variant_east_asian.value & SP_CSS_FONT_VARIANT_EAST_ASIAN_FULL_WIDTH ) + feature_string += "fwid, "; + if( font_variant_east_asian.value & SP_CSS_FONT_VARIANT_EAST_ASIAN_PROPORTIONAL_WIDTH ) + feature_string += "pwid, "; + if( font_variant_east_asian.value & SP_CSS_FONT_VARIANT_EAST_ASIAN_RUBY ) + feature_string += "ruby, "; + + if ( strcmp( font_feature_settings.value, "normal") ) { + // We do no sanity checking... + feature_string += font_feature_settings.value; + feature_string += ", "; + } + + if (feature_string.empty()) { + feature_string = "normal"; + } else { + // Remove last ", " + feature_string.erase( feature_string.size() - 1 ); + feature_string.erase( feature_string.size() - 1 ); + } + + return feature_string; +} + + // Internal /** * Release callback. @@ -1169,10 +1312,12 @@ void sp_style_filter_ref_changed(SPObject *old_ref, SPObject *ref, SPStyle *style) { if (old_ref) { + (dynamic_cast<SPFilter *>( old_ref ))->_refcount--; style->filter_modified_connection.disconnect(); } if ( SP_IS_FILTER(ref)) { + (dynamic_cast<SPFilter *>( ref ))->_refcount++; style->filter_modified_connection = ref->connectModified(sigc::bind(sigc::ptr_fun(&sp_style_filter_ref_modified), style)); } @@ -1652,6 +1797,14 @@ sp_css_attr_unset_text(SPCSSAttr *css) sp_repr_css_set_property(css, "text-decoration-color", NULL); sp_repr_css_set_property(css, "text-decoration-style", NULL); + sp_repr_css_set_property(css, "font-variant-ligatures", NULL); + sp_repr_css_set_property(css, "font-variant-position", NULL); + sp_repr_css_set_property(css, "font-variant-caps", NULL); + sp_repr_css_set_property(css, "font-variant-numeric", NULL); + sp_repr_css_set_property(css, "font-variant-alternates", NULL); + sp_repr_css_set_property(css, "font-variant-east-asian", NULL); + sp_repr_css_set_property(css, "font-feature-settings", NULL); + return css; } |
