The check for Color_math would fail if the font color is changed

in mathed, so implement a strategy which is immune to color changes.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34311 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Enrico Forestieri 2010-04-27 19:23:31 +00:00
parent 26ebe0865c
commit dbb5ac93ea
3 changed files with 12 additions and 2 deletions

View File

@ -22,6 +22,7 @@
#include "LaTeXFeatures.h"
#include "support/debug.h"
#include "support/docstring.h"
#include "support/lassert.h"
#include <ostream>
@ -105,7 +106,7 @@ InsetMath::mode_type InsetMathDecoration::currentMode() const
void InsetMathDecoration::metrics(MetricsInfo & mi, Dimension & dim) const
{
bool const upshape = currentMode() == TEXT_MODE
&& mi.base.font.color() == Color_math;
&& isMathFont(from_ascii(mi.base.fontname));
ShapeChanger dummy(mi.base.font, upshape ?
UP_SHAPE : mi.base.font.shape());
@ -129,7 +130,7 @@ void InsetMathDecoration::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetMathDecoration::draw(PainterInfo & pi, int x, int y) const
{
bool const upshape = currentMode() == TEXT_MODE
&& pi.base.font.color() == Color_math;
&& isMathFont(from_ascii(pi.base.fontname));
ShapeChanger dummy(pi.base.font, upshape ?
UP_SHAPE : pi.base.font.shape());

View File

@ -646,6 +646,13 @@ bool isFontName(docstring const & name)
}
bool isMathFont(docstring const & name)
{
fontinfo * f = lookupFont(name);
return f && f->color_ == Color_math;
}
FontInfo getFont(docstring const & name)
{
FontInfo font;

View File

@ -49,6 +49,8 @@ void augmentFont(FontInfo & f, docstring const & cmd);
bool isFontName(docstring const & name);
bool isMathFont(docstring const & name);
// converts single cell to string
docstring asString(MathData const & ar);
// converts single inset to string