From: Jean-Marc Lasgouttes Date: Mon, 10 Apr 2017 08:27:08 +0000 (+0200) Subject: Better implementation for corssOutLines X-Git-Tag: 2.3.0alpha1~91 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=94114fd1218df7d2d99888bd18bc5fee394ff515;p=features.git 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. --- diff --git a/src/frontends/qt4/GuiPainter.cpp b/src/frontends/qt4/GuiPainter.cpp index cfde181604..93bf16c414 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 @@ -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); }