From 23822ea77486913faade902461fa77934103b7ad Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Tue, 31 Aug 2021 20:08:42 +0300 Subject: [PATCH] - fixed the bug where the HUD did not used the set font size from Preferences --- CHANGELOG.md | 1 + appGUI/PlotCanvas.py | 17 +++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2496af5e..6c30bb18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ CHANGELOG for FlatCAM beta 31.08.2021 - made sure that the location labels in the InfoBar have only the decimals required when the Grid snapping is ON +- fixed the bug where the HUD did not used the set font size from Preferences 30.08.2021 diff --git a/appGUI/PlotCanvas.py b/appGUI/PlotCanvas.py index 0339211c..dadff1ac 100644 --- a/appGUI/PlotCanvas.py +++ b/appGUI/PlotCanvas.py @@ -334,11 +334,16 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas): fsize = 8 c_font = QtGui.QFont() + c_font.setPointSize(fsize) c_font_metrics = QtGui.QFontMetrics(c_font) - l1_length = c_font_metrics.horizontalAdvance(l1_hud_text, len(l1_hud_text)) - l2_length = c_font_metrics.horizontalAdvance(l2_hud_text, len(l2_hud_text)) - l3_length = c_font_metrics.horizontalAdvance(l3_hud_text, len(l3_hud_text)) - l4_length = c_font_metrics.horizontalAdvance(l4_hud_text, len(l4_hud_text)) + # l1_length = c_font_metrics.horizontalAdvance(l1_hud_text) + # l2_length = c_font_metrics.horizontalAdvance(l2_hud_text) + # l3_length = c_font_metrics.horizontalAdvance(l3_hud_text) + # l4_length = c_font_metrics.horizontalAdvance(l4_hud_text) + l1_length = c_font_metrics.boundingRect(l1_hud_text).width() + l2_length = c_font_metrics.boundingRect(l2_hud_text).width() + l3_length = c_font_metrics.boundingRect(l3_hud_text).width() + l4_length = c_font_metrics.boundingRect(l4_hud_text).width() l1_height = c_font_metrics.boundingRect(l1_hud_text).height() l2_height = c_font_metrics.boundingRect(l2_hud_text).height() @@ -347,9 +352,9 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas): # coordinates and anchors # height = fsize * 11 # 90. Constant 11 is something that works - height = l1_height + l2_height + l3_height + l4_height + (2 * c_font_metrics.lineSpacing()) + height = l1_height + l2_height + l3_height + l4_height + (0. * c_font_metrics.lineSpacing()) + 10 # width = height * 2 # width is double the height = it is something that works - width = max(l1_length, l2_length, l3_length, l4_length) + width = max(l1_length, l2_length, l3_length, l4_length) * 1.27 # don't know where the 1.27 comes center_x = (width / 2) + 5 center_y = (height / 2) + 5