commit 94114fd1218df7d2d99888bd18bc5fee394ff515 Author: Jean-Marc Lasgouttes <lasgout...@lyx.org> Date: Mon Apr 10 10:27:08 2017 +0200
Better implementation for corssOutLines When trying to do implement a LaTeX feature on screen, it is always good to see how LaTeX does it, just in case it is easy to implement on our side. Then we have a correct output at all DPI sizes. --- src/frontends/qt4/GuiPainter.cpp | 23 +++++++++++------------ 1 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/frontends/qt4/GuiPainter.cpp b/src/frontends/qt4/GuiPainter.cpp index cfde181..93bf16c 100644 --- a/src/frontends/qt4/GuiPainter.cpp +++ b/src/frontends/qt4/GuiPainter.cpp @@ -26,8 +26,9 @@ #include "insets/Inset.h" -#include "support/lassert.h" #include "support/debug.h" +#include "support/lassert.h" +#include "support/lyxlib.h" #include <algorithm> @@ -669,17 +670,15 @@ void GuiPainter::strikeoutLine(FontInfo const & f, int x, int y, int width) void GuiPainter::crossoutLines(FontInfo const & f, int x, int y, int width) { - FontMetrics const & fm = theFontMetrics(f); - int const bottom = fm.underlinePos(); - int const middle = fm.strikeoutPos(); - - // we draw several lines to fill the whole selection with strokes - // use 5 as diagonal width since this is close to the PDf output - // with normal font zoom levels - for(int x_current = x; x_current < x + width - 5; x_current = x_current + 5) { - line(x_current, y + bottom, x_current + 5, y - 2 * middle - 2 * bottom, - f.realColor(), line_solid, fm.lineWidth()); - } + FontInfo tmpf = f; + tmpf.setXout(FONT_OFF); + + // the definition of \xout in ulem.sty is + // \def\xout{\bgroup \markoverwith{\hbox to.35em{\hss/\hss}}\ULon} + // Let's mimick it somewhat. + double offset = max(0.35 * theFontMetrics(tmpf).em(), 1); + for (int i = 0 ; i < iround(width / offset) ; ++i) + text(x + iround(i * offset), y, '/', tmpf); }