]> git.lyx.org Git - features.git/commitdiff
Fix bug #5167: Correctly paint special characters in InsetMathFont
authorVincent van Ravesteijn <vfr@lyx.org>
Thu, 3 May 2012 13:51:55 +0000 (15:51 +0200)
committerVincent van Ravesteijn <vfr@lyx.org>
Sun, 6 May 2012 15:23:21 +0000 (17:23 +0200)
When using, e.g., a 'mathcal' inset in math, the inline completion and
other special characters like '\#', '{..}' are are painted in the
'mathcal' font as well. This is overcome by setting the mathnormal font
before painted these characters.

(cherry picked from commit 63772964923f765e4ab975946215725086a9c838)

src/mathed/InsetMathBrace.cpp
src/mathed/MathData.cpp
src/mathed/MathSupport.cpp
status.20x

index 14279c1d5100c077634702e83a9137de9eaad9f0..105165903d56b5dbe02feeb6345fe9cb2578ce0e 100644 (file)
@@ -48,7 +48,9 @@ void InsetMathBrace::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        Dimension dim0;
        cell(0).metrics(mi, dim0);
-       Dimension t = theFontMetrics(mi.base.font).dimension('{');
+       FontInfo font = mi.base.font;
+       augmentFont(font, from_ascii("mathnormal"));
+       Dimension t = theFontMetrics(font).dimension('{');
        dim.asc = max(dim0.asc, t.asc);
        dim.des = max(dim0.des, t.des);
        dim.wid = dim0.width() + 2 * t.wid;
@@ -59,6 +61,7 @@ void InsetMathBrace::metrics(MetricsInfo & mi, Dimension & dim) const
 void InsetMathBrace::draw(PainterInfo & pi, int x, int y) const
 {
        FontInfo font = pi.base.font;
+       augmentFont(font, from_ascii("mathnormal"));
        font.setShape(UP_SHAPE);
        font.setColor(Color_latex);
        Dimension t = theFontMetrics(font).dimension('{');
index 8fcf7466e34c825cfbe07f7badab5ca09befa1ee..12fb6c190754cd969a81d5cf5a02ceacecbefcdd 100644 (file)
@@ -280,7 +280,9 @@ void MathData::metrics(MetricsInfo & mi, Dimension & dim) const
                if (completion.length() == 0)
                        continue;
                
-               dim.wid += mathed_string_width(mi.base.font, completion);
+               FontInfo font = mi.base.font;
+               augmentFont(font, from_ascii("mathnormal"));
+               dim.wid += mathed_string_width(font, completion);
        }
        // Cache the dimension.
        mi.base.bv->coordCache().arrays().add(this, dim);
@@ -328,6 +330,7 @@ void MathData::draw(PainterInfo & pi, int x, int y) const
                if (completion.length() == 0)
                        continue;
                FontInfo f = pi.base.font;
+               augmentFont(f, from_ascii("mathnormal"));
                
                // draw the unique and the non-unique completion part
                // Note: this is not time-critical as it is
index 1d7358abb086563096c30d33bf61e942a1898cae..82de873e24934300898050cf75d95a0f12f1130d 100644 (file)
@@ -488,9 +488,18 @@ void mathed_draw_deco(PainterInfo & pi, int x, int y, int w, int h,
 }
 
 
+void metricsStrRedBlack(MetricsInfo & mi, Dimension & dim, docstring const & str)
+{
+       FontInfo font = mi.base.font;
+       augmentFont(font, from_ascii("mathnormal"));
+       mathed_string_dim(font, str, dim);
+}
+
+
 void drawStrRed(PainterInfo & pi, int x, int y, docstring const & str)
 {
        FontInfo f = pi.base.font;
+       augmentFont(f, from_ascii("mathnormal"));
        f.setColor(Color_latex);
        pi.pain.text(x, y, str, f);
 }
@@ -499,6 +508,7 @@ void drawStrRed(PainterInfo & pi, int x, int y, docstring const & str)
 void drawStrBlack(PainterInfo & pi, int x, int y, docstring const & str)
 {
        FontInfo f = pi.base.font;
+       augmentFont(f, from_ascii("mathnormal"));
        f.setColor(Color_foreground);
        pi.pain.text(x, y, str, f);
 }
index 7810fd0f7ff54808ef7ecbd142300b256fe1feb4..28af6114f6fb492fcb93634f19bee0312f9276c9 100644 (file)
@@ -167,6 +167,9 @@ What's new
 
 - Fix undo warning when inserting plain text file (bug 7916).
 
+- Fix display of special characters like '\#', '{..}' and of auto-
+  completion in math insets with a special font, e.g. mathcal (bug 5167).
+
 
 * DOCUMENTATION AND LOCALIZATION