From 63772964923f765e4ab975946215725086a9c838 Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Thu, 3 May 2012 15:51:55 +0200 Subject: [PATCH] Fix bug #5167: Correctly paint special characters in InsetMathFont 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. --- src/mathed/InsetMathBrace.cpp | 5 ++++- src/mathed/MathData.cpp | 5 ++++- src/mathed/MathSupport.cpp | 6 +++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/mathed/InsetMathBrace.cpp b/src/mathed/InsetMathBrace.cpp index 14279c1d51..105165903d 100644 --- a/src/mathed/InsetMathBrace.cpp +++ b/src/mathed/InsetMathBrace.cpp @@ -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('{'); diff --git a/src/mathed/MathData.cpp b/src/mathed/MathData.cpp index 8fcf7466e3..12fb6c1907 100644 --- a/src/mathed/MathData.cpp +++ b/src/mathed/MathData.cpp @@ -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 diff --git a/src/mathed/MathSupport.cpp b/src/mathed/MathSupport.cpp index 77b982b84b..82de873e24 100644 --- a/src/mathed/MathSupport.cpp +++ b/src/mathed/MathSupport.cpp @@ -490,13 +490,16 @@ void mathed_draw_deco(PainterInfo & pi, int x, int y, int w, int h, void metricsStrRedBlack(MetricsInfo & mi, Dimension & dim, docstring const & str) { - mathed_string_dim(mi.base.font, str, dim); + 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); } @@ -505,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); } -- 2.39.2