summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2015-06-21 20:12:09 +0000
committertavmjong-free <tavmjong@free.fr>2015-06-21 20:12:09 +0000
commit9c5f676d93e36fa9c53fd97f62b178ca1b840969 (patch)
tree64902563f9da753f60bd9b4e587e7b24fa835a74 /src
parentSpray Tool. Fixing boolean initialization and coding style issues. (diff)
downloadinkscape-9c5f676d93e36fa9c53fd97f62b178ca1b840969.tar.gz
inkscape-9c5f676d93e36fa9c53fd97f62b178ca1b840969.zip
Render font variants (ligatures, postions, caps, numerics).
Requires Pango 1.37.1. (bzr r14206)
Diffstat (limited to 'src')
-rw-r--r--src/libnrtype/Layout-TNG-Compute.cpp17
-rw-r--r--src/style.cpp60
-rw-r--r--src/style.h6
3 files changed, 83 insertions, 0 deletions
diff --git a/src/libnrtype/Layout-TNG-Compute.cpp b/src/libnrtype/Layout-TNG-Compute.cpp
index beff3734b..8c12f235c 100644
--- a/src/libnrtype/Layout-TNG-Compute.cpp
+++ b/src/libnrtype/Layout-TNG-Compute.cpp
@@ -958,6 +958,10 @@ void Layout::Calculator::ParagraphInfo::free()
*/
void Layout::Calculator::_buildPangoItemizationForPara(ParagraphInfo *para) const
{
+ TRACE(("pango version string: %s\n", pango_version_string() ));
+#if PANGO_VERSION_CHECK(1,37,1)
+ TRACE((" ... compiled for font features\n"));
+#endif
Glib::ustring para_text;
PangoAttrList *attributes_list;
unsigned input_index;
@@ -986,9 +990,22 @@ void Layout::Calculator::_buildPangoItemizationForPara(ParagraphInfo *para) con
PangoAttribute *attribute_font_description = pango_attr_font_desc_new(font->descr);
attribute_font_description->start_index = para_text.bytes();
+
+#if PANGO_VERSION_CHECK(1,37,1)
+ PangoAttribute *attribute_font_features =
+ pango_attr_font_features_new( text_source->style->getFontFeatureString().c_str());
+// pango_attr_font_features_new( "hlig 1, dlig 1");
+ attribute_font_features->start_index = para_text.bytes();
+#endif
para_text.append(&*text_source->text_begin.base(), text_source->text_length); // build the combined text
attribute_font_description->end_index = para_text.bytes();
pango_attr_list_insert(attributes_list, attribute_font_description);
+
+#if PANGO_VERSION_CHECK(1,37,1)
+ attribute_font_features->end_index = para_text.bytes();
+ pango_attr_list_insert(attributes_list, attribute_font_features);
+#endif
+
// ownership of attribute is assumed by the list
font->Unref();
}
diff --git a/src/style.cpp b/src/style.cpp
index 1668646b6..e7316525b 100644
--- a/src/style.cpp
+++ b/src/style.cpp
@@ -1190,6 +1190,66 @@ 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, clig, ";
+ else
+ 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, ";
+ else
+ 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, ";
+
+ feature_string.erase( feature_string.size() - 1 );
+ feature_string.erase( feature_string.size() - 1 );
+
+ return feature_string;
+}
+
+
// Internal
/**
* Release callback.
diff --git a/src/style.h b/src/style.h
index 8e22b3121..02432d3e7 100644
--- a/src/style.h
+++ b/src/style.h
@@ -303,6 +303,12 @@ public:
SPPaintServer *getStrokePaintServer() { return (stroke.value.href) ? stroke.value.href->getObject() : NULL; }
SPPaintServer const *getStrokePaintServer() const { return (stroke.value.href) ? stroke.value.href->getObject() : NULL; }
char const *getStrokeURI() const { return (stroke.value.href) ? stroke.value.href->getURI()->toString() : NULL; }
+
+ /**
+ * Return a font feature string useful for Pango.
+ */
+ std::string getFontFeatureString();
+
};
SPStyle *sp_style_ref(SPStyle *style); // SPStyle::ref();