Use iround function, amend c0ce79452f

This commit is contained in:
Yuriy Skalko 2020-11-26 22:10:45 +02:00
parent 8cb728c2d7
commit 59e2becdd8
3 changed files with 8 additions and 5 deletions

View File

@ -26,6 +26,7 @@
#include "support/debug.h" #include "support/debug.h"
#include "support/lassert.h" #include "support/lassert.h"
#include "support/lstrings.h" #include "support/lstrings.h"
#include "support/lyxlib.h"
#include <algorithm> #include <algorithm>
#include <ostream> #include <ostream>
@ -297,7 +298,7 @@ int Row::left_x() const
x += cit->full_width(); x += cit->full_width();
++cit; ++cit;
} }
return int(x + 0.5); return support::iround(x);
} }
@ -313,7 +314,7 @@ int Row::right_x() const
else else
break; break;
} }
return int(x + 0.5); return support::iround(x);
} }

View File

@ -12,8 +12,9 @@
#include <config.h> #include <config.h>
#include "Spacing.h" #include "Spacing.h"
#include "support/lstrings.h"
#include "support/convert.h" #include "support/convert.h"
#include "support/lstrings.h"
#include "support/lyxlib.h"
#include <ostream> #include <ostream>
@ -55,7 +56,7 @@ void Spacing::set(Spacing::Space sp, string const & val)
{ {
space = sp; space = sp;
if (sp == Other) { if (sp == Other) {
switch (int(convert<double>(val) * 1000 + 0.5)) { switch (support::iround(convert<double>(val) * 1000)) {
case 1000: case 1000:
space = Single; space = Single;
break; break;

View File

@ -19,6 +19,7 @@
#include "PreviewLoader.h" #include "PreviewLoader.h"
#include "support/FileName.h" #include "support/FileName.h"
#include "support/lyxlib.h"
using namespace std; using namespace std;
@ -85,7 +86,7 @@ Dimension PreviewImage::dim() const
if (!image) if (!image)
return dim; return dim;
dim.asc = int(pimpl_->ascent_frac_ * double(image->height()) + 0.5); dim.asc = support::iround(pimpl_->ascent_frac_ * double(image->height()));
dim.des = image->height() - dim.asc; dim.des = image->height() - dim.asc;
dim.wid = image->width(); dim.wid = image->width();
return dim; return dim;