diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2019-06-17 12:15:54 +0000 |
|---|---|---|
| committer | Tavmjong Bah <tavmjong@free.fr> | 2019-06-17 12:15:54 +0000 |
| commit | 6f0eadeb123edbc0d38bd9433591504743beba68 (patch) | |
| tree | bb4361a9abe4a30df5f3aee7d8c25d549f7d170e /src/ui/toolbar/text-toolbar.cpp | |
| parent | revert 9f72ca52805914ce62d7da1accbef6fe72bd6a46 (diff) | |
| download | inkscape-6f0eadeb123edbc0d38bd9433591504743beba68.tar.gz inkscape-6f0eadeb123edbc0d38bd9433591504743beba68.zip | |
Fix rounding error issues with 'pt' line-height values that prvent using mouse-scroll to change values.
Does not fix problem with other units (which include non-integer values in drop-down menu.
Diffstat (limited to 'src/ui/toolbar/text-toolbar.cpp')
| -rw-r--r-- | src/ui/toolbar/text-toolbar.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/ui/toolbar/text-toolbar.cpp b/src/ui/toolbar/text-toolbar.cpp index b191385df..277af1809 100644 --- a/src/ui/toolbar/text-toolbar.cpp +++ b/src/ui/toolbar/text-toolbar.cpp @@ -2098,11 +2098,15 @@ TextToolbar::selection_changed(Inkscape::Selection * /*selection*/, bool subsele int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT); double size = sp_style_css_size_px_to_units(query.font_size.computed, unit); - //gchar size_text[G_ASCII_DTOSTR_BUF_SIZE]; - //g_ascii_dtostr (size_text, sizeof (size_text), size); - Inkscape::CSSOStringStream os; - os << size; + + int rounded_size = std::round(size); + if (std::abs((size - rounded_size)/size) < 0.0001) { + // We use rounded_size to avoid rounding errors when, say, converting stored 'px' values to displayed 'pt' values. + os << rounded_size; + } else { + os << size; + } // Freeze to ignore callbacks. //g_object_freeze_notify( G_OBJECT( fontSizeAction->combobox ) ); |
