##// END OF EJS Templates
Font width calculation fix for certain Mac OS systems.
epatters -
Show More
@@ -214,10 +214,12 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
214 style = self.style()
214 style = self.style()
215 splitwidth = style.pixelMetric(QtGui.QStyle.PM_SplitterWidth)
215 splitwidth = style.pixelMetric(QtGui.QStyle.PM_SplitterWidth)
216
216
217 # Despite my best efforts to take the various margins into account, the
217 # Note 1: Despite my best efforts to take the various margins into
218 # width is still coming out a bit too small, so we include a fudge
218 # account, the width is still coming out a bit too small, so we include
219 # factor of one character here.
219 # a fudge factor of one character here.
220 width = font_metrics.maxWidth() * 81 + margin
220 # Note 2: QFontMetrics.maxWidth is not used here or anywhere else due
221 # to a Qt bug on certain Mac OS systems where it returns 0.
222 width = font_metrics.width(' ') * 81 + margin
221 width += style.pixelMetric(QtGui.QStyle.PM_ScrollBarExtent)
223 width += style.pixelMetric(QtGui.QStyle.PM_ScrollBarExtent)
222 if self.paging == 'hsplit':
224 if self.paging == 'hsplit':
223 width = width * 2 + splitwidth
225 width = width * 2 + splitwidth
@@ -940,7 +942,7 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
940
942
941 # Calculate the number of characters available.
943 # Calculate the number of characters available.
942 width = self._control.viewport().width()
944 width = self._control.viewport().width()
943 char_width = QtGui.QFontMetrics(self.font).maxWidth()
945 char_width = QtGui.QFontMetrics(self.font).width(' ')
944 displaywidth = max(10, (width / char_width) - 1)
946 displaywidth = max(10, (width / char_width) - 1)
945
947
946 # Some degenerate cases.
948 # Some degenerate cases.
General Comments 0
You need to be logged in to leave comments. Login now