/// leave monochrome painting mode
void leaveMonochromeMode() override {}
/// draws a wavy line that can be used for underlining.
- void wavyHorizontalLine(int, int, int, ColorCode) override {}
+ void wavyHorizontalLine(FontInfo const &, int, int, int, ColorCode) override {}
};
} // namespace frontend
/// leave monochrome painting mode
virtual void leaveMonochromeMode() = 0;
/// draws a wavy line that can be used for underlining.
- virtual void wavyHorizontalLine(int x, int y, int width, ColorCode col) = 0;
+ virtual void wavyHorizontalLine(FontInfo const & f, int x, int y, int width, ColorCode col) = 0;
private:
/// Ratio between physical pixels and device-independent pixels
double pixel_ratio_;
doubleUnderline(f, x, y, width);
if (f.uwave() == FONT_ON)
// f.color() doesn't work on some circumstances
- wavyHorizontalLine(x, y, width, f.realColor().baseColor);
+ wavyHorizontalLine(f, x, y, width, f.realColor().baseColor);
}
}
-void GuiPainter::wavyHorizontalLine(int x, int y, int width, ColorCode col)
+void GuiPainter::wavyHorizontalLine(FontInfo const & f, int x, int y, int width, ColorCode col)
{
- setQPainterPen(computeColor(col));
- int const step = 2;
+ FontMetrics const & fm = theFontMetrics(f);
+ int const pos = fm.underlinePos();
+
+ setQPainterPen(computeColor(col), line_solid, fm.lineWidth());
+ int const step = 2 * fm.lineWidth();
int const xend = x + width;
- int height = 1;
+ int height = 1 * fm.lineWidth();
//FIXME: I am not sure if Antialiasing gives the best effect.
//setRenderHint(Antialiasing, true);
+ QVector<QPoint> points;
while (x < xend) {
height = - height;
- drawLine(x, y - height, x + step, y + height);
+ points.append(QPoint(x, y + pos - height));
+ points.append(QPoint(x + step, y + pos + height));
x += step;
- drawLine(x, y + height, x + step/2, y + height);
+ points.append(QPoint(x, (qreal)y + pos + height));
+ points.append(QPoint(x + step/2, y + pos + height));
x += step/2;
}
+ drawPolyline(points);
//setRenderHint(Antialiasing, false);
}
int preeditText(int x, int y,
char_type c, FontInfo const & f, preedit_style style) override;
- void wavyHorizontalLine(int x, int y, int width, ColorCode col) override;
+ void wavyHorizontalLine(FontInfo const & f, int x, int y, int width, ColorCode col) override;
private:
/// check the font, and if set, draw an underline