lyx_mirror/src/dimension.C
Abdelrazak Younes 8f98ec35e4 This commit fixes the following bug:
http://bugzilla.lyx.org/show_bug.cgi?id=2900

The only drawback is that it requires about 20Mo extra-memory when loading the UserGuide. If it turns out to be too much, we can switch to a QHash based solution instead of a table.

* dimension.[Ch]:
  - Dimension(LyXFont const, char_typec): new ctor
  - set(LyXFont const & font, char_type c): new method.

* frontends/FontMetrics.h:
  - width(char_type): is now a pure virtual method.

* GuiFontMetrics:
  - CharMetrics: new structure;
  - the metrics cache now also cache ascent and descent. This is especially useful for mathed.

* MathSupport.[Ch]:
  - mathed_char_dim(): deleted. We now use Dimension::set() directly instead.

* rowpainter.C: fixe empty space.



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16124 a592a061-630c-0410-9148-cb99ea01b6c8
2006-12-01 16:12:24 +00:00

48 lines
840 B
C

/**
* \file dimension.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author André Pönitz
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "dimension.h"
#include "frontends/FontMetrics.h"
namespace lyx {
void Dimension::operator+=(Dimension const & dim)
{
if (asc < dim.asc)
asc = dim.asc;
if (des < dim.des)
des = dim.des;
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