]> git.lyx.org Git - features.git/commitdiff
The check for Color_math would fail if the font color is changed
authorEnrico Forestieri <forenr@lyx.org>
Tue, 27 Apr 2010 19:23:31 +0000 (19:23 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Tue, 27 Apr 2010 19:23:31 +0000 (19:23 +0000)
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

src/mathed/InsetMathDecoration.cpp
src/mathed/MathSupport.cpp
src/mathed/MathSupport.h

index a717484c055d2a248e339ebe4e8361d1fa585288..1cb3aebcc197a5528da5ab25cd96d5c5e9c25574 100644 (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());
 
index 99930ae4bd8107d9b23c2c8d1e587ee6e69d443e..7dc8bafa0596cc2d17e1c7d00ebdf701f6a675d6 100644 (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;
index a2279991af1474c24046c7d3558fe0367da83780..42d0977be12b2203277e360afb376f545bebed31 100644 (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