#include <config.h>
#include "dimension.h"
-#include "frontends/FontMetrics.h"
-
namespace lyx {
wid += dim.wid;
}
-
-void Dimension::clear(LyXFont const & font)
-{
- frontend::FontMetrics const & fm = theFontMetrics(font);
- asc = fm.maxAscent();
- des = fm.maxDescent();
- wid = 0;
-}
-
-
-void Dimension::set(LyXFont const & font, char_type c)
-{
- frontend::FontMetrics const & fm = theFontMetrics(font);
- des = fm.descent(c);
- asc = fm.ascent(c);
- wid = fm.width(c);
-}
-
} // namespace lyx
#ifndef DIMENSION_H
#define DIMENSION_H
-#include "support/types.h"
-
namespace lyx {
-class LyXFont;
-
/// Simple wrapper around three ints
class Dimension {
public:
/// initialize data
Dimension(int w, int a, int d) : wid(w), asc(a), des(d) {}
- Dimension(LyXFont const & font, char_type c) { set(font, c); }
-
Dimension & operator=(Dimension const & dim) {
wid = dim.wid;
asc = dim.asc;
void operator+=(Dimension const & dim);
/// set to empty box
void clear() { wid = asc = des = 0; }
- /// set to empty box suitble for given font.
- void clear(LyXFont const & font);
- /// set to a char dimensions for a given font.
- void set(LyXFont const & font, char_type c);
-
/// get height
int height() const { return asc + des; }
/// get ascent
Dimension const GuiFontMetrics::defaultDimension() const
{
- return Dimension(maxAscent(), maxDescent(), 0);
+ return Dimension(0, maxAscent(), maxDescent());
}
Dimension const GuiFontMetrics::dimension(char_type c) const
{
- return Dimension(ascent(c), descent(c), width(c));
+ return Dimension(width(c), ascent(c), descent(c));
}
#include "MathStream.h"
#include "MathSupport.h"
#include "LColor.h"
-#include "support/std_ostream.h"
+
+#include "frontends/FontMetrics.h"
#include "frontends/Painter.h"
+#include "support/std_ostream.h"
namespace lyx {
bool InsetMathBrace::metrics(MetricsInfo & mi, Dimension & dim) const
{
cell(0).metrics(mi);
- Dimension t(mi.base.font, '{');
+ Dimension t = theFontMetrics(mi.base.font).dimension('{');
dim.asc = max(cell(0).ascent(), t.asc);
dim.des = max(cell(0).descent(), t.des);
dim.wid = cell(0).width() + 2 * t.wid;
{
LyXFont font = pi.base.font;
font.setColor(LColor::latex);
- Dimension t(font, '{');
+ Dimension t = theFontMetrics(font).dimension('{');
pi.pain.text(x, y, '{', font);
cell(0).draw(pi, x + t.wid, y);
pi.pain.text(x + t.wid + cell(0).width(), y, '}', font);
#if 1
if (char_ == '=' && has_math_fonts) {
FontSetChanger dummy(mi.base, "cmr");
- dim.set(mi.base.font, char_);
+ dim = theFontMetrics(mi.base.font).dimension(char_);
} else if ((char_ == '>' || char_ == '<') && has_math_fonts) {
FontSetChanger dummy(mi.base, "cmm");
- dim.set(mi.base.font, char_);
+ dim = theFontMetrics(mi.base.font).dimension(char_);
} else if (!slanted(char_) && mi.base.fontname == "mathnormal") {
ShapeChanger dummy(mi.base.font, LyXFont::UP_SHAPE);
- dim.set(mi.base.font, char_);
+ dim = theFontMetrics(mi.base.font).dimension(char_);
} else {
- dim.set(mi.base.font, char_);
+ dim = theFontMetrics(mi.base.font).dimension(char_);
}
int const em = mathed_char_width(mi.base.font, 'M');
if (isBinaryOp(char_))
dim.wid += static_cast<int>(0.1667*em+0.5);
#else
whichFont(font_, code_, mi);
- dim.set(font_, char_);
+ dim = theFontMetrics(font_).dimension(char_);
if (isBinaryOp(char_, code_))
width_ += 2 * theFontMetrics(font_).width(' ');
lyxerr << "InsetMathChar::metrics: " << dim << endl;
#include "MathStream.h"
#include "MathSupport.h"
+#include "frontends/FontMetrics.h"
namespace lyx {
bool InsetMathDelim::metrics(MetricsInfo & mi, Dimension & dim) const
{
cell(0).metrics(mi);
- Dimension t;
- t.set(mi.base.font, 'I');
+ Dimension t = theFontMetrics(mi.base.font).dimension('I');
int h0 = (t.asc + t.des) / 2;
int a0 = max(cell(0).ascent(), t.asc) - h0;
int d0 = max(cell(0).descent(), t.des) + h0;
#include "MathSupport.h"
#include "MathParser.h"
+#include "frontends/FontMetrics.h"
namespace lyx {
bool InsetMathDots::metrics(MetricsInfo & mi, Dimension & dim) const
{
- dim.set(mi.base.font, 'M');
+ dim = theFontMetrics(mi.base.font).dimension('M');
dh_ = 0;
if (key_->name == "cdots" || key_->name == "dotsb"
|| key_->name == "dotsm" || key_->name == "dotsi")
#include "debug.h"
#include "LColor.h"
+#include "frontends/FontMetrics.h"
#include "frontends/Painter.h"
#include <boost/assert.hpp>
void MathArray::metrics(MetricsInfo & mi) const
{
- dim_.set(mi.base.font, 'I');
+ dim_ = theFontMetrics(mi.base.font).dimension('I');
if (empty())
return;