summaryrefslogtreecommitdiffstats
path: root/src/sp-tspan.cpp
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2015-12-05 14:40:56 +0000
committertavmjong-free <tavmjong@free.fr>2015-12-05 14:40:56 +0000
commit78005ad417dde6dddab40efacb757b1d6b0c03d0 (patch)
treea827191465ff949ec952b55ffed30fe943cab019 /src/sp-tspan.cpp
parentadded comment + simpler rounding (diff)
downloadinkscape-78005ad417dde6dddab40efacb757b1d6b0c03d0.tar.gz
inkscape-78005ad417dde6dddab40efacb757b1d6b0c03d0.zip
Handle units in the 'x', 'y', 'dx', and 'dy' text and tspan attributes.
Fixed bugs: - https://launchpad.net/bugs/1522478 - https://launchpad.net/bugs/262528 - https://launchpad.net/bugs/168845 (bzr r14505)
Diffstat (limited to '')
-rw-r--r--src/sp-tspan.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp
index 7582cb9e6..05f8430ba 100644
--- a/src/sp-tspan.cpp
+++ b/src/sp-tspan.cpp
@@ -70,7 +70,7 @@ void SPTSpan::release() {
}
void SPTSpan::set(unsigned int key, const gchar* value) {
- if (this->attributes.readSingleAttribute(key, value)) {
+ if (this->attributes.readSingleAttribute(key, value, style, &viewport)) {
this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
} else {
switch (key) {
@@ -103,6 +103,20 @@ void SPTSpan::update(SPCtx *ctx, guint flags) {
}
SPItem::update(ctx, flags);
+
+ if (flags & ( SP_OBJECT_STYLE_MODIFIED_FLAG |
+ SP_OBJECT_CHILD_MODIFIED_FLAG |
+ SP_TEXT_LAYOUT_MODIFIED_FLAG ) )
+ {
+ SPItemCtx const *ictx = reinterpret_cast<SPItemCtx const *>(ctx);
+
+ double const w = ictx->viewport.width();
+ double const h = ictx->viewport.height();
+ double const em = style->font_size.computed;
+ double const ex = 0.5 * em; // fixme: get x height from pango or libnrtype.
+
+ attributes.update( em, ex, w, h );
+ }
}
void SPTSpan::modified(unsigned int flags) {
@@ -264,7 +278,7 @@ void SPTextPath::release() {
}
void SPTextPath::set(unsigned int key, const gchar* value) {
- if (this->attributes.readSingleAttribute(key, value)) {
+ if (this->attributes.readSingleAttribute(key, value, style, &viewport)) {
this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
} else {
switch (key) {
@@ -304,6 +318,20 @@ void SPTextPath::update(SPCtx *ctx, guint flags) {
ochild->updateDisplay(ctx, flags);
}
}
+
+ if (flags & ( SP_OBJECT_STYLE_MODIFIED_FLAG |
+ SP_OBJECT_CHILD_MODIFIED_FLAG |
+ SP_TEXT_LAYOUT_MODIFIED_FLAG ) )
+ {
+ SPItemCtx const *ictx = reinterpret_cast<SPItemCtx const *>(ctx);
+
+ double const w = ictx->viewport.width();
+ double const h = ictx->viewport.height();
+ double const em = style->font_size.computed;
+ double const ex = 0.5 * em; // fixme: get x height from pango or libnrtype.
+
+ attributes.update( em, ex, w, h );
+ }
}