summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/attributes.cpp3
-rw-r--r--src/attributes.h3
-rw-r--r--src/style-internal.cpp61
-rw-r--r--src/style-internal.h54
-rw-r--r--src/style.cpp10
-rw-r--r--src/style.h3
6 files changed, 134 insertions, 0 deletions
diff --git a/src/attributes.cpp b/src/attributes.cpp
index c375ba903..9ba646ab4 100644
--- a/src/attributes.cpp
+++ b/src/attributes.cpp
@@ -480,6 +480,9 @@ static SPStyleProp const props[] = {
{SP_PROP_FONT_VARIANT_EAST_ASIAN, "font-variant-east-asian"},
{SP_PROP_FONT_FEATURE_SETTINGS, "font-feature-settings"},
+ /* Variable Fonts (CSS Fonts Module Level 4) */
+ {SP_PROP_FONT_VARIATION_SETTINGS, "font-variation-settings"},
+
/* Text */
{SP_PROP_TEXT_INDENT, "text-indent"},
{SP_PROP_TEXT_ALIGN, "text-align"},
diff --git a/src/attributes.h b/src/attributes.h
index c4658b85b..3fee14133 100644
--- a/src/attributes.h
+++ b/src/attributes.h
@@ -488,6 +488,9 @@ enum SPAttributeEnum {
SP_PROP_FONT_VARIANT_EAST_ASIAN,
SP_PROP_FONT_FEATURE_SETTINGS,
+ /* Variable Fonts (CSS Fonts Module Level 4) */
+ SP_PROP_FONT_VARIATION_SETTINGS,
+
/* Text Layout */
SP_PROP_TEXT_INDENT,
SP_PROP_TEXT_ALIGN,
diff --git a/src/style-internal.cpp b/src/style-internal.cpp
index 54d1a0867..34e737452 100644
--- a/src/style-internal.cpp
+++ b/src/style-internal.cpp
@@ -521,6 +521,67 @@ SPILengthOrNormal::operator==(const SPIBase& rhs) {
}
+// SPIVariableFontAxisOrNormal ----------------------------------------------------
+
+void
+SPIVariableFontAxisOrNormal::read( gchar const *str ) {
+
+ if( !str ) return;
+
+ if ( !strcmp(str, "normal") ) {
+ set = true;
+ inherit = false;
+ unit = SP_CSS_UNIT_NONE;
+ value = computed = 0.0;
+ normal = true;
+ return;
+ }
+
+ if (strlen(str) >= 6 && str[4]==' ') {
+ strncpy(axis_name, str, 4);
+ axis_name[4] = '\0';
+
+ SPILength::read( str + 5);
+ normal = false;
+ }
+};
+
+const Glib::ustring
+SPIVariableFontAxisOrNormal::write( guint const flags, SPStyleSrc const &style_src_req, SPIBase const *const base) const {
+
+ SPILength const *const my_base = dynamic_cast<const SPILength*>(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->normal) {
+ return (name + ":normal;");
+ } else {
+ return "\"" + Glib::ustring(axis_name) + "\" " + SPILength::write(flags, style_src_req, base);
+ }
+ }
+ return Glib::ustring("");
+}
+
+void
+SPIVariableFontAxisOrNormal::cascade( const SPIBase* const parent ) {
+ std::cerr << "SPIVariableFontAxisOrNormal::cascade(): TODO: Implement-me!" << std::endl;
+}
+
+void
+SPIVariableFontAxisOrNormal::merge( const SPIBase* const parent ) {
+ std::cerr << "SPIVariableFontAxisOrNormal::merge(): TODO: Implement-me!" << std::endl;
+}
+
+bool
+SPIVariableFontAxisOrNormal::operator==(const SPIBase& rhs) {
+ if( const SPIVariableFontAxisOrNormal* r = dynamic_cast<const SPIVariableFontAxisOrNormal*>(&rhs) ) {
+ if( normal && r->normal ) { return true; }
+ if( normal != r->normal ) { return false; }
+ return SPILength::operator==(rhs) && !strncmp(axis_name, r->axis_name, 4);
+ } else {
+ return false;
+ }
+}
// SPIEnum --------------------------------------------------------------
diff --git a/src/style-internal.h b/src/style-internal.h
index 154538833..3b23f2929 100644
--- a/src/style-internal.h
+++ b/src/style-internal.h
@@ -447,6 +447,60 @@ public:
};
+/// Extended length type internal to SPStyle.
+// Used for: font-variation-settings
+class SPIVariableFontAxisOrNormal : public SPILength
+{
+
+public:
+ SPIVariableFontAxisOrNormal()
+ : SPILength( "anonymous_length" ),
+ axis_name( "" ),
+ normal(true)
+ {}
+
+ SPIVariableFontAxisOrNormal( Glib::ustring const &name, gchar const *axis = NULL, float value = 0 )
+ : SPILength( name, value ),
+ normal(true)
+ {
+ strncpy(axis_name, axis, 5);
+ }
+
+ virtual ~SPIVariableFontAxisOrNormal()
+ {}
+
+ 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;
+ virtual void clear() {
+ SPILength::clear();
+ axis_name[0] = '\0';
+ normal = true;
+ }
+
+ virtual void cascade( const SPIBase* const parent );
+ virtual void merge( const SPIBase* const parent );
+
+ SPIVariableFontAxisOrNormal& operator=(const SPIVariableFontAxisOrNormal& rhs) {
+ SPILength::operator=(rhs);
+ strncpy(axis_name, rhs.axis_name, 5);
+ normal = rhs.normal;
+ return *this;
+ }
+
+ virtual bool operator==(const SPIBase& rhs);
+ virtual bool operator!=(const SPIBase& rhs) {
+ return !(*this == rhs);
+ }
+
+ // To do: make private
+public:
+ bool normal : 1;
+ gchar axis_name[5];
+};
+
+
/// Enum type internal to SPStyle.
// Used for many properties. 'font-stretch' and 'font-weight' must be special cased.
class SPIEnum : public SPIBase
diff --git a/src/style.cpp b/src/style.cpp
index 0b0358bb2..08dbcd38b 100644
--- a/src/style.cpp
+++ b/src/style.cpp
@@ -115,6 +115,9 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) :
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" ),
+ // Variable Fonts
+ font_variation_settings( "font-variation-settings" ), // SPIVariableFontAxisOrNormal
+
// Text related properties
text_indent( "text-indent", 0.0 ), // SPILength
text_align( "text-align", enum_text_align, SP_CSS_TEXT_ALIGN_START ),
@@ -298,6 +301,9 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) :
_properties.push_back( &font_variant_east_asian );
_properties.push_back( &font_feature_settings );
+ // Variable Fonts
+ _properties.push_back( &font_variation_settings );
+
_properties.push_back( &text_indent );
_properties.push_back( &text_align );
@@ -741,6 +747,10 @@ SPStyle::readIfUnset( gint id, gchar const *val, SPStyleSrc const &source ) {
font_feature_settings.readIfUnset( val, source );
break;
+ case SP_PROP_FONT_VARIATION_SETTINGS:
+ font_variation_settings.readIfUnset( val, source );
+ break;
+
/* Text */
case SP_PROP_TEXT_INDENT:
text_indent.readIfUnset( val, source );
diff --git a/src/style.h b/src/style.h
index 00c8c032a..66332a117 100644
--- a/src/style.h
+++ b/src/style.h
@@ -128,6 +128,9 @@ public:
/** Font feature settings (Low level access to TrueType tables) */
SPIString font_feature_settings;
+ /** Font variation settings (Low level access to OpenType variable font design-coordinate values) */
+ SPIVariableFontAxisOrNormal font_variation_settings;
+
/* Text ----------------------------- */
/** First line indent of paragraphs (css2 16.1) */