diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp --- a/src/TerminalDisplay.cpp +++ b/src/TerminalDisplay.cpp @@ -614,7 +614,7 @@ { //Calculate cell midpoints, end points. const int cx = x + w / 2; - const int cy = y + h / 2; + const int cy = y + h / 2. - 0.5; const int ex = x + w - 1; const int ey = y + h - 1; @@ -666,41 +666,41 @@ //Intersection points. if ((toDraw & Int11) != 0u) { - paint.drawPoint(cx - 1, cy - 1); + paint.drawPoint(cx - 2, cy - 2); } if ((toDraw & Int12) != 0u) { - paint.drawPoint(cx, cy - 1); + paint.drawPoint(cx - 1, cy - 2); } if ((toDraw & Int13) != 0u) { - paint.drawPoint(cx + 1, cy - 1); + paint.drawPoint(cx - 0, cy - 2); } if ((toDraw & Int21) != 0u) { - paint.drawPoint(cx - 1, cy); + paint.drawPoint(cx - 2, cy - 1); } if ((toDraw & Int22) != 0u) { - paint.drawPoint(cx, cy); + paint.drawPoint(cx - 1, cy - 1); } if ((toDraw & Int23) != 0u) { - paint.drawPoint(cx + 1, cy); + paint.drawPoint(cx - 0, cy - 1); } if ((toDraw & Int31) != 0u) { - paint.drawPoint(cx - 1, cy + 1); + paint.drawPoint(cx - 2, cy); } if ((toDraw & Int32) != 0u) { - paint.drawPoint(cx, cy + 1); + paint.drawPoint(cx - 1, cy); } if ((toDraw & Int33) != 0u) { - paint.drawPoint(cx + 1, cy + 1); + paint.drawPoint(cx - 0, cy); } } static void drawOtherChar(QPainter& paint, int x, int y, int w, int h, uchar code) { //Calculate cell midpoints, end points. const int cx = x + w / 2; - const int cy = y + h / 2; + const int cy = y + h / 2. - 0.5; // Compensate for the translation, to match fonts const int ex = x + w - 1; const int ey = y + h - 1; @@ -787,16 +787,17 @@ const Character* attributes) { painter.save(); - painter.setRenderHint(QPainter::Antialiasing); - const QPen& originalPen = painter.pen(); + // For antialiasing, we need to shift it so the single pixel width is in the middle + painter.translate(0.5, 0.5); if (((attributes->rendition & RE_BOLD) != 0) && _boldIntense) { - QPen boldPen(originalPen); - boldPen.setWidth(3); + QPen boldPen(painter.pen()); + boldPen.setWidth(4); painter.setPen(boldPen); } + for (int i = 0 ; i < str.length(); i++) { const uchar code = str[i].cell(); if (LineChars[code] != 0u) { @@ -904,10 +905,10 @@ QColor color(backgroundColor); color.setAlpha(qAlpha(_blendColor)); - painter.save(); + const QPainter::CompositionMode originalMode = painter.compositionMode(); painter.setCompositionMode(QPainter::CompositionMode_Source); painter.fillRect(rect, color); - painter.restore(); + painter.setCompositionMode(originalMode); #endif } else { painter.fillRect(rect, backgroundColor); @@ -1036,8 +1037,6 @@ const QString& text, const Character* style) { - painter.save(); - // setup painter const QColor foregroundColor = style->foregroundColor.color(_colorTable); const QColor backgroundColor = style->backgroundColor.color(_colorTable); @@ -1057,27 +1056,21 @@ // draw text drawCharacters(painter, rect, text, style, invertCharacterColor); - - painter.restore(); } void TerminalDisplay::drawPrinterFriendlyTextFragment(QPainter& painter, const QRect& rect, const QString& text, const Character* style) { - painter.save(); - // Set the colors used to draw to black foreground and white // background for printer friendly output when printing Character print_style = *style; print_style.foregroundColor = CharacterColor(COLOR_SPACE_RGB, 0x00000000); print_style.backgroundColor = CharacterColor(COLOR_SPACE_RGB, 0xFFFFFFFF); // draw text drawCharacters(painter, rect, text, &print_style, false); - - painter.restore(); } void TerminalDisplay::setRandomSeed(uint randomSeed) @@ -1494,6 +1487,8 @@ drawBackground(paint, rect, getBackgroundColor(), true /* use opacity setting */); } + paint.setRenderHint(QPainter::Antialiasing, _antialiasText); + foreach(const QRect & rect, dirtyImageRegion.rects()) { drawContents(paint, rect); }