+ GC gc = lyxColorHandler->getGCForeground(f.realColor());
+ if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) {
+ lyxfont::XSetFont(display, gc, f);
+ XDrawString16(display, owner.getPixmap(), gc, x, y, s, ls);
+ } else {
+ LyXFont smallfont(f);
+ smallfont.decSize().decSize().setShape(LyXFont::UP_SHAPE);
+ static XChar2b c;
+ int tmpx = x;
+ for (int i = 0; i < ls; ++i) {
+ if (s[i].byte1 == 0 && islower(s[i].byte2)) {
+ c.byte2 = toupper(s[i].byte2);
+ lyxfont::XSetFont(display, gc, smallfont);
+ XDrawString16(display, owner.getPixmap(),
+ gc, tmpx, y, &c, 1);
+ tmpx += lyxfont::XTextWidth16(smallfont, &c, 1);
+ } else {
+ lyxfont::XSetFont(display, gc, f);
+ XDrawString16(display, owner.getPixmap(),
+ gc, tmpx, y, &s[i], 1);
+ tmpx += lyxfont::XTextWidth16(f, const_cast<XChar2b *>(&s[i]), 1);
+ }
+ }
+ }
+
+ if (f.underbar() == LyXFont::ON) {
+ underline(f, x, y, lyxfont::width(s, ls, f));
+ }
+
+ return *this;
+}
+
+
+void Painter::underline(LyXFont const & f, int x, int y, int width)
+{
+ int below = max(lyxfont::maxDescent(f) / 2, 2);
+ int height = max((lyxfont::maxDescent(f) / 4) - 1, 1);
+ if (height < 2)
+ line(x, y + below, x + width, y + below, f.color());
+ else
+ fillRectangle(x, y + below, width, below + height,
+ f.color());