- fixed the bug where the HUD did not used the set font size from Preferences

This commit is contained in:
Marius Stanciu
2021-08-31 20:08:42 +03:00
committed by Marius Stanciu
parent d90e86da39
commit 23822ea774
2 changed files with 12 additions and 6 deletions

View File

@@ -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