Johnathan Burchill wrote: > Juergen Spitzmueller wrote: > > Sun, 20 Mar 2005 08:26:53 -0800 > > The striking-out line for erased text is misplaced in the first row of > > the main text, since this also includes the top margin, which is not > > honoured by the strikeout calculation. The attached patch fixes it. > > This works for the first row, which looks good. But the next row has its > strikeout line slightly higher than the first.
One drawback of the hack is that it looks different on every system (dependig on the settings). On my system, the lines are adjusted correctly. Anyway, I decided to get rid of the hack and use the default font height instead (not the actual current font, since then the lines are "jumping" if the cursor moves into areas with different font sizes). Personally, I'd rather draw the line not exactly in the middle of the max. Ascent (char 'M'), but rather in the middle of the char's x-height, since this looks better especially with lowercase text. That would be yo_ - font_metrics::ascent('x', text_.defaultfont_) / 2; instead of yo_ - font_metrics::maxAscent(text_.defaultfont_) / 2; but this is a pure matter of taste, of course (and it looks not so good with bigger font sizes, e.g. headings). Please test, this should fix all drawing issues. Jürgen
Index: rowpainter.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/rowpainter.C,v retrieving revision 1.142 diff -u -r1.142 rowpainter.C --- rowpainter.C 15 Feb 2005 19:34:44 -0000 1.142 +++ rowpainter.C 21 Mar 2005 10:08:29 -0000 @@ -664,10 +664,9 @@ // if we reach the end of a struck out range, paint it // we also don't paint across things like tables if (running_strikeout && (highly_editable_inset || !is_struckout)) { - // FIXME this should take real text height into account, not - // the whole row including padding whitespace - //int const middle = yo_ + (- row_.ascent() + row_.top_of_text()) / 2; - int const middle = yo_ - row_.ascent() / 2; + // calculate 1/2 height of the buffer's default font + int const middle = + yo_ - font_metrics::maxAscent(text_.defaultfont_) / 2; pain_.line(last_strikeout_x, middle, int(x_), middle, LColor::strikeout, Painter::line_solid, Painter::line_thin); running_strikeout = false; @@ -718,9 +717,9 @@ // if we reach the end of a struck out range, paint it if (running_strikeout) { - //top_of_text = font_metrics::maxAscent(font); - //int const middle = yo_ - top_of_text() / 2; - int const middle = yo_ - row_.ascent() / 2; + // calculate 1/2 height of the buffer's default font + int const middle = + yo_ - font_metrics::maxAscent(text_.defaultfont_) / 2; pain_.line(last_strikeout_x, middle, int(x_), middle, LColor::strikeout, Painter::line_solid, Painter::line_thin); running_strikeout = false;