Commit 167bdc64 authored by Martin Tobias Holmedahl Sandsmark's avatar Martin Tobias Holmedahl Sandsmark Committed by Tomaz Canabrava
Browse files

Center text with increased line height

parent 1bc9be4d
Pipeline #179895 passed with stage
in 2 minutes and 31 seconds
......@@ -565,7 +565,7 @@ void TerminalPainter::drawCursor(QPainter &painter, const QRect &rect, const QCo
characterColor = cursorTextColor.isValid() ? cursorTextColor : backgroundColor;
} else {
// draw the cursor outline, adjusting the area so that
// it is draw entirely inside cursorRect
// it is drawn entirely inside cursorRect
painter.drawRect(cursorRect.adjusted(halfWidth, halfWidth, -halfWidth, -halfWidth));
}
} else if (display->cursorShape() == Enum::UnderlineCursor) {
......@@ -660,10 +660,13 @@ void TerminalPainter::drawCharacters(QPainter &painter,
painter.setLayoutDirection(Qt::LeftToRight);
int y = rect.y() + display->terminalFont()->fontAscent();
int shifted = 0;
if (lineProperty & LINE_DOUBLEHEIGHT_BOTTOM) {
y -= display->terminalFont()->fontHeight() / 2;
} else {
y += display->terminalFont()->lineSpacing();
// We shift half way down here to center
shifted = display->terminalFont()->lineSpacing() / 2;
y += shifted;
}
if (display->bidiEnabled()) {
......@@ -671,6 +674,11 @@ void TerminalPainter::drawCharacters(QPainter &painter,
} else {
painter.drawText(rect.x(), y, LTR_OVERRIDE_CHAR + text);
}
if (shifted > 0) {
// To avoid rounding errors we shift the rest this way
y += display->terminalFont()->lineSpacing() - shifted;
}
}
painter.setClipRegion(origClipRegion);
painter.setClipping(origClipping);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment