diff --git a/ui/painter.h b/ui/painter.h index c393100..59af3de 100644 --- a/ui/painter.h +++ b/ui/painter.h @@ -18,13 +18,15 @@ public: void drawTextLeft(int x, int y, int outerw, const QString &text, int textWidth = -1) { QFontMetrics m(fontMetrics()); + auto ascent = (_ascent == 0 ? m.ascent() : _ascent); if (style::RightToLeft() && textWidth < 0) textWidth = m.width(text); - drawText(style::RightToLeft() ? (outerw - x - textWidth) : x, y + m.ascent(), text); + drawText(style::RightToLeft() ? (outerw - x - textWidth) : x, y + ascent, text); } void drawTextRight(int x, int y, int outerw, const QString &text, int textWidth = -1) { QFontMetrics m(fontMetrics()); + auto ascent = (_ascent == 0 ? m.ascent() : _ascent); if (!style::RightToLeft() && textWidth < 0) textWidth = m.width(text); - drawText(style::RightToLeft() ? x : (outerw - x - textWidth), y + m.ascent(), text); + drawText(style::RightToLeft() ? x : (outerw - x - textWidth), y + ascent, text); } void drawPixmapLeft(int x, int y, int outerw, const QPixmap &pix, const QRect &from) { drawPixmap(QPoint(style::RightToLeft() ? (outerw - x - (from.width() / pix.devicePixelRatio())) : x, y), pix, from); @@ -72,9 +74,14 @@ public: const style::TextPalette &textPalette() const { return _textPalette ? *_textPalette : st::defaultTextPalette; } + void setFont(const style::font &font) { + _ascent = font->ascent; + QPainter::setFont(font); + } private: const style::TextPalette *_textPalette = nullptr; + int _ascent = 0; };