diff --git a/lib/symbols b/lib/symbols index 1ec2ce5663..1856321657 100644 --- a/lib/symbols +++ b/lib/symbols @@ -198,10 +198,10 @@ hspace* space none hspace space none # styles -displaystyle style 0 -textstyle style 1 -scriptstyle style 2 -scriptscriptstyle style 3 +displaystyle style 3 +textstyle style 2 +scriptstyle style 1 +scriptscriptstyle style 0 # misc # The commented lines in this block get misparsed as MathSymbolInset because diff --git a/src/FontEnums.h b/src/FontEnums.h index 5dd7839508..43d614d22b 100644 --- a/src/FontEnums.h +++ b/src/FontEnums.h @@ -142,5 +142,21 @@ enum FontState { FONT_IGNORE }; + +/// Math styles +enum MathStyle { + /// + LM_ST_SCRIPTSCRIPT = 0, + /// + LM_ST_SCRIPT, + /// + LM_ST_TEXT, + /// + LM_ST_DISPLAY, + /// + NUM_STYLE = LM_ST_DISPLAY +}; + + } // namespace lyx #endif diff --git a/src/FontInfo.cpp b/src/FontInfo.cpp index 9edf97e52e..67255c29d4 100644 --- a/src/FontInfo.cpp +++ b/src/FontInfo.cpp @@ -17,7 +17,9 @@ #include "ColorSet.h" #include "FontInfo.h" #include "Lexer.h" +#include "LyXRC.h" +#include "support/convert.h" #include "support/debug.h" #include "support/docstring.h" #include "support/lstrings.h" @@ -168,6 +170,29 @@ FontInfo & FontInfo::incSize() } +double FontInfo::realSize() const +{ + double d = convert(lyxrc.font_sizes[size()]); + // The following is according to the average of the values in the + // definitions of \defaultscriptratio and \defaultscriptscriptratio in LaTeX + // font packages. No attempt is made to implement the actual values from + // \DefineMathSizes. + switch (style()) { + case LM_ST_DISPLAY: + case LM_ST_TEXT: + break; + case LM_ST_SCRIPT: + d *= .73; + break; + case LM_ST_SCRIPTSCRIPT: + d *= .55; + break; + } + // Never go below the smallest size + return max(d, convert(lyxrc.font_sizes[FONT_SIZE_TINY])); +} + + /// Reduce font to fall back to template where possible void FontInfo::reduce(FontInfo const & tmplt) { @@ -258,6 +283,12 @@ Changer FontInfo::changeShape(FontShape const shape, bool cond) } +Changer FontInfo::changeStyle(MathStyle const new_style, bool cond) +{ + return make_change(style_, new_style, cond); +} + + Changer FontInfo::change(FontInfo font, bool realiz, bool cond) { if (realiz) diff --git a/src/FontInfo.h b/src/FontInfo.h index b8f71e9bd3..b9d8cedd0d 100644 --- a/src/FontInfo.h +++ b/src/FontInfo.h @@ -48,8 +48,8 @@ public: FontState uwave, FontState noun, FontState number) - : family_(family), series_(series), shape_(shape), size_(size), - color_(color), background_(background), paint_color_(), emph_(emph), + : family_(family), series_(series), shape_(shape), size_(size), + style_(LM_ST_TEXT), color_(color), background_(background), emph_(emph), underbar_(underbar), strikeout_(strikeout), uuline_(uuline), uwave_(uwave), noun_(noun), number_(number) {} @@ -69,6 +69,8 @@ public: void setShape(FontShape s) { shape_ = s; } FontSize size() const { return size_; } void setSize(FontSize s) { size_ = s; } + MathStyle style() const {return style_; } + void setStyle(MathStyle s) { style_ = s; } FontState emph() const { return emph_; } void setEmph(FontState e) { emph_ = e; } FontState underbar() const { return underbar_; } @@ -107,6 +109,9 @@ public: /// Sets the color which is used during painting void setPaintColor(Color c) { paint_color_ = c; } + /// Compute the font size, taking size and math style into account. + double realSize() const; + /// docstring asCSS() const; @@ -143,6 +148,8 @@ public: Changer changeColor(ColorCode const color, bool cond = true); /// Temporarily replace the shape with \param shape. Changer changeShape(FontShape const shape, bool cond = true); + /// Temporarily replace the style + Changer changeStyle(MathStyle style, bool cond = true); /// Temporarily replace the FontInfo with \param font, and optionally /// \param realize the \param font against the current FontInfo. Changer change(FontInfo font, bool realize = false, bool cond = true); @@ -159,6 +166,8 @@ private: /// FontSize size_; /// + MathStyle style_; + /// ColorCode color_; /// ColorCode background_; diff --git a/src/MetricsInfo.cpp b/src/MetricsInfo.cpp index fdde05f3d7..96f2fc709c 100644 --- a/src/MetricsInfo.cpp +++ b/src/MetricsInfo.cpp @@ -37,7 +37,7 @@ namespace lyx { ///////////////////////////////////////////////////////////////////////// MetricsBase::MetricsBase(BufferView * b, FontInfo f, int w) - : bv(b), font(move(f)), style(LM_ST_TEXT), fontname("mathnormal"), + : bv(b), font(move(f)), fontname("mathnormal"), textwidth(w), macro_nesting(0), solid_line_thickness_(1), solid_line_offset_(1), dotted_line_thickness_(1) { @@ -71,6 +71,7 @@ Changer MetricsBase::changeFontSet(string const & name, bool cond) font = sane_font; augmentFont(font, name); font.setSize(rc->old.font.size()); + font.setStyle(rc->old.font.style()); if (name != "lyxtex" && ((isTextFont(oldname) && oldcolor != Color_foreground) || (isMathFont(oldname) && oldcolor != Color_math))) @@ -153,13 +154,13 @@ Color PainterInfo::textColor(Color const & color) const Changer MetricsBase::changeScript(bool cond) { - switch (style) { + switch (font.style()) { case LM_ST_DISPLAY: case LM_ST_TEXT: - return changeStyle(LM_ST_SCRIPT, cond); + return font.changeStyle(LM_ST_SCRIPT, cond); case LM_ST_SCRIPT: case LM_ST_SCRIPTSCRIPT: - return changeStyle(LM_ST_SCRIPTSCRIPT, cond); + return font.changeStyle(LM_ST_SCRIPTSCRIPT, cond); } //remove Warning LASSERT(false, return Changer()); @@ -168,42 +169,18 @@ Changer MetricsBase::changeScript(bool cond) Changer MetricsBase::changeFrac(bool cond) { - switch (style) { + switch (font.style()) { case LM_ST_DISPLAY: - return changeStyle(LM_ST_TEXT, cond); + return font.changeStyle(LM_ST_TEXT, cond); case LM_ST_TEXT: - return changeStyle(LM_ST_SCRIPT, cond); + return font.changeStyle(LM_ST_SCRIPT, cond); case LM_ST_SCRIPT: case LM_ST_SCRIPTSCRIPT: - return changeStyle(LM_ST_SCRIPTSCRIPT, cond); + return font.changeStyle(LM_ST_SCRIPTSCRIPT, cond); } //remove Warning return Changer(); } -Changer MetricsBase::changeStyle(Styles new_style, bool cond) -{ - static const int diff[4][4] = - { { 0, 0, -3, -5 }, - { 0, 0, -3, -5 }, - { 3, 3, 0, -2 }, - { 5, 5, 2, 0 } }; - int t = diff[style][new_style]; - RefChanger rc = make_save(*this); - if (!cond) - rc->keep(); - else { - if (t > 0) - while (t--) - font.incSize(); - else - while (t++) - font.decSize(); - style = new_style; - } - return move(rc); -} - - } // namespace lyx diff --git a/src/MetricsInfo.h b/src/MetricsInfo.h index a48b45c563..93eeb8ae19 100644 --- a/src/MetricsInfo.h +++ b/src/MetricsInfo.h @@ -32,20 +32,6 @@ class Inset; class MacroContext; -/// Standard Sizes (mode styles) -/// note: These values are hard-coded in changeStyle -enum Styles { - /// - LM_ST_DISPLAY = 0, - /// - LM_ST_TEXT, - /// - LM_ST_SCRIPT, - /// - LM_ST_SCRIPTSCRIPT -}; - - // // This is the part common to MetricsInfo and PainterInfo // @@ -59,8 +45,6 @@ public: BufferView * bv; /// current font FontInfo font; - /// current math style (display/text/script/..) - Styles style; /// name of current font - mathed specific std::string fontname; /// This is the width available in pixels @@ -70,8 +54,6 @@ public: /// Temporarily change a full font. Changer changeFontSet(std::string const & font, bool cond = true); - /// Temporarily change the font size and the math style. - Changer changeStyle(Styles style, bool cond = true); // Temporarily change to the style suitable for use in fractions Changer changeFrac(bool cond = true); // Temporarily change the style to (script)script style diff --git a/src/frontends/qt4/GuiFontLoader.cpp b/src/frontends/qt4/GuiFontLoader.cpp index cc092f5f72..d61a2782dc 100644 --- a/src/frontends/qt4/GuiFontLoader.cpp +++ b/src/frontends/qt4/GuiFontLoader.cpp @@ -19,7 +19,6 @@ #include "LyXRC.h" -#include "support/convert.h" #include "support/debug.h" #include "support/filetools.h" #include "support/gettext.h" @@ -88,7 +87,18 @@ SymbolFont symbol_fonts[] = { size_t const nr_symbol_fonts = sizeof(symbol_fonts) / sizeof(symbol_fonts[0]); /// BUTT ugly ! -static GuiFontInfo * fontinfo_[NUM_FAMILIES][NUM_SERIES][NUM_SHAPE][NUM_SIZE]; +static GuiFontInfo * +fontinfo_[NUM_FAMILIES][NUM_SERIES][NUM_SHAPE][NUM_SIZE][NUM_STYLE]; + + +// returns a reference to the pointer type (GuiFontInfo *) in the +// fontinfo_ table. +GuiFontInfo * & fontinfo_ptr(FontInfo const & f) +{ + // The display font and the text font are the same + size_t const style = (f.style() == LM_ST_DISPLAY) ? LM_ST_TEXT : f.style(); + return fontinfo_[f.family()][f.series()][f.realShape()][f.size()][style]; +} // Get font info (font + metrics) for the given LyX font. @@ -106,16 +116,12 @@ GuiFontInfo & fontinfo(FontInfo const & f) LYXERR0("Unrealized font!"); FontInfo f2 = f; f2.realize(sane_font); - GuiFontInfo * & fi = - fontinfo_[f2.family()][f2.series()][f2.realShape()][f2.size()]; + GuiFontInfo * & fi = fontinfo_ptr(f2); if (!fi) fi = new GuiFontInfo(f2); return *fi; } - // fi is a reference to the pointer type (GuiFontInfo *) in the - // fontinfo_ table. - GuiFontInfo * & fi = - fontinfo_[f.family()][f.series()][f.realShape()][f.size()]; + GuiFontInfo * & fi = fontinfo_ptr(f); if (!fi) fi = new GuiFontInfo(f); return *fi; @@ -248,7 +254,8 @@ FontLoader::FontLoader() for (int i2 = 0; i2 < NUM_SERIES; ++i2) for (int i3 = 0; i3 < NUM_SHAPE; ++i3) for (int i4 = 0; i4 < NUM_SIZE; ++i4) - fontinfo_[i1][i2][i3][i4] = 0; + for (int i5 = 0; i5 < NUM_STYLE; ++i5) + fontinfo_[i1][i2][i3][i4][i5] = 0; } @@ -257,9 +264,10 @@ void FontLoader::update() for (int i1 = 0; i1 < NUM_FAMILIES; ++i1) for (int i2 = 0; i2 < NUM_SERIES; ++i2) for (int i3 = 0; i3 < NUM_SHAPE; ++i3) - for (int i4 = 0; i4 < NUM_SIZE; ++i4) { - delete fontinfo_[i1][i2][i3][i4]; - fontinfo_[i1][i2][i3][i4] = 0; + for (int i4 = 0; i4 < NUM_SIZE; ++i4) + for (int i5 = 0; i5 < NUM_STYLE; ++i5) { + delete fontinfo_[i1][i2][i3][i4][i5]; + fontinfo_[i1][i2][i3][i4][i5] = 0; } } @@ -355,8 +363,7 @@ QFont makeQFont(FontInfo const & f) LYXERR(Debug::FONT, "XFLD: " << font.rawName()); - font.setPointSizeF(convert(lyxrc.font_sizes[f.size()]) - * lyxrc.zoom / 100.0); + font.setPointSizeF(f.realSize() * lyxrc.zoom / 100.0); LYXERR(Debug::FONT, "The font has size: " << font.pointSizeF()); diff --git a/src/mathed/InsetMathAMSArray.cpp b/src/mathed/InsetMathAMSArray.cpp index 6ec781c6b0..2ed4f2017d 100644 --- a/src/mathed/InsetMathAMSArray.cpp +++ b/src/mathed/InsetMathAMSArray.cpp @@ -85,8 +85,8 @@ char const * InsetMathAMSArray::name_right() const void InsetMathAMSArray::metrics(MetricsInfo & mi, Dimension & dim) const { - Changer dummy = - mi.base.changeStyle(LM_ST_TEXT, mi.base.style == LM_ST_DISPLAY); + FontInfo & f = mi.base.font; + Changer dummy = f.changeStyle(LM_ST_TEXT, f.style() == LM_ST_DISPLAY); InsetMathGrid::metrics(mi, dim); } @@ -98,8 +98,8 @@ void InsetMathAMSArray::draw(PainterInfo & pi, int x, int y) const // Drawing the deco after changeStyle does not work mathed_draw_deco(pi, x + 1, yy, 5, dim.height(), from_ascii(name_left())); mathed_draw_deco(pi, x + dim.width() - 8, yy, 5, dim.height(), from_ascii(name_right())); - Changer dummy = - pi.base.changeStyle(LM_ST_TEXT, pi.base.style == LM_ST_DISPLAY); + FontInfo & f = pi.base.font; + Changer dummy = f.changeStyle(LM_ST_TEXT, f.style() == LM_ST_DISPLAY); InsetMathGrid::draw(pi, x, y); } diff --git a/src/mathed/InsetMathArray.cpp b/src/mathed/InsetMathArray.cpp index 727d45998b..cc007e97a5 100644 --- a/src/mathed/InsetMathArray.cpp +++ b/src/mathed/InsetMathArray.cpp @@ -74,8 +74,8 @@ Inset * InsetMathArray::clone() const void InsetMathArray::metrics(MetricsInfo & mi, Dimension & dim) const { - Changer dummy = - mi.base.changeStyle(LM_ST_TEXT, mi.base.style == LM_ST_DISPLAY); + FontInfo & f = mi.base.font; + Changer dummy = f.changeStyle(LM_ST_TEXT, f.style() == LM_ST_DISPLAY); InsetMathGrid::metrics(mi, dim); } @@ -83,8 +83,8 @@ void InsetMathArray::metrics(MetricsInfo & mi, Dimension & dim) const void InsetMathArray::draw(PainterInfo & pi, int x, int y) const { setPosCache(pi, x, y); - Changer dummy = - pi.base.changeStyle(LM_ST_TEXT, pi.base.style == LM_ST_DISPLAY); + FontInfo & f = pi.base.font; + Changer dummy = f.changeStyle(LM_ST_TEXT, f.style() == LM_ST_DISPLAY); InsetMathGrid::draw(pi, x, y); } diff --git a/src/mathed/InsetMathChar.cpp b/src/mathed/InsetMathChar.cpp index 1669515b66..a2b9b76069 100644 --- a/src/mathed/InsetMathChar.cpp +++ b/src/mathed/InsetMathChar.cpp @@ -36,7 +36,6 @@ extern bool has_math_fonts; namespace { - latexkeys const * makeSubstitute(char_type c) { std::string name; diff --git a/src/mathed/InsetMathDiagram.cpp b/src/mathed/InsetMathDiagram.cpp index d5a1b5231a..18d7c60851 100644 --- a/src/mathed/InsetMathDiagram.cpp +++ b/src/mathed/InsetMathDiagram.cpp @@ -48,12 +48,21 @@ int InsetMathDiagram::rowsep() const void InsetMathDiagram::metrics(MetricsInfo & mi, Dimension & dim) const { - if (mi.base.style == LM_ST_DISPLAY) - mi.base.style = LM_ST_TEXT; + FontInfo & f = mi.base.font; + Changer dummy = f.changeStyle(LM_ST_TEXT, f.style() == LM_ST_DISPLAY); InsetMathGrid::metrics(mi, dim); } +void InsetMathDiagram::draw(PainterInfo & pi, int x, int y) const +{ + setPosCache(pi, x, y); + FontInfo & f = pi.base.font; + Changer dummy = f.changeStyle(LM_ST_TEXT, f.style() == LM_ST_DISPLAY); + InsetMathGrid::draw(pi, x, y); +} + + void InsetMathDiagram::write(WriteStream & os) const { MathEnsurer ensurer(os); diff --git a/src/mathed/InsetMathDiagram.h b/src/mathed/InsetMathDiagram.h index 1e44863dda..732cd4ee1b 100644 --- a/src/mathed/InsetMathDiagram.h +++ b/src/mathed/InsetMathDiagram.h @@ -26,6 +26,8 @@ public: /// void metrics(MetricsInfo &, Dimension &) const; /// + void draw(PainterInfo & pi, int x, int y) const; + /// InsetMathDiagram const * asDiagramInset() const { return this; } /// virtual int colsep() const; diff --git a/src/mathed/InsetMathFrac.cpp b/src/mathed/InsetMathFrac.cpp index 6254924db8..5662923b7b 100644 --- a/src/mathed/InsetMathFrac.cpp +++ b/src/mathed/InsetMathFrac.cpp @@ -181,6 +181,7 @@ void InsetMathFrac::metrics(MetricsInfo & mi, Dimension & dim) const } else { // general cell metrics used for \frac Changer dummy = mi.base.changeFrac(); + // FIXME: Exponential blowup cell(0).metrics(mi, dim0); cell(1).metrics(mi, dim1); if (nargs() == 3) @@ -196,9 +197,9 @@ void InsetMathFrac::metrics(MetricsInfo & mi, Dimension & dim) const || kind_ == DFRAC || kind_ == TFRAC) { // \cfrac and \dfrac are always in display size // \tfrac is in always in text size - Changer dummy2 = mi.base.changeStyle((kind_ == TFRAC) - ? LM_ST_SCRIPT - : LM_ST_DISPLAY); + Changer dummy2 = mi.base.font.changeStyle((kind_ == TFRAC) + ? LM_ST_SCRIPT + : LM_ST_DISPLAY); cell(0).metrics(mi, dim0); cell(1).metrics(mi, dim1); } @@ -252,12 +253,13 @@ void InsetMathFrac::draw(PainterInfo & pi, int x, int y) const } else if (kind_ == FRAC || kind_ == ATOP || kind_ == OVER || kind_ == TFRAC) { // tfrac is in always in text size - Changer dummy2 = pi.base.changeStyle(LM_ST_SCRIPT, kind_ == TFRAC); + Changer dummy2 = pi.base.font.changeStyle(LM_ST_SCRIPT, + kind_ == TFRAC); cell(0).draw(pi, m - dim0.wid / 2, y - dim0.des - 2 - 5); cell(1).draw(pi, m - dim1.wid / 2, y + dim1.asc + 2 - 5); } else { // \cfrac and \dfrac are always in display size - Changer dummy2 = pi.base.changeStyle(LM_ST_DISPLAY); + Changer dummy2 = pi.base.font.changeStyle(LM_ST_DISPLAY); if (kind_ == CFRAC || kind_ == DFRAC) cell(0).draw(pi, m - dim0.wid / 2, y - dim0.des - 2 - 5); else if (kind_ == CFRACLEFT) @@ -574,8 +576,8 @@ void InsetMathBinom::metrics(MetricsInfo & mi, Dimension & dim) const { Dimension dim0, dim1; Changer dummy = - (kind_ == DBINOM) ? mi.base.changeStyle(LM_ST_DISPLAY) : - (kind_ == TBINOM) ? mi.base.changeStyle(LM_ST_SCRIPT) : + (kind_ == DBINOM) ? mi.base.font.changeStyle(LM_ST_DISPLAY) : + (kind_ == TBINOM) ? mi.base.font.changeStyle(LM_ST_SCRIPT) : mi.base.changeFrac(); cell(0).metrics(mi, dim0); cell(1).metrics(mi, dim1); @@ -600,8 +602,8 @@ void InsetMathBinom::draw(PainterInfo & pi, int x, int y) const int m = x + dim.width() / 2; { Changer dummy = - (kind_ == DBINOM) ? pi.base.changeStyle(LM_ST_DISPLAY) : - (kind_ == TBINOM) ? pi.base.changeStyle(LM_ST_SCRIPT) : + (kind_ == DBINOM) ? pi.base.font.changeStyle(LM_ST_DISPLAY) : + (kind_ == TBINOM) ? pi.base.font.changeStyle(LM_ST_SCRIPT) : pi.base.changeFrac(); cell(0).draw(pi, m - dim0.wid / 2, y - dim0.des - 3 - 5); cell(1).draw(pi, m - dim1.wid / 2, y + dim1.asc + 3 - 5); diff --git a/src/mathed/InsetMathHull.cpp b/src/mathed/InsetMathHull.cpp index dc943bb520..1cba6ecb19 100644 --- a/src/mathed/InsetMathHull.cpp +++ b/src/mathed/InsetMathHull.cpp @@ -520,9 +520,9 @@ void InsetMathHull::metrics(MetricsInfo & mi, Dimension & dim) const return; } - // FIXME: Changing the same object repeatedly is inefficient. Changer dummy1 = mi.base.changeFontSet(standardFont()); - Changer dummy2 = mi.base.changeStyle(display() ? LM_ST_DISPLAY : LM_ST_TEXT); + Changer dummy2 = mi.base.font.changeStyle(display() ? LM_ST_DISPLAY + : LM_ST_TEXT); // let the cells adjust themselves InsetMathGrid::metrics(mi, dim); @@ -617,7 +617,8 @@ void InsetMathHull::draw(PainterInfo & pi, int x, int y) const bool const really_change_color = pi.base.font.color() == Color_none; Changer dummy0 = pi.base.font.changeColor(color, really_change_color); Changer dummy1 = pi.base.changeFontSet(standardFont()); - Changer dummy2 = pi.base.changeStyle(display() ? LM_ST_DISPLAY : LM_ST_TEXT); + Changer dummy2 = pi.base.font.changeStyle(display() ? LM_ST_DISPLAY + : LM_ST_TEXT); InsetMathGrid::draw(pi, x + 1, y); diff --git a/src/mathed/InsetMathSize.cpp b/src/mathed/InsetMathSize.cpp index 46ea29b30f..ef48d0b525 100644 --- a/src/mathed/InsetMathSize.cpp +++ b/src/mathed/InsetMathSize.cpp @@ -31,7 +31,8 @@ using namespace std; namespace lyx { InsetMathSize::InsetMathSize(Buffer * buf, latexkeys const * l) - : InsetMathNest(buf, 1), key_(l), style_(Styles(convert(l->extra))) + : InsetMathNest(buf, 1), key_(l), + style_(MathStyle(convert(l->extra))) {} @@ -43,7 +44,7 @@ Inset * InsetMathSize::clone() const void InsetMathSize::metrics(MetricsInfo & mi, Dimension & dim) const { - Changer dummy = mi.base.changeStyle(style_); + Changer dummy = mi.base.font.changeStyle(style_); cell(0).metrics(mi, dim); metricsMarkers(mi, dim); } @@ -51,7 +52,7 @@ void InsetMathSize::metrics(MetricsInfo & mi, Dimension & dim) const void InsetMathSize::draw(PainterInfo & pi, int x, int y) const { - Changer dummy = pi.base.changeStyle(style_); + Changer dummy = pi.base.font.changeStyle(style_); cell(0).draw(pi, x + 1, y); drawMarkers(pi, x, y); } diff --git a/src/mathed/InsetMathSize.h b/src/mathed/InsetMathSize.h index f3d8f8d37a..446e398f1a 100644 --- a/src/mathed/InsetMathSize.h +++ b/src/mathed/InsetMathSize.h @@ -53,7 +53,7 @@ private: /// latexkeys const * key_; /// - Styles const style_; + MathStyle const style_; }; diff --git a/src/mathed/InsetMathSubstack.cpp b/src/mathed/InsetMathSubstack.cpp index 06fd296a98..461c88e58d 100644 --- a/src/mathed/InsetMathSubstack.cpp +++ b/src/mathed/InsetMathSubstack.cpp @@ -45,14 +45,16 @@ Inset * InsetMathSubstack::clone() const void InsetMathSubstack::metrics(MetricsInfo & mi, Dimension & dim) const { - Changer dummy = mi.base.changeStyle(LM_ST_TEXT, mi.base.style == LM_ST_DISPLAY); + FontInfo & f = mi.base.font; + Changer dummy = f.changeStyle(LM_ST_TEXT, f.style() == LM_ST_DISPLAY); InsetMathGrid::metrics(mi, dim); } void InsetMathSubstack::draw(PainterInfo & pi, int x, int y) const { - Changer dummy = pi.base.changeStyle(LM_ST_TEXT, pi.base.style == LM_ST_DISPLAY); + FontInfo & f = pi.base.font; + Changer dummy = f.changeStyle(LM_ST_TEXT, f.style() == LM_ST_DISPLAY); InsetMathGrid::draw(pi, x + 1, y); } diff --git a/src/mathed/InsetMathSymbol.cpp b/src/mathed/InsetMathSymbol.cpp index 01bafe614d..885aa60f01 100644 --- a/src/mathed/InsetMathSymbol.cpp +++ b/src/mathed/InsetMathSymbol.cpp @@ -72,7 +72,7 @@ void InsetMathSymbol::metrics(MetricsInfo & mi, Dimension & dim) const } // set scriptable_ scriptable_ = false; - if (mi.base.style == LM_ST_DISPLAY) + if (mi.base.font.style() == LM_ST_DISPLAY) if (sym_->inset == "cmex" || sym_->inset == "esint" || sym_->extra == "funclim" || (sym_->inset == "stmry" && sym_->extra == "mathop")) diff --git a/src/mathed/InsetMathXYMatrix.cpp b/src/mathed/InsetMathXYMatrix.cpp index 52043db56a..743c07ebd3 100644 --- a/src/mathed/InsetMathXYMatrix.cpp +++ b/src/mathed/InsetMathXYMatrix.cpp @@ -49,12 +49,21 @@ int InsetMathXYMatrix::rowsep() const void InsetMathXYMatrix::metrics(MetricsInfo & mi, Dimension & dim) const { - if (mi.base.style == LM_ST_DISPLAY) - mi.base.style = LM_ST_TEXT; + FontInfo & f = mi.base.font; + Changer dummy = f.changeStyle(LM_ST_TEXT, f.style() == LM_ST_DISPLAY); InsetMathGrid::metrics(mi, dim); } +void InsetMathXYMatrix::draw(PainterInfo & pi, int x, int y) const +{ + setPosCache(pi, x, y); + FontInfo & f = pi.base.font; + Changer dummy = f.changeStyle(LM_ST_TEXT, f.style() == LM_ST_DISPLAY); + InsetMathGrid::draw(pi, x, y); +} + + void InsetMathXYMatrix::write(WriteStream & os) const { MathEnsurer ensurer(os); diff --git a/src/mathed/InsetMathXYMatrix.h b/src/mathed/InsetMathXYMatrix.h index 72f48efe46..a5be7c0af3 100644 --- a/src/mathed/InsetMathXYMatrix.h +++ b/src/mathed/InsetMathXYMatrix.h @@ -27,6 +27,8 @@ public: /// void metrics(MetricsInfo &, Dimension &) const; /// + void draw(PainterInfo & pi, int x, int y) const; + /// InsetMathXYMatrix const * asXYMatrixInset() const { return this; } /// virtual int colsep() const; diff --git a/src/mathed/MathClass.cpp b/src/mathed/MathClass.cpp index a46aad3794..f000a3e114 100644 --- a/src/mathed/MathClass.cpp +++ b/src/mathed/MathClass.cpp @@ -146,7 +146,7 @@ int class_spacing(MathClass const mc1, MathClass const mc2, //lyxerr << class_to_string(mc1) << "+" << class_to_string(mc2) // << "=" << spc_code << " @" << mb.style << endl; if (spc_code < 0) { - switch (mb.style) { + switch (mb.font.style()) { case LM_ST_DISPLAY: case LM_ST_TEXT: spc_code = abs(spc_code); diff --git a/src/mathed/MathMacroTemplate.cpp b/src/mathed/MathMacroTemplate.cpp index b4d1c1cfcb..42d81772b7 100644 --- a/src/mathed/MathMacroTemplate.cpp +++ b/src/mathed/MathMacroTemplate.cpp @@ -544,7 +544,7 @@ void MathMacroTemplate::createLook(int args) const void MathMacroTemplate::metrics(MetricsInfo & mi, Dimension & dim) const { Changer dummy1 = mi.base.changeFontSet("mathnormal"); - Changer dummy2 = mi.base.changeStyle(LM_ST_TEXT); + Changer dummy2 = mi.base.font.changeStyle(LM_ST_TEXT); // valid macro? MacroData const * macro = 0; @@ -588,7 +588,7 @@ void MathMacroTemplate::draw(PainterInfo & pi, int x, int y) const // FIXME: Calling Changer on the same object repeatedly is inefficient. Changer dummy0 = pi.base.font.changeColor(Color_math); Changer dummy1 = pi.base.changeFontSet("mathnormal"); - Changer dummy2 = pi.base.changeStyle(LM_ST_TEXT); + Changer dummy2 = pi.base.font.changeStyle(LM_ST_TEXT); setPosCache(pi, x, y); Dimension const dim = dimension(*pi.base.bv);