Corrected font bug in annotation items

This commit is contained in:
Nav
2022-09-19 14:40:48 +01:00
parent 95477c489d
commit 6e0038b41c
4 changed files with 21 additions and 12 deletions

View File

@@ -50,10 +50,7 @@ namespace Bloom::Widgets
auto lineColor = this->getLineColor(); auto lineColor = this->getLineColor();
auto labelFontColor = this->getLabelFontColor(); auto labelFontColor = this->getLabelFontColor();
auto font = painter->font(); painter->setFont(this->getLabelFont());
font.setPixelSize(this->getLabelFontSize());
font.setItalic(false);
painter->setFont(font);
const auto isEnabled = this->isEnabled(); const auto isEnabled = this->isEnabled();

View File

@@ -1,6 +1,7 @@
#pragma once #pragma once
#include <QGraphicsItem> #include <QGraphicsItem>
#include <QFont>
#include <cstdint> #include <cstdint>
#include "src/Targets/TargetMemory.hpp" #include "src/Targets/TargetMemory.hpp"
@@ -60,8 +61,15 @@ namespace Bloom::Widgets
return QColor(0x68, 0x68, 0x68); return QColor(0x68, 0x68, 0x68);
} }
[[nodiscard]] virtual int getLabelFontSize() const { [[nodiscard]] virtual const QFont& getLabelFont() const {
return 12; static auto labelFont = std::optional<QFont>();
if (!labelFont.has_value()) {
labelFont = QFont("'Ubuntu', sans-serif");
labelFont->setPixelSize(12);
}
return labelFont.value();
} }
}; };
} }

View File

@@ -26,10 +26,6 @@ namespace Bloom::Widgets
} }
void ValueAnnotationItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { void ValueAnnotationItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) {
auto font = painter->font();
font.setItalic(true);
painter->setFont(font);
AnnotationItem::paint(painter, option, widget); AnnotationItem::paint(painter, option, widget);
if (this->size > 1) { if (this->size > 1) {

View File

@@ -24,8 +24,16 @@ namespace Bloom::Widgets
return QColor(0x94, 0x6F, 0x30); return QColor(0x94, 0x6F, 0x30);
} }
[[nodiscard]] int getLabelFontSize() const override { [[nodiscard]] const QFont& getLabelFont() const override {
return 11; static auto labelFont = std::optional<QFont>();
if (!labelFont.has_value()) {
labelFont = QFont("'Ubuntu', sans-serif");
labelFont->setPixelSize(11);
labelFont->setItalic(true);
}
return labelFont.value();
} }
private: private: