#include "support/docstream.h"
#include "support/lstrings.h"
+#include "support/lyxlib.h"
#include <sstream>
#include <iomanip>
double const text_width_in = text_width / (zoom * dpi);
double const result = zoom * dpi * inInch(text_width_in, em_width_in);
- return static_cast<int>(result + ((result >= 0) ? 0.5 : -0.5));
+ return support::iround(result);
}
int Length::inPixels(MetricsBase const & base) const
{
- return inPixels(base.textwidth, theFontMetrics(base.font).em());
+ FontInfo fi = base.font;
+ if (unit_ == Length::MU)
+ // mu is 1/18th of an em in the math symbol font
+ fi.setFamily(SYMBOL_FAMILY);
+ else
+ // Math style is only taken into account in the case of mu
+ fi.setStyle(LM_ST_TEXT);
+ return inPixels(base.textwidth, theFontMetrics(fi).em());
}
double const text_width_in = 210.0 / 2.54; // assume A4
double const em_width_in = 10.0 / 72.27;
double result = 72.0 * inInch(text_width_in, em_width_in);
- return static_cast<int>(result + 0.5);
+ return support::iround(result);
}
GlueLength::GlueLength(string const & data)
{
+ // false positive from coverity
+ // coverity[CHECKED_RETURN]
isValidGlueLength(data, this);
}