summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTomasz Boczkowski <penginsbacon@gmail.com>2015-05-17 09:20:36 +0000
committerTomasz Boczkowski <penginsbacon@gmail.com>2015-05-17 09:20:36 +0000
commit447b1bcfc29b92f76a9788f5b71dff96ee632b80 (patch)
treeb57b369ec150bcd6242372bd6cbd6b289a5c8902 /src
parentmerged trunk (diff)
parentFix attributes unit test. (diff)
downloadinkscape-447b1bcfc29b92f76a9788f5b71dff96ee632b80.tar.gz
inkscape-447b1bcfc29b92f76a9788f5b71dff96ee632b80.zip
merged trunk
(bzr r14059.1.27)
Diffstat (limited to 'src')
-rw-r--r--src/attributes-test.h34
-rw-r--r--src/desktop-style.cpp85
-rw-r--r--src/desktop-style.h2
-rw-r--r--src/selection.cpp1
-rw-r--r--src/sp-offset.cpp2
-rw-r--r--src/style-enums.h63
-rw-r--r--src/style-internal.cpp130
-rw-r--r--src/style-internal.h49
-rw-r--r--src/style-test.h17
-rw-r--r--src/style.cpp2
-rw-r--r--src/style.h2
-rw-r--r--src/ui/CMakeLists.txt2
-rw-r--r--src/ui/dialog/text-edit.cpp14
-rw-r--r--src/ui/dialog/text-edit.h4
-rw-r--r--src/ui/widget/Makefile_insert6
-rw-r--r--src/ui/widget/font-variants.cpp375
-rw-r--r--src/ui/widget/font-variants.h137
17 files changed, 886 insertions, 39 deletions
diff --git a/src/attributes-test.h b/src/attributes-test.h
index 7379e4e85..411304ec3 100644
--- a/src/attributes-test.h
+++ b/src/attributes-test.h
@@ -40,6 +40,10 @@ public:
I've added these manually.
SVG 2: white-space, shape-inside, shape-outside, shape-padding, shape-margin
+ SVG 2: text-decoration-fill, text-decoration-stroke
+ SVG 2: solid-color, solid-opacity
+ SVG 2: Hatches and Meshes
+ CSS 3: font-variant-xxx, font-feature-settings
*/
struct {char const *attr; bool supported;} const all_attrs[] = {
{"attributeName", true},
@@ -124,11 +128,18 @@ struct {char const *attr; bool supported;} const all_attrs[] = {
{"flood-color", true},
{"flood-opacity", true},
{"font-family", true},
+ {"font-feature-settings", true},
{"font-size", true},
{"font-size-adjust", true},
{"font-stretch", true},
{"font-style", true},
{"font-variant", true},
+ {"font-variant-ligatures", true},
+ {"font-variant-position", true},
+ {"font-variant-caps", true},
+ {"font-variant-numeric", true},
+ {"font-variant-east-asian", true},
+ {"font-variant-alternates", true},
{"font-weight", true},
{"format", false},
{"from", true},
@@ -288,6 +299,8 @@ struct {char const *attr; bool supported;} const all_attrs[] = {
{"text-decoration-line", true},
{"text-decoration-style", true},
{"text-decoration-color", true},
+ {"text-decoration-fill", true},
+ {"text-decoration-stroke", true},
{"text-indent", true},
{"text-rendering", true},
{"text-transform", true},
@@ -381,8 +394,11 @@ struct {char const *attr; bool supported;} const all_attrs[] = {
{"inkscape:pageopacity", true},
{"inkscape:pageshadow", true},
{"inkscape:path-effect", true},
+ // SPItem
{"inkscape:transform-center-x", true},
{"inkscape:transform-center-y", true},
+ {"inkscape:highlight-color", true},
+ // Namedview
{"inkscape:zoom", true},
{"inkscape:cx", true},
{"inkscape:cy", true},
@@ -392,6 +408,7 @@ struct {char const *attr; bool supported;} const all_attrs[] = {
{"inkscape:window-y", true},
{"inkscape:window-maximized", true},
{"inkscape:current-layer", true},
+ // Connector tool
{"inkscape:connector-type", true},
{"inkscape:connection-start", true},
{"inkscape:connection-end", true},
@@ -401,10 +418,12 @@ struct {char const *attr; bool supported;} const all_attrs[] = {
{"inkscape:connector-curvature", true},
{"inkscape:connector-avoid", true},
{"inkscape:connector-spacing", true},
+ // Ellipse, Spiral, Star
{"sodipodi:cx", true},
{"sodipodi:cy", true},
{"sodipodi:rx", true},
{"sodipodi:ry", true},
+ // Box tool
{"inkscape:perspectiveID", true},
{"inkscape:corner0", true},
{"inkscape:corner7", true},
@@ -414,6 +433,7 @@ struct {char const *attr; bool supported;} const all_attrs[] = {
{"inkscape:vp_y", true},
{"inkscape:vp_z", true},
{"inkscape:persp3d-origin", true},
+ // Star tool
{"sodipodi:start", true},
{"sodipodi:end", true},
{"sodipodi:open", true},
@@ -446,9 +466,19 @@ struct {char const *attr; bool supported;} const all_attrs[] = {
{"inkscape:layoutOptions", true},
{"osb:paint", true},
+ /* SPSolidColor" */
+ {"solid-color", true},
+ {"solid-opacity", true},
+
/* SPMeshPatch */
{"tensor", true},
+ /* SPHash */
+ {"hatchUnits", true},
+ {"hatchContentUnits", true},
+ {"hatchTransform", true},
+ {"pitch", true},
+
/* SPNamedView */
{"fit-margin-top", true},
{"fit-margin-left", true},
@@ -485,8 +515,10 @@ struct {char const *attr; bool supported;} const all_attrs[] = {
{"pagecolor", true},
/* SPGuide */
- {"position", true}
+ {"position", true},
+ /* SPTag */
+ {"inkscape:expanded", true}
};
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp
index fb92ffaf5..3bb0ce71a 100644
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
@@ -1168,6 +1168,88 @@ objects_query_fontstyle (const std::vector<SPItem*> &objects, SPStyle *style_res
}
}
+int
+objects_query_fontvariants (const std::vector<SPItem*> &objects, SPStyle *style_res)
+{
+ bool set = false;
+
+ int texts = 0;
+
+ SPILigatures* ligatures_res = &(style_res->font_variant_ligatures);
+ SPIEnum* position_res = &(style_res->font_variant_position);
+ SPIEnum* caps_res = &(style_res->font_variant_caps);
+
+ // 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;
+
+ // Stores only differences
+ ligatures_res->value = 0;
+ position_res->value = 0;
+ caps_res->value = 0;
+
+ for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) {
+ SPObject *obj = *i;
+
+ if (!isTextualItem(obj)) {
+ continue;
+ }
+
+ SPStyle *style = obj->style;
+ if (!style) {
+ continue;
+ }
+
+ texts ++;
+
+ SPILigatures* ligatures_in = &(style->font_variant_ligatures);
+ SPIEnum* position_in = &(style->font_variant_position);
+ SPIEnum* caps_in = &(style->font_variant_caps);
+ // 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.
+ if (set) {
+ ligatures_res->value |= (ligatures_res->computed ^ ligatures_in->computed );
+ ligatures_res->computed &= ligatures_in->computed;
+
+ position_res->value |= (position_res->computed ^ position_in->computed );
+ position_res->computed &= position_in->computed;
+
+ caps_res->value |= (caps_res->computed ^ caps_in->computed );
+ caps_res->computed &= caps_in->computed;
+
+ } else {
+ ligatures_res->computed = ligatures_in->computed;
+ position_res->computed = position_in->computed;
+ caps_res->computed = caps_in->computed;
+ }
+
+ set = true;
+ }
+
+ bool different = (style_res->font_variant_ligatures.value !=
+ style_res->font_variant_ligatures.computed ||
+ style_res->font_variant_position.value !=
+ style_res->font_variant_position.computed ||
+ style_res->font_variant_caps.value !=
+ style_res->font_variant_caps.computed );
+
+ if (texts == 0 || !set)
+ return QUERY_STYLE_NOTHING;
+
+ if (texts > 1) {
+ if (different) {
+ return QUERY_STYLE_MULTIPLE_DIFFERENT;
+ } else {
+ return QUERY_STYLE_MULTIPLE_SAME;
+ }
+ } else {
+ return QUERY_STYLE_SINGLE;
+ }
+}
+
+
/**
* Write to style_res the baseline numbers.
*/
@@ -1577,6 +1659,8 @@ sp_desktop_query_style_from_list (const std::vector<SPItem*> &list, SPStyle *sty
return objects_query_fontfamily (list, style);
} else if (property == QUERY_STYLE_PROPERTY_FONTSTYLE) {
return objects_query_fontstyle (list, style);
+ } else if (property == QUERY_STYLE_PROPERTY_FONTVARIANTS) {
+ return objects_query_fontvariants (list, style);
} else if (property == QUERY_STYLE_PROPERTY_FONTNUMBERS) {
return objects_query_fontnumbers (list, style);
} else if (property == QUERY_STYLE_PROPERTY_BASELINES) {
@@ -1598,6 +1682,7 @@ sp_desktop_query_style_from_list (const std::vector<SPItem*> &list, SPStyle *sty
int
sp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property)
{
+ // Used by text tool and in gradient dragging
int ret = desktop->_query_style_signal.emit(style, property);
if (ret != QUERY_STYLE_NOTHING)
diff --git a/src/desktop-style.h b/src/desktop-style.h
index a72f49776..e5fe50440 100644
--- a/src/desktop-style.h
+++ b/src/desktop-style.h
@@ -47,6 +47,7 @@ enum { // which property was queried (add when you need more)
QUERY_STYLE_PROPERTY_FONT_SPECIFICATION, //-inkscape-font-specification
QUERY_STYLE_PROPERTY_FONTFAMILY, // font-family
QUERY_STYLE_PROPERTY_FONTSTYLE, // font style
+ QUERY_STYLE_PROPERTY_FONTVARIANTS, // font variants (OpenType features)
QUERY_STYLE_PROPERTY_FONTNUMBERS, // size, spacings
QUERY_STYLE_PROPERTY_BASELINES, // baseline-shift
QUERY_STYLE_PROPERTY_MASTEROPACITY, // opacity
@@ -71,6 +72,7 @@ int objects_query_fillstroke (const std::vector<SPItem*> &objects, SPStyle *styl
int objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_res);
int objects_query_fontstyle (const std::vector<SPItem*> &objects, SPStyle *style_res);
int objects_query_fontfamily (const std::vector<SPItem*> &objects, SPStyle *style_res);
+int objects_query_fontvariants (const std::vector<SPItem*> &objects, SPStyle *style_res);
int objects_query_opacity (const std::vector<SPItem*> &objects, SPStyle *style_res);
int objects_query_strokewidth (const std::vector<SPItem*> &objects, SPStyle *style_res);
int objects_query_miterlimit (const std::vector<SPItem*> &objects, SPStyle *style_res);
diff --git a/src/selection.cpp b/src/selection.cpp
index 7979b5d61..77a507eec 100644
--- a/src/selection.cpp
+++ b/src/selection.cpp
@@ -125,6 +125,7 @@ Selection::_releaseContext(SPObject *obj)
void Selection::_invalidateCachedLists() {
_items.clear();
_reprs.clear();
+ _objs_vector.clear();
}
void Selection::_clear() {
diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp
index 15d3821c7..e8aa09952 100644
--- a/src/sp-offset.cpp
+++ b/src/sp-offset.cpp
@@ -83,7 +83,7 @@ static void sp_offset_source_modified (SPObject *iSource, guint flags, SPItem *i
// fast is not mathematically correct, because computing the offset of a single
// cubic bezier patch is not trivial; in particular, there are problems with holes
// reappearing in offset when the radius becomes too large
-static bool use_slow_but_correct_offset_method=false;
+static bool use_slow_but_correct_offset_method=true;
SPOffset::SPOffset() : SPShape() {
this->rad = 1.0;
diff --git a/src/style-enums.h b/src/style-enums.h
index f235b6699..dca7e246d 100644
--- a/src/style-enums.h
+++ b/src/style-enums.h
@@ -74,34 +74,35 @@ enum SPCSSFontStretch {
// Can select more than one
enum SPCSSFontVariantLigatures {
- SP_CSS_FONT_VARIANT_LIGATURES_NORMAL,
- SP_CSS_FONT_VARIANT_LIGATURES_NONE,
- SP_CSS_FONT_VARIANT_LIGATURES_COMMON,
- SP_CSS_FONT_VARIANT_LIGATURES_NO_COMMON,
- SP_CSS_FONT_VARIANT_LIGATURES_DISCRETIONARY,
- SP_CSS_FONT_VARIANT_LIGATURES_NO_DISCRETIONARY,
- SP_CSS_FONT_VARIANT_LIGATURES_HISTORICAL,
- SP_CSS_FONT_VARIANT_LIGATURES_NO_HISTORICAL,
- SP_CSS_FONT_VARIANT_LIGATURES_CONTEXTUAL,
- SP_CSS_FONT_VARIANT_LIGATURES_NO_CONTEXTUAL
+ SP_CSS_FONT_VARIANT_LIGATURES_NONE = 0,
+ SP_CSS_FONT_VARIANT_LIGATURES_COMMON = 1,
+ SP_CSS_FONT_VARIANT_LIGATURES_DISCRETIONARY = 2,
+ SP_CSS_FONT_VARIANT_LIGATURES_HISTORICAL = 4,
+ SP_CSS_FONT_VARIANT_LIGATURES_CONTEXTUAL = 8,
+ SP_CSS_FONT_VARIANT_LIGATURES_NORMAL = 9, // Special case
+ SP_CSS_FONT_VARIANT_LIGATURES_NOCOMMON = 16,
+ SP_CSS_FONT_VARIANT_LIGATURES_NODISCRETIONARY = 32,
+ SP_CSS_FONT_VARIANT_LIGATURES_NOHISTORICAL = 64,
+ SP_CSS_FONT_VARIANT_LIGATURES_NOCONTEXTUAL = 128
};
enum SPCSSFontVariantPosition {
- SP_CSS_FONT_VARIANT_POSITION_NORMAL,
- SP_CSS_FONT_VARIANT_POSITION_SUB,
- SP_CSS_FONT_VARIANT_POSITION_SUPER
+ SP_CSS_FONT_VARIANT_POSITION_NORMAL = 1,
+ SP_CSS_FONT_VARIANT_POSITION_SUB = 2,
+ SP_CSS_FONT_VARIANT_POSITION_SUPER = 4
};
enum SPCSSFontVariantCaps {
- SP_CSS_FONT_VARIANT_CAPS_NORMAL,
- SP_CSS_FONT_VARIANT_CAPS_SMALL,
- SP_CSS_FONT_VARIANT_CAPS_ALL_SMALL,
- SP_CSS_FONT_VARIANT_CAPS_PETITE,
- SP_CSS_FONT_VARIANT_CAPS_ALL_PETITE,
- SP_CSS_FONT_VARIANT_CAPS_UNICASE,
- SP_CSS_FONT_VARIANT_CAPS_TITLING,
+ SP_CSS_FONT_VARIANT_CAPS_NORMAL = 1,
+ SP_CSS_FONT_VARIANT_CAPS_SMALL = 2,
+ SP_CSS_FONT_VARIANT_CAPS_ALL_SMALL = 4,
+ SP_CSS_FONT_VARIANT_CAPS_PETITE = 8,
+ SP_CSS_FONT_VARIANT_CAPS_ALL_PETITE = 16,
+ SP_CSS_FONT_VARIANT_CAPS_UNICASE = 32,
+ SP_CSS_FONT_VARIANT_CAPS_TITLING = 64
};
+// Can select more than one (see spec)
enum SPCSSFontVariantNumeric {
SP_CSS_FONT_VARIANT_NUMERIC_NORMAL,
SP_CSS_FONT_VARIANT_NUMERIC_LINING_NUMS,
@@ -376,16 +377,16 @@ static SPStyleEnum const enum_font_stretch[] = {
};
static SPStyleEnum const enum_font_variant_ligatures[] = {
- {"normal", SP_CSS_FONT_VARIANT_LIGATURES_NORMAL},
- {"none", SP_CSS_FONT_VARIANT_LIGATURES_NONE},
- {"common-ligatures", SP_CSS_FONT_VARIANT_LIGATURES_COMMON},
- {"no-common-ligatures", SP_CSS_FONT_VARIANT_LIGATURES_NO_COMMON},
- {"discretionary-ligatures", SP_CSS_FONT_VARIANT_LIGATURES_DISCRETIONARY},
- {"no-discretionary-ligatures", SP_CSS_FONT_VARIANT_LIGATURES_NO_DISCRETIONARY},
- {"historical-ligatures", SP_CSS_FONT_VARIANT_LIGATURES_HISTORICAL},
- {"nohistorical-ligatures", SP_CSS_FONT_VARIANT_LIGATURES_NO_HISTORICAL},
- {"contextual", SP_CSS_FONT_VARIANT_LIGATURES_CONTEXTUAL},
- {"no-contextual", SP_CSS_FONT_VARIANT_LIGATURES_NO_CONTEXTUAL},
+ {"none", SP_CSS_FONT_VARIANT_LIGATURES_NONE},
+ {"common-ligatures", SP_CSS_FONT_VARIANT_LIGATURES_COMMON},
+ {"discretionary-ligatures", SP_CSS_FONT_VARIANT_LIGATURES_DISCRETIONARY},
+ {"historical-ligatures", SP_CSS_FONT_VARIANT_LIGATURES_HISTORICAL},
+ {"contextual", SP_CSS_FONT_VARIANT_LIGATURES_CONTEXTUAL},
+ {"normal", SP_CSS_FONT_VARIANT_LIGATURES_NORMAL},
+ {"no-common-ligatures", SP_CSS_FONT_VARIANT_LIGATURES_NOCOMMON},
+ {"no-discretionary-ligatures", SP_CSS_FONT_VARIANT_LIGATURES_NODISCRETIONARY},
+ {"no-historical-ligatures", SP_CSS_FONT_VARIANT_LIGATURES_NOHISTORICAL},
+ {"no-contextual", SP_CSS_FONT_VARIANT_LIGATURES_NOCONTEXTUAL},
{NULL, -1}
};
@@ -401,7 +402,7 @@ static SPStyleEnum const enum_font_variant_caps[] = {
{"small-caps", SP_CSS_FONT_VARIANT_CAPS_SMALL},
{"all-small-caps", SP_CSS_FONT_VARIANT_CAPS_ALL_SMALL},
{"petite-caps", SP_CSS_FONT_VARIANT_CAPS_PETITE},
- {"all_petite-caps", SP_CSS_FONT_VARIANT_CAPS_ALL_PETITE},
+ {"all-petite-caps", SP_CSS_FONT_VARIANT_CAPS_ALL_PETITE},
{"unicase", SP_CSS_FONT_VARIANT_CAPS_UNICASE},
{"titling", SP_CSS_FONT_VARIANT_CAPS_TITLING},
{NULL, -1}
diff --git a/src/style-internal.cpp b/src/style-internal.cpp
index 915282301..3b76e5ab1 100644
--- a/src/style-internal.cpp
+++ b/src/style-internal.cpp
@@ -45,6 +45,8 @@
#include <sigc++/functors/ptr_fun.h>
#include <sigc++/adaptors/bind.h>
+#include <glibmm/regex.h>
+
// TODO REMOVE OR MAKE MEMBER FUNCTIONS
void sp_style_fill_paint_server_ref_changed( SPObject *old_ref, SPObject *ref, SPStyle *style);
void sp_style_stroke_paint_server_ref_changed(SPObject *old_ref, SPObject *ref, SPStyle *style);
@@ -664,6 +666,134 @@ SPIEnum::operator==(const SPIBase& rhs) {
}
+// SPIEnumBits ----------------------------------------------------------
+// Used for 'font-variant-xxx'
+void
+SPIEnumBits::read( gchar const *str ) {
+
+ if( !str ) return;
+ std::cout << "SPIEnumBits: " << name << ": " << str << std::endl;
+ if( !strcmp(str, "inherit") ) {
+ set = true;
+ inherit = true;
+ } else {
+ for (unsigned i = 0; enums[i].key; i++) {
+ if (!strcmp(str, enums[i].key)) {
+ std::cout << " found: " << enums[i].key << std::endl;
+ set = true;
+ inherit = false;
+ value += enums[i].value;
+ /* Save copying for values not needing it */
+ computed = value;
+ }
+ }
+ }
+}
+
+const Glib::ustring
+SPIEnumBits::write( guint const flags, SPIBase const *const base) const {
+
+ SPIEnum const *const my_base = dynamic_cast<const SPIEnum*>(base);
+ if ( (flags & SP_STYLE_FLAG_ALWAYS) ||
+ ((flags & SP_STYLE_FLAG_IFSET) && this->set) ||
+ ((flags & SP_STYLE_FLAG_IFDIFF) && this->set
+ && (!my_base->set || this != my_base )))
+ {
+ if (this->inherit) {
+ return (name + ":inherit;");
+ }
+ if (this->value == 0 ) {
+ return (name + ":normal");
+ }
+ Glib::ustring return_string = name + ":";
+ unsigned j = 1;
+ for (unsigned i = 0; enums[i].key; ++i) {
+ if (j & this->value ) {
+ return_string += enums[i].value + " ";
+ }
+ j *= 2;
+ }
+ return return_string;
+ }
+ return Glib::ustring("");
+}
+
+
+// SPILigatures -----------------------------------------------------
+// Used for 'font-variant-ligatures'
+void
+SPILigatures::read( gchar const *str ) {
+
+ if( !str ) return;
+
+ value = SP_CSS_FONT_VARIANT_LIGATURES_NORMAL;
+ if( !strcmp(str, "inherit") ) {
+ set = true;
+ inherit = true;
+ } else if (!strcmp(str, "normal" )) {
+ // Defaults for TrueType
+ inherit = false;
+ set = true;
+ } else if (!strcmp(str, "none" )) {
+ value = SP_CSS_FONT_VARIANT_LIGATURES_NONE;
+ inherit = false;
+ set = true;
+ } else {
+ // We need to parse in order
+ std::vector<Glib::ustring> 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;
+ if( enums[j].value < SP_CSS_FONT_VARIANT_LIGATURES_NOCOMMON ) {
+ // Turn on
+ value |= enums[j].value;
+ } else {
+ // Turn off
+ value &= ~(enums[j].value >> 4);
+ }
+ }
+ }
+ }
+ }
+ computed = value;
+}
+
+const Glib::ustring
+SPILigatures::write( guint const flags, SPIBase const *const base) const {
+
+ SPIEnum const *const my_base = dynamic_cast<const SPIEnum*>(base);
+ if ( (flags & SP_STYLE_FLAG_ALWAYS) ||
+ ((flags & SP_STYLE_FLAG_IFSET) && this->set) ||
+ ((flags & SP_STYLE_FLAG_IFDIFF) && this->set
+ && (!my_base->set || this != my_base )))
+ {
+ if (this->inherit) {
+ return (name + ":inherit;");
+ }
+ if (value == SP_CSS_FONT_VARIANT_LIGATURES_NONE ) {
+ return (name + ":none;");
+ }
+ if (value == SP_CSS_FONT_VARIANT_LIGATURES_NORMAL ) {
+ return (name + ":normal;");
+ }
+
+ Glib::ustring return_string = name + ":";
+ if ( !(value & SP_CSS_FONT_VARIANT_LIGATURES_COMMON) )
+ return_string += "no-common-ligatures ";
+ if ( value & SP_CSS_FONT_VARIANT_LIGATURES_DISCRETIONARY )
+ return_string += "discretionary-ligatures ";
+ if ( value & SP_CSS_FONT_VARIANT_LIGATURES_HISTORICAL )
+ return_string += "historical-ligatures ";
+ if ( !(value & SP_CSS_FONT_VARIANT_LIGATURES_CONTEXTUAL) )
+ return_string += "no-contextual ";
+ return_string.erase( return_string.size() - 1 );
+ return_string += ";";
+ return return_string;
+ }
+ return Glib::ustring("");
+}
// SPIString ------------------------------------------------------------
diff --git a/src/style-internal.h b/src/style-internal.h
index a8f0c5096..ea966866a 100644
--- a/src/style-internal.h
+++ b/src/style-internal.h
@@ -510,6 +510,55 @@ private:
};
+/// SPIEnum w/ bits, allows values with multiple key words.
+class SPIEnumBits : public SPIEnum
+{
+
+public:
+ SPIEnumBits() :
+ SPIEnum( "anonymous_enumbits", NULL )
+ {}
+
+ SPIEnumBits( Glib::ustring const &name, SPStyleEnum const *enums, unsigned value = 0, bool inherits = true ) :
+ SPIEnum( name, enums, value, inherit )
+ {}
+
+ virtual ~SPIEnumBits()
+ {}
+
+ virtual void read( gchar const *str );
+ virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET,
+ SPIBase const *const base = NULL ) const;
+
+};
+
+
+/// SPIEnum w/ extra bits. The 'font-variants-ligatures' property is a complete mess that needs
+/// special handling. For OpenType fonts the values 'common-ligatures', 'contextual',
+/// 'no-discretionary-ligatures', and 'no-historical-ligatures' are not useful but we still must be
+/// able to parse them.
+class SPILigatures : public SPIEnum
+{
+
+public:
+ SPILigatures() :
+ SPIEnum( "anonymous_enumligatures", NULL )
+ {}
+
+ SPILigatures( Glib::ustring const &name, SPStyleEnum const *enums) :
+ SPIEnum( name, enums,
+ SP_CSS_FONT_VARIANT_LIGATURES_COMMON | SP_CSS_FONT_VARIANT_LIGATURES_CONTEXTUAL)
+ {}
+
+ virtual ~SPILigatures()
+ {}
+
+ virtual void read( gchar const *str );
+ virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET,
+ 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-test.h b/src/style-test.h
index cd6769b24..1d821312b 100644
--- a/src/style-test.h
+++ b/src/style-test.h
@@ -137,6 +137,23 @@ public:
TestCase("font-weight:bolder"),
TestCase("font-stretch:condensed"), // SPIEnum
+ TestCase("font-variant-ligatures:none"), // SPILigatures
+ TestCase("font-variant-ligatures:normal"),
+ TestCase("font-variant-ligatures:no-common-ligatures"),
+ TestCase("font-variant-ligatures:discretionary-ligatures"),
+ TestCase("font-variant-ligatures:historical-ligatures"),
+ TestCase("font-variant-ligatures:no-contextual"),
+ TestCase("font-variant-ligatures:common-ligatures", "font-variant-ligatures:normal"),
+ TestCase("font-variant-ligatures:contextual", "font-variant-ligatures:normal"),
+ TestCase("font-variant-ligatures:no-common-ligatures historical-ligatures"),
+ TestCase("font-variant-ligatures:historical-ligatures no-contextual"),
+ TestCase("font-variant-position:normal"),
+ TestCase("font-variant-position:sub"),
+ TestCase("font-variant-position:super"),
+ TestCase("font-variant-caps:normal"),
+ TestCase("font-variant-caps:small-caps"),
+ TestCase("font-variant-caps:all-small-caps"),
+
// Should be moved down
TestCase("text-indent:12em"), // SPILength?
TestCase("text-align:center"), // SPIEnum
diff --git a/src/style.cpp b/src/style.cpp
index 49a13604b..4d93841eb 100644
--- a/src/style.cpp
+++ b/src/style.cpp
@@ -119,7 +119,7 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) :
font_specification( "-inkscape-font-specification" ), // SPIString
// Font variants
- font_variant_ligatures( "font-variant-ligatures", enum_font_variant_ligatures, SP_CSS_FONT_VARIANT_LIGATURES_NORMAL ),
+ 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, SP_CSS_FONT_VARIANT_NUMERIC_NORMAL ),
diff --git a/src/style.h b/src/style.h
index 2618662f5..f82fad9b0 100644
--- a/src/style.h
+++ b/src/style.h
@@ -113,7 +113,7 @@ public:
/* Font variants -------------------- */
/** Font variant ligatures */
- SPIEnum font_variant_ligatures;
+ SPILigatures font_variant_ligatures;
/** Font variant position (subscript/superscript) */
SPIEnum font_variant_position;
/** Font variant caps (small caps) */
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index 09c32d501..fbf25d039 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -129,6 +129,7 @@ set(ui_SRC
widget/entity-entry.cpp
widget/entry.cpp
widget/filter-effect-chooser.cpp
+ widget/font-variants.cpp
widget/frame.cpp
widget/gimpcolorwheel.c
widget/gimpspinscale.c
@@ -309,6 +310,7 @@ set(ui_SRC
widget/entity-entry.h
widget/entry.h
widget/filter-effect-chooser.h
+ widget/font-variants.h
widget/frame.h
widget/gimpspinscale.h
widget/gimpcolorwheel.h
diff --git a/src/ui/dialog/text-edit.cpp b/src/ui/dialog/text-edit.cpp
index 815aa12ef..4fd227f01 100644
--- a/src/ui/dialog/text-edit.cpp
+++ b/src/ui/dialog/text-edit.cpp
@@ -69,6 +69,7 @@ TextEdit::TextEdit()
font_label(_("_Font"), true),
layout_frame(),
text_label(_("_Text"), true),
+ vari_label(_("_Variants"), true),
setasdefault_button(_("Set as _default")),
close_button(Gtk::Stock::CLOSE),
apply_button(Gtk::Stock::APPLY),
@@ -195,7 +196,8 @@ TextEdit::TextEdit()
notebook.append_page(font_vbox, font_label);
notebook.append_page(text_vbox, text_label);
-
+ notebook.append_page(vari_vbox, vari_label);
+
/* Buttons */
setasdefault_button.set_use_underline(true);
apply_button.set_can_default();
@@ -384,6 +386,11 @@ void TextEdit::onReadSelection ( gboolean dostyle, gboolean /*docontent*/ )
gtk_entry_set_text ((GtkEntry *) gtk_bin_get_child ((GtkBin *) spacing_combo), sstr);
g_free(sstr);
+ // Update font variant widget
+ //int result_variants =
+ sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_FONTVARIANTS);
+ vari_vbox.update( &query );
+
}
blocked = false;
}
@@ -510,12 +517,15 @@ SPCSSAttr *TextEdit::fillTextStyle ()
sp_repr_css_set_property (css, "writing-mode", "tb");
}
- // Note that CSS 1.1 does not support line-height; we set it for consistency, but also set
+ // Note that SVG 1.1 does not support line-height; we set it for consistency, but also set
// sodipodi:linespacing for backwards compatibility; in 1.2 we use line-height for flowtext
const gchar *sstr = gtk_combo_box_text_get_active_text ((GtkComboBoxText *) spacing_combo);
sp_repr_css_set_property (css, "line-height", sstr);
+ // Font variants
+ vari_vbox.fill_css( css );
+
return css;
}
diff --git a/src/ui/dialog/text-edit.h b/src/ui/dialog/text-edit.h
index 117ad2e28..f088fd337 100644
--- a/src/ui/dialog/text-edit.h
+++ b/src/ui/dialog/text-edit.h
@@ -32,6 +32,7 @@
#include "ui/widget/panel.h"
#include "ui/widget/frame.h"
#include "ui/dialog/desktop-tracker.h"
+#include "ui/widget/font-variants.h"
class SPItem;
struct SPFontSelector;
@@ -213,6 +214,9 @@ private:
GtkWidget *text_view; // TODO - Convert this to a Gtk::TextView, but GtkSpell doesn't seem to work with it
GtkTextBuffer *text_buffer;
+ Inkscape::UI::Widget::FontVariants vari_vbox;
+ Gtk::Label vari_label;
+
Gtk::HBox button_row;
Gtk::Button setasdefault_button;
Gtk::Button close_button;
diff --git a/src/ui/widget/Makefile_insert b/src/ui/widget/Makefile_insert
index d56946745..eb98e6872 100644
--- a/src/ui/widget/Makefile_insert
+++ b/src/ui/widget/Makefile_insert
@@ -33,8 +33,10 @@ ink_common_sources += \
ui/widget/entry.h \
ui/widget/filter-effect-chooser.h \
ui/widget/filter-effect-chooser.cpp \
- ui/widget/gimpspinscale.c \
- ui/widget/gimpspinscale.h \
+ ui/widget/font-variants.h \
+ ui/widget/font-variants.cpp \
+ ui/widget/gimpspinscale.c \
+ ui/widget/gimpspinscale.h \
ui/widget/gimpcolorwheel.c \
ui/widget/gimpcolorwheel.h \
ui/widget/frame.cpp \
diff --git a/src/ui/widget/font-variants.cpp b/src/ui/widget/font-variants.cpp
new file mode 100644
index 000000000..8ca926d8f
--- /dev/null
+++ b/src/ui/widget/font-variants.cpp
@@ -0,0 +1,375 @@
+/*
+ * Author:
+ * Tavmjong Bah <tavmjong@free.fr>
+ *
+ * Copyright (C) 2015 Tavmong Bah
+ *
+ * Released under GNU GPL. Read the file 'COPYING' for more information.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <gtkmm.h>
+#include <glibmm/i18n.h>
+
+#include <iostream>
+
+#include "font-variants.h"
+
+// For updating from selection
+#include "desktop.h"
+#include "selection.h"
+#include "style.h"
+#include "sp-text.h"
+#include "sp-tspan.h"
+#include "sp-tref.h"
+#include "sp-textpath.h"
+#include "sp-item-group.h"
+#include "xml/repr.h"
+
+namespace Inkscape {
+namespace UI {
+namespace Widget {
+
+ FontVariants::FontVariants () :
+ Gtk::VBox (),
+ _ligatures_frame ( Glib::ustring(_("Ligatures" )) ),
+ _ligatures_common ( Glib::ustring(_("Common" )) ),
+ _ligatures_discretionary ( Glib::ustring(_("Discretionary")) ),
+ _ligatures_historical ( Glib::ustring(_("Historical" )) ),
+ _ligatures_contextual ( Glib::ustring(_("Contextual" )) ),
+
+ _position_frame ( Glib::ustring(_("Position" )) ),
+ _position_normal ( Glib::ustring(_("Normal" )) ),
+ _position_sub ( Glib::ustring(_("Subscript" )) ),
+ _position_super ( Glib::ustring(_("Superscript" )) ),
+
+ _caps_frame ( Glib::ustring(_("Capitals" )) ),
+ _caps_normal ( Glib::ustring(_("Normal" )) ),
+ _caps_small ( Glib::ustring(_("Small" )) ),
+ _caps_all_small ( Glib::ustring(_("All small" )) ),
+ _caps_petite ( Glib::ustring(_("Petite" )) ),
+ _caps_all_petite ( Glib::ustring(_("All petite" )) ),
+ _caps_unicase ( Glib::ustring(_("Unicase" )) ),
+ _caps_titling ( Glib::ustring(_("Titling" )) ),
+
+ _numeric_frame ( Glib::ustring(_("Numeric" )) ),
+ _numeric_lining ( Glib::ustring(_("Lining" )) ),
+ _numeric_old_style ( Glib::ustring(_("Old Style" )) ),
+ _numeric_default_style ( Glib::ustring(_("Default Style")) ),
+ _numeric_proportional ( Glib::ustring(_("Proportional" )) ),
+ _numeric_tabular ( Glib::ustring(_("Tabular" )) ),
+ _numeric_default_width ( Glib::ustring(_("Default Width")) ),
+ _numeric_diagonal ( Glib::ustring(_("Diagonal" )) ),
+ _numeric_stacked ( Glib::ustring(_("Stacked" )) ),
+ _numeric_default_fractions( Glib::ustring(_("Default Fractions")) ),
+ _numeric_ordinal ( Glib::ustring(_("Ordinal" )) ),
+ _numeric_slashed_zero ( Glib::ustring(_("Slashed Zero" )) ),
+
+ _ligatures_changed( false ),
+ _position_changed( false ),
+ _caps_changed( false ),
+ _numeric_changed( false )
+
+ {
+
+ // Ligatures --------------------------
+ _ligatures_common.set_tooltip_text(
+ _("Common ligatures. On by default. OpenType tables: 'liga', 'clig'"));
+ _ligatures_discretionary.set_tooltip_text(
+ _("Discretionary ligatures. Off by default. OpenType table: 'dlig'"));
+ _ligatures_historical.set_tooltip_text(
+ _("Historical ligatures. Off by default. OpenType table: 'hlig'"));
+ _ligatures_contextual.set_tooltip_text(
+ _("Contextual forms. On by default. OpenType table: 'calt'"));
+
+
+ _ligatures_common.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::ligatures_callback) );
+ _ligatures_discretionary.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::ligatures_callback) );
+ _ligatures_historical.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::ligatures_callback) );
+ _ligatures_contextual.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::ligatures_callback) );
+ _ligatures_vbox.add( _ligatures_common );
+ _ligatures_vbox.add( _ligatures_discretionary );
+ _ligatures_vbox.add( _ligatures_historical );
+ _ligatures_vbox.add( _ligatures_contextual );
+ _ligatures_frame.add( _ligatures_vbox );
+ add( _ligatures_frame );
+
+ ligatures_init();
+
+ // Position ----------------------------------
+ _position_vbox.add( _position_normal );
+ _position_vbox.add( _position_sub );
+ _position_vbox.add( _position_super );
+ _position_frame.add( _position_vbox );
+ add( _position_frame );
+
+ // Group buttons
+ Gtk::RadioButton::Group position_group = _position_normal.get_group();
+ _position_sub.set_group(position_group);
+ _position_super.set_group(position_group);
+ _position_normal.signal_pressed().connect ( sigc::mem_fun(*this, &FontVariants::position_callback) );
+ _position_sub.signal_pressed().connect ( sigc::mem_fun(*this, &FontVariants::position_callback) );
+ _position_super.signal_pressed().connect ( sigc::mem_fun(*this, &FontVariants::position_callback) );
+
+ position_init();
+
+ // Caps ----------------------------------
+ _caps_vbox.add( _caps_normal );
+ _caps_vbox.add( _caps_small );
+ _caps_vbox.add( _caps_all_small );
+ _caps_vbox.add( _caps_petite );
+ _caps_vbox.add( _caps_all_petite );
+ _caps_vbox.add( _caps_unicase );
+ _caps_vbox.add( _caps_titling );
+ _caps_frame.add( _caps_vbox );
+ add( _caps_frame );
+
+ // Group buttons
+ Gtk::RadioButton::Group caps_group = _caps_normal.get_group();
+ _caps_small.set_group(caps_group);
+ _caps_all_small.set_group(caps_group);
+ _caps_petite.set_group(caps_group);
+ _caps_all_petite.set_group(caps_group);
+ _caps_unicase.set_group(caps_group);
+ _caps_titling.set_group(caps_group);
+ _caps_normal.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::caps_callback) );
+ _caps_small.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::caps_callback) );
+ _caps_all_small.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::caps_callback) );
+ _caps_petite.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::caps_callback) );
+ _caps_all_petite.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::caps_callback) );
+ _caps_unicase.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::caps_callback) );
+ _caps_titling.signal_clicked().connect ( sigc::mem_fun(*this, &FontVariants::caps_callback) );
+
+ caps_init();
+
+ // Numeric ------------------------------
+ _numeric_stylebox.add( _numeric_default_style );
+ _numeric_stylebox.add( _numeric_lining );
+ _numeric_stylebox.add( _numeric_old_style );
+ _numeric_vbox.add( _numeric_stylebox );
+ _numeric_widthbox.add( _numeric_default_width );
+ _numeric_widthbox.add( _numeric_proportional );
+ _numeric_widthbox.add( _numeric_tabular );
+ _numeric_vbox.add( _numeric_widthbox );
+ _numeric_fractionbox.add( _numeric_default_fractions );
+ _numeric_fractionbox.add( _numeric_diagonal );
+ _numeric_fractionbox.add( _numeric_stacked );
+ _numeric_vbox.add( _numeric_fractionbox );
+ _numeric_vbox.add( _numeric_ordinal );
+ _numeric_vbox.add( _numeric_slashed_zero );
+ _numeric_frame.add( _numeric_vbox );
+ add( _numeric_frame );
+
+ // Group buttons
+ Gtk::RadioButton::Group style_group = _numeric_default_style.get_group();
+ _numeric_lining.set_group(style_group);
+ _numeric_old_style.set_group(style_group);
+
+ Gtk::RadioButton::Group width_group = _numeric_default_width.get_group();
+ _numeric_proportional.set_group(width_group);
+ _numeric_tabular.set_group(width_group);
+
+ Gtk::RadioButton::Group fraction_group = _numeric_default_fractions.get_group();
+ _numeric_diagonal.set_group(fraction_group);
+ _numeric_stacked.set_group(fraction_group);
+
+ show_all_children();
+ }
+
+ void
+ FontVariants::ligatures_init() {
+ // std::cout << "FontVariants::ligatures_init()" << std::endl;
+ }
+
+ void
+ FontVariants::ligatures_callback() {
+ // std::cout << "FontVariants::ligatures_callback()" << std::endl;
+ _ligatures_changed = true;
+ }
+
+ void
+ FontVariants::position_init() {
+ // std::cout << "FontVariants::position_init()" << std::endl;
+ }
+
+ void
+ FontVariants::position_callback() {
+ // std::cout << "FontVariants::position_callback()" << std::endl;
+ _position_changed = true;
+ }
+
+ void
+ FontVariants::caps_init() {
+ // std::cout << "FontVariants::caps_init()" << std::endl;
+ }
+
+ void
+ FontVariants::caps_callback() {
+ // std::cout << "FontVariants::caps_callback()" << std::endl;
+ _caps_changed = true;
+ }
+
+ void
+ FontVariants::numeric_init() {
+ std::cout << "FontVariants::numeric_init()" << std::endl;
+ // _numeric_tabular.set_inconsistent();
+ }
+
+ void
+ FontVariants::numeric_callback() {
+ // std::cout << "FontVariants::numeric_callback()" << std::endl;
+ _numeric_changed = true;
+ }
+
+ // Update GUI based on query.
+ void
+ FontVariants::update( SPStyle const *query ) {
+ // std::cout << "FontVariants::update" << std::endl;
+
+ _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;
+
+ _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
+ FontVariants::fill_css( SPCSSAttr *css ) {
+
+ // Ligatures
+ bool common = _ligatures_common.get_active();
+ bool discretionary = _ligatures_discretionary.get_active();
+ bool historical = _ligatures_historical.get_active();
+ bool contextual = _ligatures_contextual.get_active();
+
+ if( !common && !discretionary && !historical && !contextual ) {
+ sp_repr_css_set_property(css, "font-variant-ligatures", "none" );
+ } else if ( common && !discretionary && !historical && contextual ) {
+ sp_repr_css_set_property(css, "font-variant-ligatures", "normal" );
+ } else {
+ Glib::ustring css_string;
+ if ( !common )
+ css_string += "no-common-ligatures ";
+ if ( discretionary )
+ css_string += "discretionary-ligatures ";
+ if ( historical )
+ css_string += "historical-ligatures ";
+ if ( !contextual )
+ 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
+} // namespace UI
+} // namespace Inkscape
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/ui/widget/font-variants.h b/src/ui/widget/font-variants.h
new file mode 100644
index 000000000..04c05d3c6
--- /dev/null
+++ b/src/ui/widget/font-variants.h
@@ -0,0 +1,137 @@
+/*
+ * Author:
+ * Tavmjong Bah <tavmjong@free.fr>
+ *
+ * Copyright (C) 2015 Tavmong Bah
+ *
+ * Released under GNU GPL. Read the file 'COPYING' for more information.
+ */
+
+#ifndef INKSCAPE_UI_WIDGET_FONT_VARIANT_H
+#define INKSCAPE_UI_WIDGET_FONT_VARIANT_H
+
+// Temp: both frame and expander
+#include <gtkmm/frame.h>
+#include <gtkmm/expander.h>
+#include <gtkmm/checkbutton.h>
+#include <gtkmm/radiobutton.h>
+
+class SPDesktop;
+class SPObject;
+class SPStyle;
+class SPCSSAttr;
+
+namespace Inkscape {
+namespace UI {
+namespace Widget {
+
+/**
+ * A container for selecting font variants (OpenType Features).
+ */
+class FontVariants : public Gtk::VBox
+{
+
+public:
+
+ /**
+ * Constructor
+ */
+ FontVariants();
+
+protected:
+ // To start, use four check buttons.
+ Gtk::Expander _ligatures_frame;
+ Gtk::VBox _ligatures_vbox;
+ Gtk::CheckButton _ligatures_common;
+ Gtk::CheckButton _ligatures_discretionary;
+ Gtk::CheckButton _ligatures_historical;
+ Gtk::CheckButton _ligatures_contextual;
+
+ // Exclusive options
+ Gtk::Expander _position_frame;
+ Gtk::VBox _position_vbox;
+ Gtk::RadioButton _position_normal;
+ Gtk::RadioButton _position_sub;
+ Gtk::RadioButton _position_super;
+
+ // Exclusive options (maybe a dropdown menu to save space?)
+ Gtk::Expander _caps_frame;
+ Gtk::VBox _caps_vbox;
+ Gtk::RadioButton _caps_normal;
+ Gtk::RadioButton _caps_small;
+ Gtk::RadioButton _caps_all_small;
+ Gtk::RadioButton _caps_petite;
+ Gtk::RadioButton _caps_all_petite;
+ Gtk::RadioButton _caps_unicase;
+ Gtk::RadioButton _caps_titling;
+
+ // Complicated!
+ Gtk::Expander _numeric_frame;
+ Gtk::VBox _numeric_vbox;
+ Gtk::HBox _numeric_stylebox;
+ Gtk::RadioButton _numeric_lining;
+ Gtk::RadioButton _numeric_old_style;
+ Gtk::RadioButton _numeric_default_style;
+ Gtk::HBox _numeric_widthbox;
+ Gtk::RadioButton _numeric_proportional;
+ Gtk::RadioButton _numeric_tabular;
+ Gtk::RadioButton _numeric_default_width;
+ Gtk::HBox _numeric_fractionbox;
+ Gtk::RadioButton _numeric_diagonal;
+ Gtk::RadioButton _numeric_stacked;
+ Gtk::RadioButton _numeric_default_fractions;
+ Gtk::CheckButton _numeric_ordinal;
+ Gtk::CheckButton _numeric_slashed_zero;
+
+private:
+ void ligatures_init();
+ void ligatures_callback();
+
+ void position_init();
+ void position_callback();
+
+ void caps_init();
+ void caps_callback();
+
+ 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( SPStyle const *query );
+
+ void fill_css( SPCSSAttr* css );
+};
+
+
+} // namespace Widget
+} // namespace UI
+} // namespace Inkscape
+
+#endif // INKSCAPE_UI_WIDGET_FONT_VARIANT_H
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :