Move monospace font id string to separate header
MODIFY
src/cachesim/cachegraphic.h
src/cachesim/cachegraphic.h
#include <QObject>
#include <memory>
#include "cachesim.h"
+#include "fonts.h"
namespace Ripes {
class FancyPolyLine;
@@ -82,7 +83,7 @@ private:
void updateAddressing(bool valid, const CacheSim::CacheTransaction* transaction = nullptr);
void drawIndexingItems();
- QFont m_font = QFont("Inconsolata", 12);
+ QFont m_font = QFont(Fonts::monospace, 12);
CacheSim& m_cache;
std::vector<std::unique_ptr<QGraphicsRectItem>> m_highlightingItems;

MODIFY
src/console.cpp
src/console.cpp
#include "console.h"
+#include "fonts.h"
#include "ripessettings.h"
#include <QScrollBar>
@@ -8,7 +9,7 @@ namespace Ripes {
Console::Console(QWidget* parent) : QPlainTextEdit(parent) {
if (RipesSettings::value(RIPES_SETTING_CONSOLEFONT).isNull()) {
- m_font = QFont("Inconsolata", 12);
+ m_font = QFont(Fonts::monospace, 12);
} else {
m_font = RipesSettings::value(RIPES_SETTING_CONSOLEFONT).value<QFont>();
}

MODIFY
src/editor/codeeditor.cpp
src/editor/codeeditor.cpp
#include "colors.h"
#include "csyntaxhighlighter.h"
+#include "fonts.h"
#include "processorhandler.h"
#include "ripessettings.h"
#include "rvsyntaxhighlighter.h"
@@ -32,7 +33,7 @@ CodeEditor::CodeEditor(QWidget* parent) : QPlainTextEdit(parent) {
// Set font for the entire widget. calls to fontMetrics() will get the
// dimensions of the currently set font
- m_font = QFont("Inconsolata", 11);
+ m_font = QFont(Fonts::monospace, 11);
setFont(m_font);
m_fontTimer.setSingleShot(true);
setTabStopDistance(QFontMetricsF(m_font).width(' ') * 4);

ADD
src/fonts.h
+#pragma once
+
+namespace Ripes {
+namespace Fonts {
+
+constexpr auto monospace = "Inconsolata";
+
+} // namespace Fonts
+} // namespace Ripes

MODIFY
src/io/memorymapmodel.cpp
src/io/memorymapmodel.cpp
#include <QHeaderView>
+#include "fonts.h"
#include "iobase.h"
#include "iomanager.h"
#include "processorhandler.h"
@@ -64,7 +65,7 @@ QVariant MemoryMapModel::data(const QModelIndex& index, int role) const {
return encodeRadixValue(memoryMapEntry->first, Radix::Hex) + " - " +
encodeRadixValue(memoryMapEntry->first + memoryMapEntry->second.size, Radix::Hex);
case Qt::FontRole:
- return QFont("Inconsolata", 11);
+ return QFont(Fonts::monospace, 11);
case Qt::TextAlignmentRole:
return Qt::AlignCenter;
}

MODIFY
src/io/registermapmodel.cpp
src/io/registermapmodel.cpp
#include <QHeaderView>
+#include "fonts.h"
#include "iobase.h"
#include "processorhandler.h"
@@ -70,7 +71,7 @@ QVariant RegisterMapModel::data(const QModelIndex& index, int role) const {
case Qt::DisplayRole:
return "0x" + QString::number(m_peripheral->registers().at(idx).address, 16);
case Qt::FontRole:
- return QFont("Inconsolata", 11);
+ return QFont(Fonts::monospace, 11);
case Qt::TextAlignmentRole:
return Qt::AlignCenter;
}

MODIFY
src/ioperipheraltab.cpp
src/ioperipheraltab.cpp
#include "ui_ioperipheraltab.h"
#include "editor/csyntaxhighlighter.h"
+#include "fonts.h"
#include "io/iobase.h"
#include "io/iomanager.h"
#include "io/periphparammodel.h"
@@ -13,7 +14,7 @@ namespace Ripes {
IOPeripheralTab::IOPeripheralTab(QWidget* parent, IOBase* peripheral)
: QWidget(parent), m_ui(new Ui::IOPeripheralTab), m_peripheral(peripheral) {
m_ui->setupUi(this);
- m_ui->exports->setFont(QFont("Inconsolata", 11));
+ m_ui->exports->setFont(QFont(Fonts::monospace, 11));
m_ui->description->setText(m_peripheral->description());
m_ui->registerMapView->setModel(new RegisterMapModel(peripheral, this));

MODIFY
src/iotab.cpp
src/iotab.cpp
#include <QScreen>
#include <QToolBar>
+#include "fonts.h"
#include "io/memorymapmodel.h"
+#include "ioperipheraltab.h"
#include "processorhandler.h"
#include "ripessettings.h"
-#include "ioperipheraltab.h"
-
#include "cereal/archives/json.hpp"
#include "cereal/types/map.hpp"
#include "cereal/types/vector.hpp"
@@ -77,7 +77,7 @@ IOTab::IOTab(QToolBar* toolbar, QWidget* parent) : RipesTab(toolbar, parent), m_
// Reload peripheral state from the last graceful exit of the program
loadPeripheralState();
- m_ui->ioSymbols->setFont(QFont("Inconsolata", 11));
+ m_ui->ioSymbols->setFont(QFont(Fonts::monospace, 11));
m_ui->ioSymbols->setToolTip(
"Exported symbols for all I/O devices.\nThese symbols may be referenced in Assembly\nor C-language programs.");

MODIFY
src/memorymodel.cpp
src/memorymodel.cpp
#include <QBrush>
#include <QFont>
+#include "fonts.h"
+
namespace Ripes {
MemoryModel::MemoryModel(QObject* parent) : QAbstractTableModel(parent) {}
@@ -66,7 +68,7 @@ QVariant MemoryModel::data(const QModelIndex& index, int role) const {
return Qt::AlignCenter;
if (role == Qt::FontRole) {
- return QFont("Inconsolata", 11);
+ return QFont(Fonts::monospace, 11);
}
const auto bytes = ProcessorHandler::currentISA()->bytes();

MODIFY
src/programviewer.cpp
src/programviewer.cpp
#include <QTextBlock>
#include "colors.h"
+#include "fonts.h"
#include "ripessettings.h"
namespace Ripes {
@@ -21,7 +22,7 @@ ProgramViewer::ProgramViewer(QWidget* parent) : QPlainTextEdit(parent) {
// Set font for the entire widget. calls to fontMetrics() will get the
// dimensions of the currently set font
- m_font = QFont("Inconsolata", 11);
+ m_font = QFont(Fonts::monospace, 11);
setFont(m_font);
m_fontTimer.setSingleShot(true);

MODIFY
src/registermodel.cpp
src/registermodel.cpp
#include <QHeaderView>
+#include "fonts.h"
#include "processorhandler.h"
namespace Ripes {
@@ -105,7 +106,7 @@ QVariant RegisterModel::data(const QModelIndex& index, int role) const {
case Qt::UserRole:
return QVariant::fromValue(m_radix);
case Qt::FontRole:
- return QFont("Inconsolata", 11);
+ return QFont(Fonts::monospace, 11);
case Qt::ForegroundRole:
return QBrush(Qt::blue);
default:

Move monospace font id string to separate header