summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/desktop-style.cpp14
-rw-r--r--src/sp-text.cpp7
-rw-r--r--src/widgets/text-toolbar.cpp10
3 files changed, 23 insertions, 8 deletions
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp
index 5f6441aa7..7f9b46c7d 100644
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
@@ -1073,7 +1073,12 @@ objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_r
texts ++;
SPItem *item = dynamic_cast<SPItem *>(obj);
g_assert(item != NULL);
- double dummy = style->font_size.computed * Geom::Affine(item->i2dt_affine()).descrim();
+
+ // Quick way of getting document scale. Should be same as:
+ // item->document->getDocumentScale().Affine().descrim()
+ double doc_scale = Geom::Affine(item->i2dt_affine()).descrim();
+
+ double dummy = style->font_size.computed * doc_scale;
if (!IS_NAN(dummy)) {
size += dummy; /// \todo FIXME: we assume non-% units here
} else {
@@ -1085,7 +1090,7 @@ objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_r
letterspacing_normal = true;
}
} else {
- letterspacing += style->letter_spacing.computed * Geom::Affine(item->i2dt_affine()).descrim(); /// \todo FIXME: we assume non-% units here
+ letterspacing += style->letter_spacing.computed * doc_scale;; /// \todo FIXME: we assume non-% units here
letterspacing_normal = false;
}
@@ -1094,7 +1099,7 @@ objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_r
wordspacing_normal = true;
}
} else {
- wordspacing += style->word_spacing.computed * Geom::Affine(item->i2dt_affine()).descrim(); /// \todo FIXME: we assume non-% units here
+ wordspacing += style->word_spacing.computed * doc_scale; /// \todo FIXME: we assume non-% units here
wordspacing_normal = false;
}
@@ -1119,14 +1124,15 @@ objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_r
lineheight_unit_current = style->line_height.unit;
lineheight_unit_proportional = true;
lineheight_normal = false;
+ lineheight += lineheight_current;
} else {
// Always 'px' internally
lineheight_current = style->line_height.computed;
lineheight_unit_current = style->line_height.unit;
lineheight_unit_absolute = true;
lineheight_normal = false;
+ lineheight += lineheight_current * doc_scale;
}
- lineheight += lineheight_current;
if ((size_prev != 0 && style->font_size.computed != size_prev) ||
(letterspacing_prev != 0 && style->letter_spacing.computed != letterspacing_prev) ||
diff --git a/src/sp-text.cpp b/src/sp-text.cpp
index da92ad8d4..6ae1c4fba 100644
--- a/src/sp-text.cpp
+++ b/src/sp-text.cpp
@@ -645,6 +645,13 @@ void SPText::_adjustFontsizeRecursive(SPItem *item, double ex, bool is_root)
style->font_size.computed *= ex;
style->letter_spacing.computed *= ex;
style->word_spacing.computed *= ex;
+ if (style->line_height.unit != SP_CSS_UNIT_NONE &&
+ style->line_height.unit != SP_CSS_UNIT_PERCENT &&
+ style->line_height.unit != SP_CSS_UNIT_EM &&
+ style->line_height.unit != SP_CSS_UNIT_EX) {
+ // No unit on 'line-height' property has special behavior.
+ style->line_height.computed *= ex;
+ }
item->updateRepr();
}
diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp
index 8df80d2b6..e71c911bd 100644
--- a/src/widgets/text-toolbar.cpp
+++ b/src/widgets/text-toolbar.cpp
@@ -638,7 +638,8 @@ static void sp_text_lineheight_unit_changed( gpointer /* */, GObject *tbl )
int count = 0;
for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){
if (SP_IS_TEXT (*i)) {
- font_size += (*i)->style->font_size.computed;
+ double doc_scale = Geom::Affine((*i)->i2dt_affine()).descrim();
+ font_size += (*i)->style->font_size.computed * doc_scale;
++count;
}
}
@@ -662,7 +663,8 @@ static void sp_text_lineheight_unit_changed( gpointer /* */, GObject *tbl )
int count = 0;
for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end(); ++i){
if (SP_IS_TEXT (*i)) {
- font_size += (*i)->style->font_size.computed;
+ double doc_scale = Geom::Affine((*i)->i2dt_affine()).descrim();
+ font_size += (*i)->style->font_size.computed * doc_scale;
++count;
}
}
@@ -671,12 +673,13 @@ static void sp_text_lineheight_unit_changed( gpointer /* */, GObject *tbl )
} else {
font_size = 20;
}
- line_height *= font_size;
+
if (old_unit == SP_CSS_UNIT_PERCENT) {
line_height /= 100.0;
} else if (old_unit == SP_CSS_UNIT_EX) {
line_height /= 2.0;
}
+ line_height *= font_size;
line_height = Quantity::convert(line_height, "px", unit);
} else {
// Convert between different absolute units (only used in GUI)
@@ -1252,7 +1255,6 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
double height;
int line_height_unit = -1;
if (query.line_height.normal) {
- std::cout << " normal" << std::endl;
height = Inkscape::Text::Layout::LINE_HEIGHT_NORMAL;
line_height_unit = SP_CSS_UNIT_NONE;
} else {