Fix bug #6851: Wrong mode and screen fonts with old style macros such as \bf and \rm.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_6_X@35157 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Enrico Forestieri 2010-08-14 18:37:35 +00:00
parent 95024a7fac
commit 352a254bec
3 changed files with 30 additions and 6 deletions

View File

@ -13,8 +13,9 @@
#include "InsetMathFontOld.h"
#include "MathData.h"
#include "MathStream.h"
#include "MathParser.h"
#include "MathStream.h"
#include "MathSupport.h"
#include "MetricsInfo.h"
#include <ostream>
@ -23,7 +24,7 @@
namespace lyx {
InsetMathFontOld::InsetMathFontOld(Buffer * buf, latexkeys const * key)
: InsetMathNest(buf, 1), key_(key)
: InsetMathNest(buf, 1), key_(key), current_mode_(TEXT_MODE)
{
//lock(true);
}
@ -37,7 +38,16 @@ Inset * InsetMathFontOld::clone() const
void InsetMathFontOld::metrics(MetricsInfo & mi, Dimension & dim) const
{
FontSetChanger dummy(mi.base, key_->name.c_str());
current_mode_ = isTextFont(from_ascii(mi.base.fontname))
? TEXT_MODE : MATH_MODE;
docstring const font = current_mode_ == MATH_MODE
? "math" + key_->name : "text" + key_->name;
// When \cal is used in text mode, the font is not changed
bool really_change_font = font != "textcal";
FontSetChanger dummy(mi.base, font, really_change_font);
cell(0).metrics(mi, dim);
metricsMarkers(dim);
}
@ -45,7 +55,16 @@ void InsetMathFontOld::metrics(MetricsInfo & mi, Dimension & dim) const
void InsetMathFontOld::draw(PainterInfo & pi, int x, int y) const
{
FontSetChanger dummy(pi.base, key_->name.c_str());
current_mode_ = isTextFont(from_ascii(pi.base.fontname))
? TEXT_MODE : MATH_MODE;
docstring const font = current_mode_ == MATH_MODE
? "math" + key_->name : "text" + key_->name;
// When \cal is used in text mode, the font is not changed
bool really_change_font = font != "textcal";
FontSetChanger dummy(pi.base, font, really_change_font);
cell(0).draw(pi, x + 1, y);
drawMarkers(pi, x, y);
}

View File

@ -25,8 +25,8 @@ class InsetMathFontOld : public InsetMathNest {
public:
///
explicit InsetMathFontOld(Buffer * buf, latexkeys const * key);
/// we are in text mode.
mode_type currentMode() const { return TEXT_MODE; }
/// we inherit the mode
mode_type currentMode() const { return current_mode_; }
/// we write extra braces in any case...
bool extraBraces() const { return true; }
///
@ -50,6 +50,8 @@ private:
virtual Inset * clone() const;
/// the font to be used on screen
latexkeys const * key_;
/// the inherited mode
mutable mode_type current_mode_;
};

View File

@ -102,6 +102,9 @@ What's new
- Fix handling of commands containing a double quote (") in shortcut
editor (bug 6786).
- Use correct mode and screen fonts for old-style font changing macros
(\bf, \cal, \it, \rm, and \tt) in math (bug 6851).
* DOCUMENTATION AND LOCALIZATION