mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
A couple more QFontMetrics::width
This commit is contained in:
parent
8846f7fd44
commit
bd354daa0e
@ -61,8 +61,8 @@ class CodeEditor(QPlainTextEdit):
|
||||
|
||||
def line_number_area_width(self):
|
||||
# get largest width of digits
|
||||
w = self.fontMetrics()
|
||||
self.number_width = max(map(lambda x:w.width(str(x)), range(10)))
|
||||
fm = self.fontMetrics()
|
||||
self.number_width = max(map(lambda x:fm.horizontalAdvance(str(x)), range(10)))
|
||||
digits = 1
|
||||
limit = max(1, self.blockCount())
|
||||
while limit >= 10:
|
||||
@ -218,4 +218,3 @@ class CodeEditor(QPlainTextEdit):
|
||||
ev.accept()
|
||||
return
|
||||
QPlainTextEdit.keyPressEvent(self, ev)
|
||||
|
||||
|
@ -138,7 +138,7 @@ class FontFamilyDelegate(QStyledItemDelegate):
|
||||
painter.drawText(r, Qt.AlignmentFlag.AlignVCenter|Qt.AlignmentFlag.AlignLeading|Qt.TextFlag.TextSingleLine, text)
|
||||
|
||||
if (system != QFontDatabase.WritingSystem.Any):
|
||||
w = painter.fontMetrics().width(text + " ")
|
||||
w = painter.fontMetrics().horizontalAdvance(text + " ")
|
||||
painter.setFont(font2)
|
||||
sample = QFontDatabase.writingSystemSample(system)
|
||||
if (option.direction == Qt.LayoutDirection.RightToLeft):
|
||||
|
Loading…
x
Reference in New Issue
Block a user