summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2014-09-23 13:17:29 +0000
committertavmjong-free <tavmjong@free.fr>2014-09-23 13:17:29 +0000
commit7fd4a3fa7436b7064cf55474ff53b76be1e2a7dc (patch)
treebc78390dbb4918bbe151e7587a3386d1fcc88543
parentFix a bug in BSpline, happend pressing any key hover a modified weight handle... (diff)
downloadinkscape-7fd4a3fa7436b7064cf55474ff53b76be1e2a7dc.tar.gz
inkscape-7fd4a3fa7436b7064cf55474ff53b76be1e2a7dc.zip
Fix for #1334792. Correct inheritance for 'line-height' property.
(bzr r13341.1.217)
-rw-r--r--src/desktop-style.cpp4
-rw-r--r--src/style-internal.cpp24
-rw-r--r--src/style-internal.h2
3 files changed, 27 insertions, 3 deletions
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp
index 91359983b..2c20524a2 100644
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
@@ -1012,8 +1012,8 @@ objects_query_fontnumbers (GSList *objects, SPStyle *style_res)
} else if (style->line_height.unit == SP_CSS_UNIT_PERCENT || style->font_size.computed == 0) {
linespacing_current = style->line_height.value;
linespacing_normal = false;
- } else { // we need % here
- linespacing_current = style->line_height.computed / style->font_size.computed;
+ } else {
+ linespacing_current = style->line_height.computed;
linespacing_normal = false;
}
linespacing += linespacing_current;
diff --git a/src/style-internal.cpp b/src/style-internal.cpp
index 2212f8fff..a55a11403 100644
--- a/src/style-internal.cpp
+++ b/src/style-internal.cpp
@@ -287,6 +287,14 @@ SPILength::read( gchar const *str ) {
/* Percentage */
unit = SP_CSS_UNIT_PERCENT;
value = value * 0.01;
+ if (name.compare( "line-height" ) == 0) {
+ // See: http://www.w3.org/TR/CSS2/visudet.html#propdef-line-height
+ if( style ) {
+ computed = value * style->font_size.computed;
+ } else {
+ computed = value * SPIFontSize::font_size_default;
+ }
+ }
} else {
/* Invalid */
return;
@@ -355,6 +363,7 @@ void
SPILength::cascade( const SPIBase* const parent ) {
if( const SPILength* p = dynamic_cast<const SPILength*>(parent) ) {
if( (inherits && !set) || inherit ) {
+ unit = p->unit;
value = p->value;
computed = p->computed;
} else {
@@ -365,6 +374,9 @@ SPILength::cascade( const SPIBase* const parent ) {
} else if (unit == SP_CSS_UNIT_EX) {
// FIXME: Get x height from libnrtype or pango.
computed = value * em * 0.5;
+ } else if (unit == SP_CSS_UNIT_PERCENT && name.compare( "line-height" ) == 0 ) {
+ // Special case
+ computed = value * em;
}
}
} else {
@@ -469,6 +481,18 @@ SPILengthOrNormal::write( guint const flags, SPIBase const *const base) const {
}
void
+SPILengthOrNormal::cascade( const SPIBase* const parent ) {
+ if( const SPILengthOrNormal* p = dynamic_cast<const SPILengthOrNormal*>(parent) ) {
+ if( (inherits && !set) || inherit ) {
+ normal = p->normal;
+ }
+ SPILength::cascade( parent );
+ } else {
+ std::cerr << "SPILengthOrNormal::cascade(): Incorrect parent type" << std::endl;
+ }
+}
+
+void
SPILengthOrNormal::merge( const SPIBase* const parent ) {
if( const SPILengthOrNormal* p = dynamic_cast<const SPILengthOrNormal*>(parent) ) {
if( inherits ) {
diff --git a/src/style-internal.h b/src/style-internal.h
index b549bb8ef..9158ed60e 100644
--- a/src/style-internal.h
+++ b/src/style-internal.h
@@ -315,7 +315,7 @@ class SPILengthOrNormal : public SPILength {
virtual const Glib::ustring write( guint const flags = SP_STYLE_FLAG_IFSET,
SPIBase const *const base = NULL ) const;
virtual void clear() { SPILength::clear(); normal = true; };
- // virtual void cascade( const SPIBase* const parent ); // Use SPILength::cascade
+ virtual void cascade( const SPIBase* const parent );
virtual void merge( const SPIBase* const parent );
SPILengthOrNormal& operator=(const SPILengthOrNormal& rhs) {