Use fixed overlay text font

Use Qt's system fixed font for viewer overlay text instead of the generic monospace family, avoiding the Windows font-resolution delay seen during measurement overlays.

Generated with the assistance of an AI coding tool.
This commit is contained in:
Dion Moult
2026-05-26 13:23:23 +10:00
parent 371aabfef6
commit dd902bf0f8
+10 -4
View File
@@ -20,6 +20,7 @@
#include "OverlayRenderer.h"
#include <QFont>
#include <QFontDatabase>
#include <QFontMetrics>
#include <QPainter>
#include <QtGlobal>
@@ -58,6 +59,13 @@ GLuint link(QOpenGLFunctions_4_5_Core* gl, GLuint vs, GLuint fs) {
return p;
}
QFont overlayTextFont(int point_size) {
QFont font = QFontDatabase::systemFont(QFontDatabase::FixedFont);
font.setPointSize(point_size);
font.setStyleHint(QFont::TypeWriter);
return font;
}
// ---- Triangle program (flat color) ----
const char* TRI_VS = R"(
@@ -620,10 +628,8 @@ void OverlayRenderer::render(const float view_proj[16],
const bool any_painter = !hud_text_.isEmpty() || !labels_.empty();
if (!any_painter) return;
QFont label_font("monospace", 9);
label_font.setStyleHint(QFont::TypeWriter);
QFont hud_font("monospace", 11);
hud_font.setStyleHint(QFont::TypeWriter);
QFont label_font = overlayTextFont(9);
QFont hud_font = overlayTextFont(11);
const QFontMetrics lfm(label_font);
const QFontMetrics hfm(hud_font);