[LyX/master] Improve display of ellipsis special char
Jean-Marc Lasgouttes
lasgouttes at lyx.org
Wed Mar 15 16:50:33 UTC 2023
commit a2378c11822e1478a20d36d2ad72558fcecdb923
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date: Wed Mar 15 10:48:31 2023 +0100
Improve display of ellipsis special char
Follow the TeXbook and use a half space as separation.
---
src/insets/InsetSpecialChar.cpp | 22 ++++++++++++++--------
1 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/src/insets/InsetSpecialChar.cpp b/src/insets/InsetSpecialChar.cpp
index bebf61a..fd36a21 100644
--- a/src/insets/InsetSpecialChar.cpp
+++ b/src/insets/InsetSpecialChar.cpp
@@ -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;
@@ -211,7 +210,9 @@ void InsetSpecialChar::metrics(MetricsInfo & mi, Dimension & dim) const
s = from_ascii(".");
break;
case LDOTS:
- s = from_ascii(". . .");
+ // see comment in draw().
+ dim.wid = 3 * fm.width(char_type('.'))
+ + 3 * fm.width(char_type(' ')) / 2;
break;
case MENU_SEPARATOR:
// ▹ U+25B9 WHITE RIGHT-POINTING SMALL TRIANGLE
@@ -285,15 +286,20 @@ 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);
+ int wid1 = fm.width(char_type('.')) + fm.width(char_type(' ')) / 2;
+ 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;
More information about the lyx-cvs
mailing list