mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
Correct computation of math font size
Move math style to FontInfo and compute the font sizes for scriptstyle and scriptscriptstyle according to standard proportions: 0.73 and 0.55. This is simpler and more accurate. It also fixes the font size of ${\scriptscriptstyle {\textstyle A}}A$ which exposed the limitations of the previous approach.
This commit is contained in:
parent
cb6c40a07b
commit
a9eb87a89d
@ -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
|
||||
|
@ -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
|
||||
|
@ -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<double>(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<double>(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)
|
||||
|
@ -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_;
|
||||
|
@ -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<MetricsBase> 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
|
||||
|
@ -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
|
||||
|
@ -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<double>(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());
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,6 @@ extern bool has_math_fonts;
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
latexkeys const * makeSubstitute(char_type c)
|
||||
{
|
||||
std::string name;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
||||
|
@ -31,7 +31,8 @@ using namespace std;
|
||||
namespace lyx {
|
||||
|
||||
InsetMathSize::InsetMathSize(Buffer * buf, latexkeys const * l)
|
||||
: InsetMathNest(buf, 1), key_(l), style_(Styles(convert<int>(l->extra)))
|
||||
: InsetMathNest(buf, 1), key_(l),
|
||||
style_(MathStyle(convert<int>(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);
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ private:
|
||||
///
|
||||
latexkeys const * key_;
|
||||
///
|
||||
Styles const style_;
|
||||
MathStyle const style_;
|
||||
};
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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"))
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user