Le 14/04/2015 15:09, Kornel Benko a écrit :
Don't know, how big they seem on your screen. Here the letter 'A' is about 3mm
high.
And here snapshot without the patch. On shorter words it is nearly invisible.
What about this proof-of-concept patch? I suspect you will find it
nearly invisible too, but we could double the size or add 1.
JMarc
>From 14f9676dfe8061cb477f3d08493869afbe0f5620 Mon Sep 17 00:00:00 2001
From: Jean-Marc Lasgouttes <lasgout...@lyx.org>
Date: Tue, 14 Apr 2015 15:22:11 +0200
Subject: [PATCH] Use QFontMetrics::lineWidth() for underline size
This is a proof of concept
---
src/RowPainter.cpp | 6 +++---
src/RowPainter.h | 2 +-
src/frontends/FontMetrics.h | 2 ++
src/frontends/qt4/GuiFontMetrics.cpp | 8 +++++++-
src/frontends/qt4/GuiFontMetrics.h | 1 +
5 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/src/RowPainter.cpp b/src/RowPainter.cpp
index 4c9118d..14d6617 100644
--- a/src/RowPainter.cpp
+++ b/src/RowPainter.cpp
@@ -290,7 +290,7 @@ void RowPainter::paintForeignMark(double orig_x, Language const * lang,
}
-void RowPainter::paintMisspelledMark(double orig_x, bool changed)
+void RowPainter::paintMisspelledMark(double orig_x, bool changed, Font const & font)
{
// if changed the misspelled marker gets placed slightly lower than normal
// to avoid drawing at the same vertical offset
@@ -298,7 +298,7 @@ void RowPainter::paintMisspelledMark(double orig_x, bool changed)
+ (changed ? solid_line_thickness_ + 1 : 0)
+ dotted_line_offset_;
pi_.pain.line(int(orig_x), int(y), int(x_), int(y), Color_error,
- Painter::line_onoffdash, dotted_line_thickness_);
+ Painter::line_onoffdash, theFontMetrics(font).lineWidth());
}
@@ -328,7 +328,7 @@ void RowPainter::paintFromPos(pos_type & vpos, bool changed)
new_word = par_.isSameSpellRange(pos, cpos) ;
}
if (!new_word)
- paintMisspelledMark(orig_x, changed);
+ paintMisspelledMark(orig_x, changed, font);
}
}
diff --git a/src/RowPainter.h b/src/RowPainter.h
index 0628f32..7af9ffb 100644
--- a/src/RowPainter.h
+++ b/src/RowPainter.h
@@ -76,7 +76,7 @@ public:
private:
void paintSeparator(double orig_x, double width, FontInfo const & font);
void paintForeignMark(double orig_x, Language const * lang, int desc = 0);
- void paintMisspelledMark(double orig_x, bool changed);
+ void paintMisspelledMark(double orig_x, bool changed, Font const & font);
void paintChars(pos_type & vpos, Font const & font);
int paintAppendixStart(int y);
void paintFromPos(pos_type & vpos, bool changed);
diff --git a/src/frontends/FontMetrics.h b/src/frontends/FontMetrics.h
index 53f57a2..b5cbbe3 100644
--- a/src/frontends/FontMetrics.h
+++ b/src/frontends/FontMetrics.h
@@ -65,6 +65,8 @@ public:
virtual Dimension const defaultDimension() const = 0;
/// return the em size
virtual int em() const = 0;
+ /// return the width of a line for underlining
+ virtual int lineWidth() const = 0;
/// return the width of the char in the font
virtual int width(char_type c) const = 0;
diff --git a/src/frontends/qt4/GuiFontMetrics.cpp b/src/frontends/qt4/GuiFontMetrics.cpp
index b488b68..9648eec 100644
--- a/src/frontends/qt4/GuiFontMetrics.cpp
+++ b/src/frontends/qt4/GuiFontMetrics.cpp
@@ -78,10 +78,16 @@ int GuiFontMetrics::em() const
}
+int GuiFontMetrics::lineWidth() const
+{
+ return metrics_.lineWidth();
+}
+
+
int GuiFontMetrics::lbearing(char_type c) const
{
if (!is_utf16(c))
- // FIXME: QFontMetrics::leftBearingdoes not support the
+ // FIXME: QFontMetrics::leftBearing does not support the
// full unicode range. Once it does, we could use:
//return metrics_.leftBearing(toqstr(docstring(1, c)));
return 0;
diff --git a/src/frontends/qt4/GuiFontMetrics.h b/src/frontends/qt4/GuiFontMetrics.h
index 7555929..06b721c 100644
--- a/src/frontends/qt4/GuiFontMetrics.h
+++ b/src/frontends/qt4/GuiFontMetrics.h
@@ -36,6 +36,7 @@ public:
virtual int maxDescent() const;
virtual Dimension const defaultDimension() const;
virtual int em() const;
+ virtual int lineWidth() const;
virtual int width(char_type c) const;
virtual int ascent(char_type c) const;
virtual int descent(char_type c) const;
--
1.7.9.5