]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetSpecialChar.cpp
Fix bug #12795
[lyx.git] / src / insets / InsetSpecialChar.cpp
index bebf61a0208154c6842cbb182c025e25681eb203..5983c07d649906ad69c225ae005c2b8c2fa801a5 100644 (file)
@@ -191,8 +191,7 @@ void drawLogo(PainterInfo & pi, int & x, int const y, InsetSpecialChar::Kind kin
 
 void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       frontend::FontMetrics const & fm =
-               theFontMetrics(mi.base.font);
+       frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
        dim.asc = fm.maxAscent();
        dim.des = 0;
        dim.wid = 0;
@@ -210,9 +209,14 @@ void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
                case END_OF_SENTENCE:
                        s = from_ascii(".");
                        break;
-               case LDOTS:
-                       s = from_ascii(". . .");
+               case LDOTS: {
+                       // see comment in draw().
+                       auto const fam = mi.base.font.family();
+                       // Multiplication by 3 is done here to limit rounding effects.
+                       int const spc3 = fam == TYPEWRITER_FAMILY ? 0 : 3 * fm.width(char_type(' ')) / 2;
+                       dim.wid = 3 * fm.width(char_type('.')) + spc3;
                        break;
+               }
                case MENU_SEPARATOR:
                        // ▹  U+25B9 WHITE RIGHT-POINTING SMALL TRIANGLE
                        // There is a \thinspace on each side of the triangle
@@ -285,15 +289,22 @@ void InsetSpecialChar::draw(PainterInfo & pi, int x, int y) const
        case LDOTS:
        {
                font.setColor(Color_special);
-               string ell = ". . . ";
-               docstring dell(ell.begin(), ell.end());
-               pi.pain.text(x, y, dell, font);
+               /* \textellipsis uses a \fontdimen3 is spacing. The TeXbook
+                * tells us that \fontdimen3 is the interword stretch, and
+                * that this is usually half a space.
+                */
+               frontend::FontMetrics const & fm = theFontMetrics(font);
+               auto const fam = pi.base.font.family();
+               int const spc = fam == TYPEWRITER_FAMILY ? 0 : fm.width(char_type(' ')) / 2;
+               int wid1 = fm.width(char_type('.')) + spc;
+               pi.pain.text(x, y, char_type('.'), font);
+               pi.pain.text(x + wid1, y, char_type('.'), font);
+               pi.pain.text(x + 2 * wid1, y, char_type('.'), font);
                break;
        }
        case MENU_SEPARATOR:
        {
-               frontend::FontMetrics const & fm =
-                       theFontMetrics(font);
+               frontend::FontMetrics const & fm = theFontMetrics(font);
 
                // There is a \thinspace on each side of the triangle
                x += fm.em() / 6;