Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] graphicstextlist: Use integer font metrics again #4524

Merged
merged 1 commit into from
Mar 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Orange/widgets/utils/graphicstextlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Optional, Union, Any, Iterable, List, Callable

from AnyQt.QtCore import Qt, QSizeF, QEvent, QMarginsF
from AnyQt.QtGui import QFont, QFontMetricsF, QFontInfo
from AnyQt.QtGui import QFont, QFontMetrics, QFontInfo
from AnyQt.QtWidgets import (
QGraphicsWidget, QSizePolicy, QGraphicsItemGroup, QGraphicsSimpleTextItem,
QGraphicsItem, QGraphicsScene, QGraphicsSceneResizeEvent
Expand Down Expand Up @@ -146,15 +146,15 @@ def __width_for_font(self, font: QFont) -> float:
key = font.key()
if key in self.__widthCache:
return self.__widthCache[key]
fm = QFontMetricsF(font)
fm = QFontMetrics(font)
width = max((fm.width(text) for text in self.__items),
default=0)
self.__widthCache[key] = width
return width

def __naturalsh(self) -> QSizeF:
"""Return the natural size hint (preferred sh with no constraints)."""
fm = QFontMetricsF(self.font())
fm = QFontMetrics(self.font())
spacing = self.__spacing
N = len(self.__items)
width = self.__width_for_font(self.font())
Expand Down Expand Up @@ -230,7 +230,7 @@ def __layout(self) -> None:

assert self.__group is not None
font = self.font()
fm = QFontMetricsF(font)
fm = QFontMetrics(font)

fontheight = fm.height()
# the available vertical space
Expand All @@ -245,7 +245,7 @@ def __layout(self) -> None:
# find a smaller font size to fit the height
psize = effective_point_size_for_height(font, cell_height)
font.setPointSizeF(psize)
fm = QFontMetricsF(font)
fm = QFontMetrics(font)
fontheight = fm.height()

if self.__autoScale and self.__effectiveFont != font:
Expand Down Expand Up @@ -304,7 +304,7 @@ def effective_point_size_for_height(
start = max(math.ceil(height), minsize)
font.setPointSizeF(start)
fix = 0
while QFontMetricsF(font).height() > height and start - (fix + step) > minsize:
while QFontMetrics(font).height() > height and start - (fix + step) > minsize:
fix += step
font.setPointSizeF(start - fix)
return QFontInfo(font).pointSizeF()
Expand Down