]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_support.C
fix #1073
[lyx.git] / src / mathed / math_support.C
index 5bcdbfd8bd600cc29719a152c6ef67a6f5f5569a..a893da51ce5fd494cb69b6dcde57d8f827e2ebd1 100644 (file)
@@ -6,12 +6,12 @@
 #include "math_cursor.h"
 #include "math_inset.h"
 #include "math_parser.h"
-#include "math_metricsinfo.h"
+#include "metricsinfo.h"
 #include "frontends/Painter.h"
 #include "frontends/font_metrics.h"
 #include "frontends/lyx_gui.h"
 #include "debug.h"
-#include "commandtags.h"
+#include "lfuns.h"
 #include "dimension.h"
 
 #include <map>
@@ -62,7 +62,7 @@ namespace {
 
 
 double const parenthHigh[] = {
-13,
+       2, 13,
        0.9840, 0.0014, 0.7143, 0.0323, 0.4603, 0.0772,
        0.2540, 0.1278, 0.1746, 0.1966, 0.0952, 0.3300,
        0.0950, 0.5000, 0.0952, 0.6700, 0.1746, 0.8034,
@@ -73,7 +73,7 @@ double const parenthHigh[] = {
 
 
 double const parenth[] = {
-13,
+       2, 13,
        0.9930, 0.0071, 0.7324, 0.0578, 0.5141, 0.1126,
        0.3380, 0.1714, 0.2183, 0.2333, 0.0634, 0.3621,
        0.0141, 0.5000, 0.0563, 0.6369, 0.2113, 0.7647,
@@ -84,7 +84,7 @@ double const parenth[] = {
 
 
 double const brace[] = {
-21,
+       2, 21,
        0.9492, 0.0020, 0.9379, 0.0020, 0.7458, 0.0243,
        0.5819, 0.0527, 0.4859, 0.0892, 0.4463, 0.1278,
        0.4463, 0.3732, 0.4011, 0.4199, 0.2712, 0.4615,
@@ -97,139 +97,139 @@ double const brace[] = {
 
 
 double const arrow[] = {
-
+       4, 7,
        0.0150, 0.7500, 0.2000, 0.6000, 0.3500, 0.3500,
        0.5000, 0.0500, 0.6500, 0.3500, 0.8000, 0.6000,
        0.9500, 0.7500,
-0.1500,
+       3, 0.5000, 0.1500, 0.5000, 0.9500,
        0
 };
 
 
 double const Arrow[] = {
-
+       4, 7,
        0.0150, 0.7500, 0.2000, 0.6000, 0.3500, 0.3500,
        0.5000, 0.0500, 0.6500, 0.3500, 0.8000, 0.6000,
        0.9500, 0.7500,
-0.5000,
-0.5000,
+       3, 0.3500, 0.5000, 0.3500, 0.9500,
+       3, 0.6500, 0.5000, 0.6500, 0.9500,
        0
 };
 
 
 double const udarrow[] = {
-3,
+       2, 3,
        0.015, 0.25,  0.5, 0.05, 0.95, 0.25,
-3,
+       2, 3,
        0.015, 0.75,  0.5, 0.95, 0.95, 0.75,
-1,
+       1, 0.5, 0.2,  0.5, 0.8,
        0
 };
 
 
 double const Udarrow[] = {
-3,
+       2, 3,
        0.015, 0.25,  0.5, 0.05, 0.95, 0.25,
-3,
+       2, 3,
        0.015, 0.75,  0.5, 0.95, 0.95, 0.75,
-1,
-1,
+       1, 0.35, 0.2, 0.35, 0.8,
+       1, 0.65, 0.2, 0.65, 0.8,
        0
 };
 
 
 double const brack[] = {
-4,
+       2, 4,
        0.95, 0.05,  0.05, 0.05,  0.05, 0.95,  0.95, 0.95,
        0
 };
 
 
 double const corner[] = {
-3,
+       2, 3,
        0.95, 0.05,  0.05, 0.05,  0.05, 0.95,
        0
 };
 
 
 double const angle[] = {
-3,
-1,
+       2, 3,
+       1, 0,  0.05, 0.5,  1, 1,
        0
 };
 
 
 double const slash[] = {
-1,
+       1, 0.95, 0.05, 0.05, 0.95,
        0
 };
 
 
 double const hline[] = {
-1,
+       1, 0.00, 0.5, 1.0, 0.5,
        0
 };
 
 
 double const ddot[] = {
-1,
-1,
+       1, 0.2, 0.5,  0.3, 0.5,
+       1, 0.7, 0.5,  0.8, 0.5,
        0
 };
 
 
 double const dddot[] = {
-1,
-1,
-1,
+       1, 0.1, 0.5,  0.2, 0.5,
+       1, 0.45, 0.5, 0.55, 0.5,
+       1, 0.8, 0.5,  0.9, 0.5,
        0
 };
 
 
 double const hline3[] = {
-1,
-1,
-1,
+       1, 0.1,   0,  0.15,  0,
+       1, 0.475, 0,  0.525, 0,
+       1, 0.85,  0,  0.9,   0,
        0
 };
 
 
 double const dline3[] = {
-1,
-1,
-1,
+       1, 0.1,   0.1,   0.15,  0.15,
+       1, 0.475, 0.475, 0.525, 0.525,
+       1, 0.85,  0.85,  0.9,   0.9,
        0
 };
 
 
 double const hlinesmall[] = {
-1,
+       1, 0.4, 0.5, 0.6, 0.5,
        0
 };
 
 
 double const ring[] = {
-5,
+       2, 5,
        0.5, 0.8,  0.8, 0.5,  0.5, 0.2,  0.2, 0.5,  0.5, 0.8,
        0
 };
 
 
 double const vert[] = {
-1,
+       1, 0.5, 0.05,  0.5, 0.95,
        0
 };
 
 
 double const  Vert[] = {
-1,
-1,
+       1, 0.3, 0.05,  0.3, 0.95,
+       1, 0.7, 0.05,  0.7, 0.95,
        0
 };
 
 
 double const tilde[] = {
-4,
+       2, 4,
        0.00, 0.8,  0.25, 0.2,  0.75, 0.8,  1.00, 0.2,
        0
 };
@@ -395,12 +395,12 @@ int mathed_string_width(LyXFont const & font, string const & s)
 }
 
 
-void mathed_draw_deco(MathPainterInfo & pi, int x, int y, int w, int h,
+void mathed_draw_deco(PainterInfo & pi, int x, int y, int w, int h,
        const string & name)
 {
        if (name == ".") {
                pi.pain.line(x + w/2, y, x + w/2, y + h,
-                         LColor::mathcursor, Painter::line_onoffdash);
+                         LColor::cursor, Painter::line_onoffdash);
                return;
        }
 
@@ -465,7 +465,7 @@ void mathed_draw_deco(MathPainterInfo & pi, int x, int y, int w, int h,
 }
 
 
-void mathed_draw_framebox(MathPainterInfo & pi, int x, int y, MathInset const * p)
+void mathed_draw_framebox(PainterInfo & pi, int x, int y, MathInset const * p)
 {
        if (mathcursor && mathcursor->isInside(p))
                pi.pain.rectangle(x, y - p->ascent(), p->width(), p->height(),
@@ -474,14 +474,14 @@ void mathed_draw_framebox(MathPainterInfo & pi, int x, int y, MathInset const *
 
 
 // In the future maybe we use a better fonts renderer
-void drawStr(MathPainterInfo & pi, LyXFont const & font,
+void drawStr(PainterInfo & pi, LyXFont const & font,
        int x, int y, string const & str)
 {
        pi.pain.text(x, y, str, font);
 }
 
 
-void drawStrRed(MathPainterInfo & pi, int x, int y, string const & str)
+void drawStrRed(PainterInfo & pi, int x, int y, string const & str)
 {
        LyXFont f = pi.base.font;
        f.setColor(LColor::latex);
@@ -489,15 +489,15 @@ void drawStrRed(MathPainterInfo & pi, int x, int y, string const & str)
 }
 
 
-void drawStrBlack(MathPainterInfo & pi, int x, int y, string const & str)
+void drawStrBlack(PainterInfo & pi, int x, int y, string const & str)
 {
        LyXFont f = pi.base.font;
-       f.setColor(LColor::black);
+       f.setColor(LColor::foreground);
        pi.pain.text(x, y, str, f);
 }
 
 
-void drawChar(MathPainterInfo & pi, LyXFont const & font, int x, int y, char c)
+void drawChar(PainterInfo & pi, LyXFont const & font, int x, int y, char c)
 {
        pi.pain.text(x, y, c, font);
 }
@@ -527,55 +527,89 @@ LyXFont::FONT_SHAPE  const inh_shape  = LyXFont::INHERIT_SHAPE;
 // mathnormal should be the first, otherwise the fallback further down
 // does not work
 fontinfo fontinfos[] = {
-       {"mathnormal",
-               inh_family, LyXFont::MEDIUM_SERIES, LyXFont::UP_SHAPE, LColor::math},
-       {"mathbf", inh_family, LyXFont::BOLD_SERIES, inh_shape, LColor::math},
-       {"mathcal",LyXFont::CMSY_FAMILY, inh_series, inh_shape, LColor::math},
-       {"mathfrak", LyXFont::EUFRAK_FAMILY, inh_series, inh_shape, LColor::math},
-       {"mathrm", LyXFont::ROMAN_FAMILY, inh_series, inh_shape, LColor::math},
-       {"mathsf", LyXFont::SANS_FAMILY, inh_series, inh_shape, LColor::math},
-       {"mathbb", LyXFont::MSB_FAMILY, inh_series, inh_shape, LColor::math},
-       {"mathtt", LyXFont::TYPEWRITER_FAMILY, inh_series, inh_shape, LColor::math},
-       {"cmex",   LyXFont::CMEX_FAMILY, inh_series, inh_shape, LColor::none},
-       {"cmm",    LyXFont::CMM_FAMILY, inh_series, inh_shape, LColor::none},
-       {"cmr",    LyXFont::CMR_FAMILY, inh_series, inh_shape, LColor::none},
-       {"cmsy",   LyXFont::CMSY_FAMILY, inh_series, inh_shape, LColor::none},
-       {"eufrak", LyXFont::EUFRAK_FAMILY, inh_series, inh_shape, LColor::none},
-       {"msa",    LyXFont::MSA_FAMILY, inh_series, inh_shape, LColor::none},
-       {"msb",    LyXFont::MSB_FAMILY, inh_series, inh_shape, LColor::none},
-       {"wasy",   LyXFont::WASY_FAMILY, inh_series, inh_shape, LColor::none},
-       {"text",   inh_family, inh_series, inh_shape, LColor::black},
-       {"textbf", inh_family, LyXFont::BOLD_SERIES, inh_shape, LColor::black},
-       {"textit", inh_family, inh_series, LyXFont::ITALIC_SHAPE, LColor::black},
-       {"textmd", inh_family, LyXFont::MEDIUM_SERIES, inh_shape, LColor::black},
-       {"textnormal", inh_family, inh_series, LyXFont::UP_SHAPE, LColor::black},
-       {"textrm", LyXFont::ROMAN_FAMILY, inh_series,LyXFont::UP_SHAPE,LColor::black},
-       {"textsc", inh_family, inh_series, LyXFont::SMALLCAPS_SHAPE, LColor::black},
-       {"textsf", LyXFont::SANS_FAMILY, inh_series, inh_shape, LColor::black},
-       {"textsl", inh_family, inh_series, LyXFont::SLANTED_SHAPE, LColor::black},
-       {"texttt", LyXFont::TYPEWRITER_FAMILY, inh_series, inh_shape, LColor::black},
-       {"textup", inh_family, inh_series, LyXFont::UP_SHAPE, LColor::black},
+       // math fonts
+       {"mathnormal",    inh_family, LyXFont::MEDIUM_SERIES,
+                         LyXFont::UP_SHAPE, LColor::math},
+       {"mathbf",        inh_family, LyXFont::BOLD_SERIES,
+                         inh_shape, LColor::math},
+       {"mathcal",       LyXFont::CMSY_FAMILY, inh_series,
+                         inh_shape, LColor::math},
+       {"mathfrak",      LyXFont::EUFRAK_FAMILY, inh_series,
+                         inh_shape, LColor::math},
+       {"mathrm",        LyXFont::ROMAN_FAMILY, inh_series,
+                         inh_shape, LColor::math},
+       {"mathsf",        LyXFont::SANS_FAMILY, inh_series,
+                         inh_shape, LColor::math},
+       {"mathbb",        LyXFont::MSB_FAMILY, inh_series,
+                         inh_shape, LColor::math},
+       {"mathtt",        LyXFont::TYPEWRITER_FAMILY, inh_series,
+                         inh_shape, LColor::math},
+       {"cmex",          LyXFont::CMEX_FAMILY, inh_series,
+                         inh_shape, LColor::none},
+       {"cmm",           LyXFont::CMM_FAMILY, inh_series,
+                         inh_shape, LColor::none},
+       {"cmr",           LyXFont::CMR_FAMILY, inh_series,
+                         inh_shape, LColor::none},
+       {"cmsy",          LyXFont::CMSY_FAMILY, inh_series,
+                         inh_shape, LColor::none},
+       {"eufrak",        LyXFont::EUFRAK_FAMILY, inh_series,
+                         inh_shape, LColor::none},
+       {"msa",           LyXFont::MSA_FAMILY, inh_series,
+                         inh_shape, LColor::none},
+       {"msb",           LyXFont::MSB_FAMILY, inh_series,
+                         inh_shape, LColor::none},
+       {"wasy",          LyXFont::WASY_FAMILY, inh_series,
+                         inh_shape, LColor::none},
+
+       // Text fonts
+       {"text",          inh_family, inh_series,
+                         inh_shape, LColor::foreground},
+       {"textbf",        inh_family, LyXFont::BOLD_SERIES,
+                         inh_shape, LColor::foreground},
+       {"textit",        inh_family, inh_series,
+                         LyXFont::ITALIC_SHAPE, LColor::foreground},
+       {"textmd",        inh_family, LyXFont::MEDIUM_SERIES,
+                         inh_shape, LColor::foreground},
+       {"textnormal",    inh_family, inh_series,
+                         LyXFont::UP_SHAPE, LColor::foreground},
+       {"textrm",        LyXFont::ROMAN_FAMILY,
+                         inh_series,LyXFont::UP_SHAPE,LColor::foreground},
+       {"textsc",        inh_family, inh_series,
+                         LyXFont::SMALLCAPS_SHAPE, LColor::foreground},
+       {"textsf",        LyXFont::SANS_FAMILY, inh_series,
+                         inh_shape, LColor::foreground},
+       {"textsl",        inh_family, inh_series,
+                         LyXFont::SLANTED_SHAPE, LColor::foreground},
+       {"texttt",        LyXFont::TYPEWRITER_FAMILY, inh_series,
+                         inh_shape, LColor::foreground},
+       {"textup",        inh_family, inh_series,
+                         LyXFont::UP_SHAPE, LColor::foreground},
 
        // TIPA support
-       {"textipa",   inh_family, inh_series, inh_shape, LColor::black},
-
-       {"lyxtex", inh_family, inh_series, inh_shape, LColor::latex},
-       {"lyxert", LyXFont::TYPEWRITER_FAMILY, inh_series, inh_shape, LColor::latex},
-       {"lyxsymbol", LyXFont::SYMBOL_FAMILY, inh_series, inh_shape, LColor::math},
-       {"lyxboldsymbol",
-               LyXFont::SYMBOL_FAMILY, LyXFont::BOLD_SERIES, inh_shape, LColor::math},
-       {"lyxitsymbol", LyXFont::SYMBOL_FAMILY,
-               inh_series, LyXFont::ITALIC_SHAPE, LColor::math},
-       {"lyxblacktext", LyXFont::ROMAN_FAMILY,
-               LyXFont::MEDIUM_SERIES, LyXFont::UP_SHAPE, LColor::black},
-       {"lyxnochange", inh_family, inh_series, inh_shape, LColor::black},
-
-       {"lyxfakebb", LyXFont::TYPEWRITER_FAMILY, LyXFont::BOLD_SERIES,
-               LyXFont::UP_SHAPE, LColor::math},
-       {"lyxfakecal", LyXFont::SANS_FAMILY, LyXFont::MEDIUM_SERIES,
-               LyXFont::ITALIC_SHAPE, LColor::math},
-       {"lyxfakefrak", LyXFont::ROMAN_FAMILY, LyXFont::BOLD_SERIES,
-               LyXFont::ITALIC_SHAPE, LColor::math}
+       {"textipa",       inh_family, inh_series,
+                         inh_shape, LColor::foreground},
+
+       // LyX internal usage
+       {"lyxtex",        inh_family, inh_series,
+                         inh_shape, LColor::latex},
+       {"lyxert",        LyXFont::TYPEWRITER_FAMILY, inh_series,
+                         inh_shape, LColor::latex},
+       {"lyxsymbol",     LyXFont::SYMBOL_FAMILY, inh_series,
+                         inh_shape, LColor::math},
+       {"lyxboldsymbol", LyXFont::SYMBOL_FAMILY, LyXFont::BOLD_SERIES,
+                         inh_shape, LColor::math},
+       {"lyxitsymbol",   LyXFont::SYMBOL_FAMILY, inh_series,
+                    LyXFont::ITALIC_SHAPE, LColor::math},
+       {"lyxblacktext",  LyXFont::ROMAN_FAMILY, LyXFont::MEDIUM_SERIES,
+                    LyXFont::UP_SHAPE, LColor::foreground},
+       {"lyxnochange",   inh_family, inh_series,
+                    inh_shape, LColor::foreground},
+       {"lyxfakebb",     LyXFont::TYPEWRITER_FAMILY, LyXFont::BOLD_SERIES,
+                         LyXFont::UP_SHAPE, LColor::math},
+       {"lyxfakecal",    LyXFont::SANS_FAMILY, LyXFont::MEDIUM_SERIES,
+                         LyXFont::ITALIC_SHAPE, LColor::math},
+       {"lyxfakefrak",   LyXFont::ROMAN_FAMILY, LyXFont::BOLD_SERIES,
+                         LyXFont::ITALIC_SHAPE, LColor::math}
 };