mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-12 06:32:09 +00:00
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:
@@ -20,6 +20,7 @@
|
|||||||
#include "OverlayRenderer.h"
|
#include "OverlayRenderer.h"
|
||||||
|
|
||||||
#include <QFont>
|
#include <QFont>
|
||||||
|
#include <QFontDatabase>
|
||||||
#include <QFontMetrics>
|
#include <QFontMetrics>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
@@ -58,6 +59,13 @@ GLuint link(QOpenGLFunctions_4_5_Core* gl, GLuint vs, GLuint fs) {
|
|||||||
return p;
|
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) ----
|
// ---- Triangle program (flat color) ----
|
||||||
|
|
||||||
const char* TRI_VS = R"(
|
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();
|
const bool any_painter = !hud_text_.isEmpty() || !labels_.empty();
|
||||||
if (!any_painter) return;
|
if (!any_painter) return;
|
||||||
|
|
||||||
QFont label_font("monospace", 9);
|
QFont label_font = overlayTextFont(9);
|
||||||
label_font.setStyleHint(QFont::TypeWriter);
|
QFont hud_font = overlayTextFont(11);
|
||||||
QFont hud_font("monospace", 11);
|
|
||||||
hud_font.setStyleHint(QFont::TypeWriter);
|
|
||||||
const QFontMetrics lfm(label_font);
|
const QFontMetrics lfm(label_font);
|
||||||
const QFontMetrics hfm(hud_font);
|
const QFontMetrics hfm(hud_font);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user