From dbb5ac93ea8d2310038322a81e25242f32e35f71 Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Tue, 27 Apr 2010 19:23:31 +0000 Subject: [PATCH] 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 --- src/mathed/InsetMathDecoration.cpp | 5 +++-- src/mathed/MathSupport.cpp | 7 +++++++ src/mathed/MathSupport.h | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/mathed/InsetMathDecoration.cpp b/src/mathed/InsetMathDecoration.cpp index a717484c05..1cb3aebcc1 100644 --- a/src/mathed/InsetMathDecoration.cpp +++ b/src/mathed/InsetMathDecoration.cpp @@ -22,6 +22,7 @@ #include "LaTeXFeatures.h" #include "support/debug.h" +#include "support/docstring.h" #include "support/lassert.h" #include @@ -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()); diff --git a/src/mathed/MathSupport.cpp b/src/mathed/MathSupport.cpp index 99930ae4bd..7dc8bafa05 100644 --- a/src/mathed/MathSupport.cpp +++ b/src/mathed/MathSupport.cpp @@ -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; diff --git a/src/mathed/MathSupport.h b/src/mathed/MathSupport.h index a2279991af..42d0977be1 100644 --- a/src/mathed/MathSupport.h +++ b/src/mathed/MathSupport.h @@ -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 -- 2.39.2